Basic enemy AI

Is there a way to make the ai climb/jump on some obstacles and avoid others? maybe by using tags?

Everything is possible, but I don’t think this is easy to achieve.

is was thinking maybe it could be a if else kinda thing

Where do you think you can apply that?

The ray detection

Maybe you can give it a try in de function below.

image

On line 409 you can try to add something like && !entity.tags.has('Climbable')

With this the AI will only move on the object if it coincidentally is moving that way.
Also the sensor height must be higher than the object, otherwise the AI ​​will move through it instead of on it.

All in all, I don’t think you will achieve the results you want.

If the sensor height is higher than the object, the object is already considered as climbable anyway, so the entire suggestion above is useless. Sorry.

so all I gotta do is raise the sensors?

The AI ​​will move on all objects lower than the value of the sensor height attribute. If the object is higher, it will be detected as an obstacle and the AI ​​will try to avoid it.

Suggestion, to make the enemy more customization and match the creators game better for navigation, I would suggest allowing the player to change the sensor length on the side and the front, making them separate, for example what if you want your enemy to avoid obstacles on its left and right but less in the front. This feature will make the enemies ai more advanced but also keeping it simple and easy.

What would be the use case for the AI ​​to avoid obstacles in front less?

The sensor lengths are precisely adjusted so that the balance for avoiding obstacles is optimal. If there is an imbalance, the AI ​​is more likely to move through obstacles. That’s why I think the sensors should only be extended as a whole and you basically only use this if the scaling of your character is different.

EXACLTY, to match the enemy size more correctly! Although in most cases it will be better balanced just having the option adds more customization and match the enemy scale better.

1 Like

But I think it would also be used for certain terrain types, for example, open areas will use balanced sensors, but something an area that is really space tight could be more turn sensitive.

The problem is that the script also has to be stable with every customizable part and that is not easy to achieve. I also don’t want the script to become more complex than it already is. If you study the script, you are still be able to change the raycasts.

How do I get an enemy to get through a pushable door with a collision?

Since the AI has no pathfinding and movement is based on target direction, it’s unlikely you get the AI through a small doorway anyway.

1 Like

I did it in Prasinophobia → PlayCanvas | HTML5 Game Engine
But that was pretty outdated code, I think it used tags or somthing, I just need the enemy to ignore the door like it is not there and it can get through.

I will see if I can add a way to ignore entities in the next update.

Just any entities with a “ignore tag” maybe? but also can you maybe just tell me what code to add since I already added ai to the project I am working on

Yes, it will be something like that. I can’t tell you what to do exactly as I first need to check and test. I expect you can do something similar as I describe in the post below.