I am trying to get my AI (a ship constrained to a 2D plane) to turn towards its target but without having it just rotate directly to face its target then move in a straight line to it. I’d like to be able to have it perform a steering maneuver like an actual ship would, eg an arc that would change size depending on how far/fast it needs to turn.
Can anyone offer any insight into this? I’m not great at vector math so its a pain in the butt trying to solve this.
I’d love to be able to hook it up to the in built navigation so I can also avoid obstacles and whatnot!
Any help is seriously appreciated.
For a ship you might want to make your own pawn movement component. It’s fairly easy if you are doing 2d movement.
For player movement you can just add the movement input always towards the “desired vector” projected to “forward vector”.normalized and add control rotation using the desired movement vector scaled by velocity.
For collisions I did these during a previous situation with custom movement:
When moving, I trace ahead and ALWAYS place the pawn 1 full unit (or more) before the actual hit location because the resulting location is not always really not overlapping. Better to be safe than stuck.
Projecting my velocity to a plane with the impact normal and making that my new velocity I made it “slide off” of obstacles.
It might be a good idea to use some collision testing for AI though so it reverses when an obstacle is in the way. Using the built-in navigation is alright but actually planning a path taking the turn radius into consideration… ugh.
I’m sort of trying to do something similar currently (that’s how I found this question) but for a mech so I’m using the built-in character movement component in blueprint mode because aside from a few things like the wide turn, these are essentially behaving like characters. But sadly I’m not sure how to make the MoveTo order move like what I need. Acceleration etc. is taken care of now but the turning is still beyond me