Hello,
i;m trying to make my first game in unity,
so my question maybe is silly but i need help :
I have one door - gate, and i want when my player collect the “key” - another object in my game - with tag “key”
the rotation of my gate to me (0,90,0). X,Y, Z axis.
So i create my “key” - and also my gate.
On my player i have this code:
var score:GameObject;
private var dead = false;
var gate = false;
function OnControllerColliderHit( col: ControllerColliderHit)
{
//col is the object that enter the Collider Box of the cube
var val:int;
if(col.gameObject.tag == “coin”)
{
val=1;
score.SendMessage(“updateScore”, val);
Destroy(col.gameObject);
}
//gate code here
if(col.gameObject.tag == “key”)
{
gate = true;
Destroy(col.gameObject);
gameObject.Finf(“key”).transform.rotation = Vector3(0,90,0);
}
//sea code here
if(col.gameObject.tag == “sea”)
{
dead = true;
//subscribe life here
HealthControl.LIVES -=1;
}
}
function LateUpdate()
{
if(dead)
{
transform.position = Vector3(950,155,1480);
gameObject.Finf(“Main Camera”).transform.position = Vector3(950,155,1480);
dead = false;
}
}
but i still cannot rotate my gate. =(
thank you
znoey
February 10, 2012, 12:46am
2
Did you try doing
gameObject.Find("key").transform.rotation = Vector3(0, 90, 0);
Notice the spelling error on Finf in the code posted above.
Also… rotation is a Quaternion, you cannot try to fill it with a Vector3… Replace Vector3(0,90, 0) with Quaternion.Euler(0,90,0)