Search Unity

Always rotate Gameobject to the right site

Discussion in 'VR' started by martinK95, Jul 31, 2017.

  1. martinK95

    martinK95

    Joined:
    Jul 27, 2017
    Posts:
    2
    Hello, im using an 3D-Arrow that is always in the Users Field of View at the Position of the Cursor and want it to turn right no matter where the User is looking at. I already played around a little with the Quaternion.LookRotation Method but couldn't make it show exactly to the right relative to the camera at every position.
    Anyone knows how i can correctly implement this?
     
  2. unity_andrewc

    unity_andrewc

    Unity Technologies

    Joined:
    Dec 14, 2015
    Posts:
    223
    That depends a bit on the way the model is oriented initially. An arbitrary arrow model could be pointing in any arbitrary direction when its rotation is set to just the identity quaternion.

    But once you've determined which way it's pointing in Unity space when its rotation is identity, it should be pretty straightforward. I'm pretty sure all you'd need to do is say:
    transform.rotation.SetFromToRotation(directionDeterminedBasedOnModel, Camera.transform.right);