1) First of all, let me roughly clarify a few concepts. You said:
Once I have the vector length (are "length", "speed" and "magnitude" all the same thing?), and vector direction (angle), how do I actually move the entity towards the player target at the specified angle and speed?
Yes, length and magnitude of a vector can be both terms used with the same meaning. However, technically, a vector is not an angle: it forms angles in relation to something else. In your example image, the line segment going from point B to point A forms an angle of around 51 degrees in relation to the X axis.
A vector is given by a point in space (in your case, 2D space). When we think of or use a vector as a direction, it means that it represents the direction going from the origin (0,0) to that given point in space. Not a specific angle. So, in your example, the vector (4,5) that you calculated is the direction from point B to point A. And actually, as you will se, that is all we need.
In what regards speed, that's a totally different thing. By you mixing that together with length and magnitude, it is apparent that you are confounding speed and velocity, which are two different concepts. Speed is just a scalar number that represents the amount of distance walked in a given time, i.e. length divided by elapsed time. Velocity is a vector given by the direction of the movement divided by elapsed time. Hence, the current speed of a movement is the length of the velocity of that movement. For more details, see: http://www.physicsclassroom.com/class/1DKin/Lesson-1/Speed-and-Velocity.
2) That said, the way I find to be the simplest to move an object using vector math is the following. You need 4 pieces: direction, length, speed and frame delta.Time.
In detail: you have to calculate the vector direction (not the angle) and normalize it, have to use the scalar speed that you desire, and have to apply a frame-to-frame delta time for consistency across different computers. You put all that in a loop that loops while the distance between moving char and destination point (in your case, point A) is lower than the total distance between points A and B. And voilá!
Let's do it. If the movement goes from point B to point A, then the vector direction of the movement is equal the location (position) of point A in the space minus the location (position) of the point B in space. I will use C# for the following examples, but you will get the idea:
Vector2 movement_direction = A.transform.position - B.transform.position;
Then, we normalize that vector. What does normalize mean? It only means that we take the vector "movement_direction" and force its length/magnitude to become equal 1. That's pretty simple to achieve: you just divide the vector by its length. See more here: http://www.fundza.com/vectors/normalize/. For that, we will need to get the direction lenght, just as you did:
float direction_length = Math.sqrt (Math.Pow(movement_direction.x,2) + Math.Pow(movement_direction.y,2) );
Then, let's normalize the direction of the movement:
Vector2 movement_direction_normalized = movement_direction / direction_length;
Now, you just choose the speed you want for your movement and you retrieve from your game engine the so called frame delta.Time, which is the time elapsed between the last frame and the current frame of the main game loop.
The final formula for the movement becomes, at each frame of the main loop while the movement is still going on:
movingchar.transform.position = movingchar.transform.position + (movement_direction_normalized * speed * Time.deltaTime;
It means that, at each iteration of the loop while movement is in place, you take the current location of the moving char and sum to it the result of the multiplication between the normalized direction of the movement, the speed of the movement and the frame delta.Time.
Note that you should execute the formula (i.e. update the movement) in a loop that keeps working until the updated distance between the moving character is smaller than the initial distance, i.e. smaller than the distance between points B and A.
Also note that including delta.Time is crucial, because that is the way you guarantee that you movement will have the same speed no matter how fast is the computer running the game. Otherwise, the speed would vary because of the difference in how fast computers calculate each frame of your game.
max_speed * -norm(V)
\$\endgroup\$atan(y/x)
I always suggestatan2(y, x)
because the algorithm ofatan2
can cope with the situation ofx
much smaller thany
, while the same situation would forceatan
to cope with a very largey/x
result. \$\endgroup\$