Make player character lock on and move toward target
I'm creating a 2d fighing game. In it, the fighters can fly and battle. Currently, characters are just flying around free form. My issue is I need a way to have the player 'lock on' mid battle if they want to and have them face and then move to wherever the opponent goes (similar to how it was setup in the dragonball z budokai series https://www.youtube.com/watch?v=gkbCsIq_LXI). So far I've been able to orient the player character's rotation to always face the oppoent but I do not know how to have them follow wherever the opponent goes. Any suggestions?
asked Aug 07 '16 at 02:03 AM in C++ Programming
I am not sure if I understand everything you are asking, but I think you want the movement to locked to the target, right? So if the target moves, the distance should stay the same?
If so, then you can do this in two ways.
First implementation Read the location of your target every frame and store it's location. Then just calculate the difference in location and add it to your own location. You would have to make sure that you aren't colliding with anything though.
Store the Vector
answered Aug 07 '16 at 02:34 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here