Search Unity

trying to rotate an object (2D) around it's center

Discussion in 'Scripting' started by pKallv, Aug 20, 2014.

  1. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    Code (csharp):
    1.  
    2. void On_Twist( Gesture gesture) {
    3.     selected_GameObject.transform.Rotate(0, 0, gesture.twistAngle);

    I am using Easy Touch 3.1 and I am trying to rotate an object around it's center but do not get it to work. It does rotate but as i move the two fingers (simulated) away from the center the object does not rotate correct.

    I would very much appreciate some help here.

    twistAngle = The angle of the twist
     
  2. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    If you are using sprites, make sure the pivot is in its centre. You can always parent the sprite to an empty gameObject to change its centre.
     
  3. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    The pivot is set in the center. The effect is that if i keep the fingers close the object will rotate but as i move the fingers apart the object follows one of the fingers. I would like to rotate around the center independently of were the fingers are located.