- Home /
Question by
Jammer3000 · Jul 06, 2012 at 01:49 PM ·
animationcameragameobject
How to run an animation mouse click.
Hi I need to know how to run an animation on a mouse click. For example I have a scene that has an animation on the camera, plus I have a button with a box collider at the bottom right of my scene, so here's what I want to happen, when I click play I want it so when I click my button(that has the box collider on it) I want it to play the animation I assigned to my camera. And if you can please write the code in java it would be awesome. Thanks so much.
Animation name = CameraAnimation1 Camera name = MainCamera
Comment
Answer by xKroniK13x · Jul 06, 2012 at 04:39 PM
if(Input.GetMouseButtonDown(0)){
Animation name = CameraAnimation1 Camera name = MainCamera
}
Wiki
Answer by Ingen · Jul 06, 2012 at 07:45 PM
Hi, I use this to play 2 animation and work,
and think this can be good for You,
function OnMouseOver()
{
GetButton("Fire1")) // GetButtonUp("Fire1")) - GetButtonDown("Fire1"))
{
GameObject.Find("buttonPlay").animation.Play("ButtonAnim");
/* "buttonPlay" the button to press to start the animation
"ButtonAnim" the animation of pressed button
if there is, if not remove the string above
*/
animation.Play("NameOfAnimation");
}
}
but submit myself at who have better experience