1
\$\begingroup\$

How do I invert my arrow that is pointing Z forward to point backwards? The arrow has it own rotation and position. The arrow is also linked to it´s parent rotation and moving position in space. I wish to rotate flip direction of my arrow conserving the direction of it, so that it points in the opposite direction of one local axis (Z for example). Without losing the parent or it´s own direction in space.

transform.localRotation = Quaternion.... Z * -1

Is there more than one way to do this?

Probably by rotating in Y 180°? I wish not to scale Y to -1.

transform.rotation = new Quaternion.AngleAxis(Vector3.up, 180f);

enter image description here

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Rotating is the right choice. Scaling -1 will also invert normals, which is often undesirable. \$\endgroup\$
    – Kromster
    Commented Mar 15, 2017 at 19:38

1 Answer 1

0
\$\begingroup\$
// rotate following parent. localEulerAngles CAN CAUSE CRAZY ROTATION PROBLEMS
transform.localEulerAngles = new Vector3(0f, 180f, 0f);

Making a rotation in Y will make the arrow to pointing back. If is necessary make the arrow a child object of the Game Object transform that you are rotating. In this way, this line of code will not affect the direction and the final rotation will be opposite to the Game Object parent.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .