Search Unity

object rotation by 30 degrees

Discussion in 'Scripting' started by Trild123787898, Jan 26, 2020.

  1. Trild123787898

    Trild123787898

    Joined:
    Dec 9, 2018
    Posts:
    206
    how can I make it so that when I press the key, the object turned 30 degrees and then couldn’t, what do I need to change in the script?

    Code (CSharp):
    1.  rigibody.MoveRotation(Quaternion.AngleAxis(30, Vector3.right) * rigidbody.rotation);
     
  2. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    Perhaps start with posting a script, not a single line. Also, it would help of you told us what you are trying to do (turn an object 30 degrees around which axis, over time or instantly), and what part of your current attempt isn't working. If you do that, perhaps more People might be able to help you.
     
  3. davidnibi

    davidnibi

    Joined:
    Dec 19, 2012
    Posts:
    426
    You want to continually rotate it 30 degrees with every keypress?
    Every time you press a key you will need to add 30 to the current rotation, instead of just declaring the declaring the rotation.