Search Unity

Slightly confussed with setting a rotation

Discussion in 'Scripting' started by Sam_Pr, Jan 30, 2014.

  1. Sam_Pr

    Sam_Pr

    Joined:
    Aug 23, 2012
    Posts:
    66
    So, I'm having a bit of trouble setting an object's orientation using C#, I can only seem to rotate it over time instead of just snapping it to a certain rotation, example 0,0,0 so it's back to square one.

    Sorry for this nooby question, and thanks for answering!
     
  2. scryedzxp

    scryedzxp

    Joined:
    May 14, 2013
    Posts:
    47
    What's your code? If you want it to snap to one direction, just call that function once and make sure the degree is the right amount to rotate it to the desirable orientation.
     
  3. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    someTransform.rotation = someQuaternion;
    for the default rotation:
    someTransform.rotation = Quaternion.identity;
     
  4. Sam_Pr

    Sam_Pr

    Joined:
    Aug 23, 2012
    Posts:
    66
    Thanks a ton mate!