- Home /
How can i control animations by using mouse click ?
Hi All,
I have three animations. i want to play one by one by using mouse click.
i wrote code like this
code:
using UnityEngine;
using System.Collections;
public class guiText : MonoBehaviour {
public GameObject gg;
public GameObject gg1;
public GameObject gg2;
public GameObject gg3;
public int count = 0;
// Use this for initialization
void Start () {
gg.animation.Play("Des");
//Lunch();
}
// Update is called once per frame
void Update () {
if(Input.GetButtonDown("Fire1"))
{
//gg1.animation.Play("Ap");
count++;
}
if(count==1)
{
//gg1.animation["Ap"].wrapMode = WrapMode.Once;
gg1.animation.Play("Ap");
}
if(count==2)
{
gg2.animation.Play("APP1");
}
if(count==3)
{
gg3.animation.Play("APPS2");
}
}
}
It is coming but i want to like ms power point ppt(ppt side type of thing) .
I want, if i click in the scene i want to play first animation once and stop. after clicking the second time mouse(left click of the mouse) i want to play second animation. like same 3 animation also.
can i get any solution. thanks ®ards Shankar
Answer by shanth · May 14, 2013 at 12:34 PM
using UnityEngine; using System.Collections;
public class guiText : MonoBehaviour {
public GameObject gg; public GameObject gg1; public GameObject gg2; public GameObject gg3; public int count = 0; public bool one,two,three; // Use this for initialization
void Start () {
gg.animation.Play("Des");
one = true;
two = true;
three = true;
//Lunch();
}
// Update is called once per frame void Update () {
if(Input.GetButtonDown("Fire1")) { //gg1.animation.Play("Ap"); count++; } if(count==1 && one) { one = false; //gg1.animation["Ap"].wrapMode = WrapMode.Once; gg1.animation.Play("Ap"); } if(count==2 && two) { two = false; gg2.animation.Play("APP1");
} if(count==3 && three) { three = false; gg3.animation.Play("APPS2");
}
} }
This script makes your objects to animate for only one time