# How do i flip FromToRotation on a certain axis?

I am using FromToRotation to rotate towards an object in a 2D game, however, my Yaxis is facing downwards and i don’t know how to flip it without messing the rotation up.
Code(update method):

``````Vector2 direction = Player.position - new Vector3(Shoulder.transform.position.x, Shoulder.transform.position.y, Shoulder.transform.position.z);

Shoulder.transform.rotation = Quaternion.FromToRotation(Vector3.right, direction);
``````

Note: the black capsule is not the player.

Use Vector3.left instead of Vector3.right (or -Vector3.right)

I’ll move your post to the scripting forum, it does not relate to either 2D or 3D physics.

1 Like

It changes the direction am rotating to, not the rotation of the x axis, instead of pointing at the player, it points exactly opposite from the player…

Try with this (put it AFTER the rotation code)

``````transform.up = -transform.up
``````

This should flip it

It flipped the entire thing, using transform.right = -transform.right also did the same

Edit: Code:

``````            Vector2 direction = new Vector3(Player.position.x,Player.position.y, 0) - new Vector3(Shoulder.transform.position.x, 0, Shoulder.transform.position.z);

Shoulder.transform.rotation = Quaternion.FromToRotation(Vector3.right, direction);
Shoulder.transform.up = -Shoulder.transform.up;
``````

I guess that the pivot of the square is not in the center.
Scale it by -1 in local Y axis