-1

Right now it seems the only way to rotate a game object is to input the rotation based on degrees. Is there a way to rotate a game object using a normalized Vector3, where its x,y,z are between -1 and 1.

I have tried just multiplying the Vector3 by 90 instead which seems to work. But I was wondering if there is a better solution.

Bob
  • 105
  • 1
  • 9
  • What do you mean exactly? There are many ways how objects can be rotated in Unity .. and there are many `Vector3` and `Quaternion` helper methods to achieve that ... What exactly are you trying to achieve? What does `-1` and `1` stand for? `-180` to `180`? Or `-360` to `360`? ... If it is just about mapping then yes simply do e.g. `transform.rotation = Quaternion.Euler(yourVector * 180);` – derHugo Dec 20 '21 at 12:53
  • I'm trying to rotate an object using a Vector3 where all its values are between -1 and 1. For example a value of (1, 0, 0) would mean the object is facing forward on the x-axis. – Bob Dec 20 '21 at 12:56

1 Answers1

1

From what you describe it sounds like you simply want to do e.g.

transform.forward = directionVector;

or you could also use Quaternion.LookRotation

transform.rotation = Quaternion.LookRotation(directionVector);
derHugo
  • 83,094
  • 9
  • 75
  • 115