Search Unity

Rotate object through c# script

Discussion in 'Scripting' started by Erin abrams, Aug 28, 2015.

  1. Erin abrams

    Erin abrams

    Joined:
    Mar 4, 2015
    Posts:
    22
    I was wondering how I might go about rotating an object when my play presses a button. I would like to have it so when my player presses the space button, it rotates and object 90°. I can't figure out how to do so. Thanks.
     
  2. Duugu

    Duugu

    Joined:
    May 23, 2015
    Posts:
    241
  3. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Code (CSharp):
    1. if (Input.GetKeyDown("Jump")) {
    2.    transform.Translate(0,90,0); //this will rotate it on the y axis, change it if needed
    3. }
     
  4. Duugu

    Duugu

    Joined:
    May 23, 2015
    Posts:
    241
    Ehm, Translate??
     
  5. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    sorry.Rotate