# transform.Translate but Transform has Rotation!=0

Hi there!

I was testing enemies movements in my wannabe game, and I’ve noticed a behaviour that I really don’t like.

Basically, I got a simple translation function that should move the enemies to a given target Vector 3.
Skipping useless details, here’s the function itself:

``````//Your regular Translation function
void Move(Vector3 _target){

//DEBUG
if(Commander.allStandStill){

//Do nuffin!
}
else{
//First we define the direction - target is assumed as specified.
direction= _target - transform.position;

//We normalize it
direction = direction.normalized;

//We set up a Vector used to move you
moveVector = direction * speed * Time.deltaTime;

//We scale this so that speed 1 is the minimum value to move you
moveVector *= 12f;

//And then we move you
//Space.World helps moving decently even with a 25° X rotation
transform.Translate(moveVector.x,0f,moveVector.z, Space.World);
}
}
``````

Odd Things ( number 2 is the focus of this question):

1. As you can see I have to multiply moveVector by 12f. I don’t know why, but if I set the speed <= 11 the enemy doesn’t move, while values of 12 or above works. My solution was to multiply the vector by 12f so that a speed of 1 could work ( thus the scale starts at 1 now);
2. The enemy translates but it doesn’t follow a linear direction even though it’s supposed to do so. My game is 2.5d so little imprecisions of floats for x/z axes are fine, but these curves are obviously more than just a rushed rounding.

I’ve managed to track down a bit what I believe is the source of these curves: the object’s rotation.

All the object’s in my game have 25° of rotation on the X axis.
That’s my 2 cents in tweaking the perspective a little bit so the game seems deeper ( right now the camera is not ortho, and these 25 degrees really show off).

As a matter of fact, I’ve already tried the posted code on an enemy with default rotation ( 0) and everything went as expected: no curves or other oddities.

*Question is: * What would I need to fix those curves and make translation straight with a rotated object?

If you need to know more about my current set up, please let me know!

P.S.: If you think .Translate() is not the best method to use, feel free to point me toward other methods! Thanks for your time

you could change move with MoveToowards instead of translate, something like this:

transform.position = Vector3.MoveTowards(transform.position, _target, speed * Time.deltaTime);