Hello. I am currently exploring different possibilities on how I could create some sort of AI system like this: - YouTube (created by @solter) I am confused on how/where I should start, for example, should I use a pathfinding node module, or should I use pathfindingservice for this AI.
Any help would be appriciated, thanks.
i dont know much about ai stuff, so i probably wont be able to help much
the only input i can give is maybe constantly ray cast to the player’s humanoid root part within a certain distance, and if it isnt obstructed shoot at the player- and if they leave sight, pathfind towards their location
My own system was made with my own script based state machine.
I haven’t tested other systems and modules. So I can’t comment on their performance, but mine ran pretty well.
And yes I used roblox pathfinding to move ai from point a to point b for long distances, but don’t constantly recalculate this. Do this only when the end point is reached or the path needs to change. Also for something like zombies for close distance I would switch over to just MoveTo
If you want to make your own system do this:
- Make a path zone using parts for position and when the game starts have a script get the positions and delete the part itself. This will be a convenient for setting paths up later.
- You need to create a state machine by this I mean make a while true loop that basically calls out different functions that loops itself until a valid state is reached to transfer over to another state.
- You can also experiment with variables that scale ai properties to make it more aggressive with lower health for example.
- I did the ai vision detection by testing part visibility with raycasts and look vector based field of view
- Also you can further optimize by making the ai run slower or despawn altogether when the player is far
Very basic example of this: if enemy is closer than 100 studs go to attack state from idle.
PS. I am just about to make v2 version of my script so what I would upgrade myself is add leg movement separate to upper body (basically shooting). This way the ai will be able to strafe and move up while not always having to stop to shoot.