- Home /
Causing animaton on mouseclick?
I have a rope object that I want to be able to click on and that will cause the rope animation to play which is just it being pulled down and then I have another two cubes acting as curtains which I want to open. So I have two animation, one for each, for them being pulled to the sides and then back together.
So to just test that I had a good idea of what to do I just did a basic test of trying to click on the rope and just getting one cube to move. For that I wrote
function OnTriggerEnter(other : Collider){
if (Input.GetKey("Mouse1")){
GameObject.Find("Curtain").animation.Play("CurtainClose");
}
}
But nothing happens for this. Clicking on the rope does nothing. Also not sure when I figure that out how to play multiple animations from the single clip. Would I just add && and continue to list the other two animations?
Thanks for any and all help!
Answer by tw1st3d · Oct 03, 2013 at 02:39 AM
Just drop this onto your Curtain object.
function OnMouseDown()
{
GameObject.Find("Curtain").animation.Play("CurtainClose");
}
@tw1st3d, I think you meant to say "drop this on your Rope object"
Eugh, yeah sorry. $$anonymous$$ust have misread it since I just skimmed it.
If this was correct, would you $$anonymous$$d ticking my answer? :)