How do I move simple AI in a 2D space?
I've been looking all over for a solution that works and maybe it's so simple that thats why I can't find anyone talking about it but I have my little 2D AI BP character who I would like to make move around. However the 'simiple move to location' function in BP is for nav meshes and using it in a 2d space doesn't seem to work.
Whats the best/simplest way to get a 2D character to move to a new location? Specifically which function in BP.
asked Dec 29 '15 at 06:31 PM in Blueprint Scripting
There are a lot of "it depends" type answers that could be given here, depending on if your AI is like a physics driven ball, or a character-movement driven character (instead of a pawn) or maybe even a paper 2D sprite in screen space. But the overall techniques come down to two main choices:
So given you said you're having a problem implementing a nav meshed solution, here's how to do the 2nd way.
So that's how you steer. To hit the gas, you'll want to have a variable you can play with to adjust your Speed. This should probably be multiplied by the Delta Seconds coming from the Tick event so that games played on computers with higher frame rates don't see the AI going faster.
Depending on what type of movement input you want to use, you'll now have all the pieces to get your AI to move in the correct direction towards a goal. The "Add Movement Input" node takes a Scale Value (your gas pedal) separate from your Direction (your steering). The "Add Input Vector" combines them both (by multiplying them).
In this example, the goal is a target actor stored in a variable I made called "My Target". So this would work if you wanted the AI to move towards the player for example. But you could also do this so it goes towards a specific location or in a specific direction by feeding it a vector instead of using My Target's actor location.
Not too hard once you've done it once or twice - hope this helps.
answered Dec 29 '15 at 11:00 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here