Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Help with changing rotation speed and position of an image as time goes on.

Discussion in 'Scripting' started by russellscrosslin, May 13, 2023.

  1. russellscrosslin

    russellscrosslin

    Joined:
    Feb 25, 2023
    Posts:
    2
    I'm trying to understand how to do it. But I can't seem to wrap my head around it.
    Code (CSharp):
    1. void Update()
    2.     {
    3.         if (Input.GetKeyDown(LeftArrow))
    4.         {
    5.             transform.rotate.z + 1;
    6.         }
    7.     }
    I don't get it.
     
  2. russellscrosslin

    russellscrosslin

    Joined:
    Feb 25, 2023
    Posts:
    2
    Keep in mind, this is a 2D game.
     
  3. seejayjames

    seejayjames

    Joined:
    Jan 28, 2013
    Posts:
    685
    You want the key press to rotate as long as it's held down? Use getKey()
    Also you can't change the z value directly, you need to use a new Vector and change that, or use Rotate()