Stop the script - problem with myObject's rotation.

Hi,

I would like to ask you for help! I need to stop my script when “myObject” rotation reaches 0 in X,Y and Z axis ( or it’ll be close to that value, e.g. ±3 degrees ). Console shows me “Cannot convert ‘void’ to ‘UnityEngine.Transform’.”. I know what it means :wink: , but I have no idea how to make my script working. Thanks a LOT and sorry for my English! :slight_smile:

JS

#pragma strict
 
 private var h : float;
 private var v : float;


var horozontalSpeed : float = 0.5;
var verticalSpeed : float = 0.5;

var myObject : GameObject;

function Update()
 {
     if (Input.touchCount == 1)
     {
         var touch : Touch = Input.GetTouch(0);
         
         if (touch.phase == TouchPhase.Moved)
         {
             h = horozontalSpeed * touch.deltaPosition.x ;
             transform.Rotate( 0, h, 0 );
             
             v = verticalSpeed * touch.deltaPosition.y ;
             transform.Rotate( -v, 0, 0 );
            
         }
     }

var myObjectPos : Transform = transform.Rotate(0, 0, 0);

    if (myObjectPos && transform.Rotate != myObjectPos.Rotate)
    
    {    
     GetComponent(MoveBackRot).enabled = false;
     }
 }

void Rotate() is a function, but you’re trying to use it like a property. Try something like this instead:

var myObjectTrans : Transform = transform;
var myObjectPos : Vector3 = transform.position;
var myObjectRot : Quaternion = transform.rotation;

transform.rotation != myObjectPos.rotation

http://docs.unity3d.com/ScriptReference/Transform.html