i want to apologize if this seems so basic, but I'm having trouble having an Enemy move in my Player's Direction in a 2D Top-Down game.
I already saw a lot of other answers but they all use the .LookAt()
and .Forward
but i'm not using rotations so i cannot just move them in the direction they are looking at, i just need to move them along X and Y, and i managed to do a pretty horrible workaround :
//I tried getting the difference between player and enemy positions, but this is relative, and slows down the closer it gets to the player.
Vector2 distance = new Vector2(player.position.x - enemy.position.x, player.position.y - enemy.position.y);
enemy.AddForce(distance * walkspeed);
So, how could i make the Enemy move in the direction the Player is, but with a constant speed?