Hi,i made simple script,it plays animation when raycast hits cube. So problem is,what i want to do is : When i press “e” button cube play “Clip1” and WHEN i press again button “e” cube play animation “Clip2”. Everything seems okey,but its not. Clip1 plays perfect but “Clip2” not. I done something wrong i know,can anyone help me?
var Cube : GameObject;
var Clip1 : AnimationClip;
var Clip2 : AnimationClip;
function Start()
{
Cube = GameObject.Find("Cube.This");
}
function Update()
{
if (Input.GetKeyDown(KeyCode.E))
{
var hit : RaycastHit;
if (Physics.Raycast(transform.position, transform.forward, hit, 100.0F))
{
if(hit.transform.tag == "Cube")
{
print("First");
Cube.animation.Play("Clip1");
} else {
print("Second");
Cube.animation.Play("Clip2");
}
}
}
}
Something is wrong in else function.