Search Unity

3D object is orbiting instead of Rotating

Discussion in 'Scripting' started by Deleted User, Apr 9, 2021.

  1. Deleted User

    Deleted User

    Guest

    Hi,
    I am trying to rotate a 3D object. However, instead of rotating it is orbiting around. The same scripts works properly for other 3D object. Can someone please point me in the right direction?

    Code (CSharp):
    1. cube1.transform.Rotate(xAngle, yAngle, Time.deltaTime*25, Space.Self); // This sample 3D object rotates correctly
    2.  
    3. transform.Rotate(xAngle, Time.deltaTime*25, 0, Space.World); // This object orbits instead of rotation
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The code you have will cause it to rotate. It may appear to orbit if the visual representation of the object is a child object, and the child object is off center, causing the appearance of the child object orbiting the position of the parent. It is like if you extend your arm out to the side holding a glass and then spin in a circle, the glass is basically orbiting you.
     
    SparrowGS likes this.