- Home /
how to call animations from a different game object
i am making a main menu for my game and i want to rotate the camera when you click a button so it can show another menu. i have this script that is attached to the button:
function OnMouseEnter () { renderer.material.color = Color.red; } function OnMouseExit () { renderer.material.color = Color.white; } function OnMouseUp() { animation.Play("controls switch");
}
My question is when i click the button i get an error saying that there is no animaton attached to the button, and i was wondering how to call animations from other game objects because this problem, and i have a problem with calling animations in other scripts as well.
There error is most likely because their is no animation entitled "controls switch" in the animations property of the animation component.
no there is an animation, the error is saying there is no animation attached to the button
Answer by Tyler Alvis · Mar 21, 2011 at 12:23 AM
i fixed it.
var arm : GameObject; arm = gameObject.FindWithTag("cam");
function OnMouseUp()
{
arm.animation.Play("control switch"); }