I have been looking around for some time on how to do this, but I did not find anything to help me.
I want to move an enemy towards the player at an angle (white line, the red is how it is moving now) , not really sure how to explain this so I drew it.
I am using RigidBody2D to move stuff around and the player moves around quite fast.
What you’re asking for is a little confusing. You seem to be asking to move at an angle but then your diagram seems to indicate you want to move in a straight line directly towards an enemy.
If you subtract the position of the player from the position of the enemy this will give you the vector pointing from the player to the enemy. If you then normalise this it’ll give you a unit direction (vector of length 1). You can then scale this by the speed you want to move per simulation step. If you then use Rigidbody2D.MovePosition(playerPosition + moveDirection) then it’ll move towards the player at the specific speed.
I could write a code snippet but maybe you should confirm this is what you want first i.e. move in a straight line towards an enemy.
I am sorry I messed up, I wanted to say that I want to move the enemy along the white line and that the red line is how it is moving right now.
I will edit my post.
Okay that makes more sense but I guess the next question is what is the actual behaviour here and what defines the white line to be what it is? Is it trying to predict an interception path based upon the enemies movement or something? Just some more details on what you want.
It’s hard for me to put this into words, sorry for that.
I would like for the enemy instead of charging straight at the player to curve around the player, when at a certain distance, and then to try and bump into him. I hope that makes sense.
A similar example of this is the movement of skulls in the game Devil Daggers, I think at least. Here is a video of that game from a top-down perspective, it is usually played in the first person. The player is the light that shoots and the skulls are the little grey circles that chase the player. Keep in mind that the skulls also move in the z coordinate in this game and I think that they lose momentum when they change direction. If you are going to take a look at the video I would skip to about 0:45 since until you can’t really see their movement.