I would need a script that works like this:When I click first time mouse button Fire1 it does animation 1…if I click it again after that it does animation 2
This sounds like an easy script but I couldn’t make it work fully…I could make it using 2 different buttons but not this way soo help
Also this in not a iphone game…just a classic PC soo I dont think those script will work.
just keep a boolean variable that when true it does animation 1 and false animation 2 then everytime you call you just change the value of the variable.
That would only work for 2 animations, if you want to use more animations you can use switch case :
int count = 1;
void OnGUI ()
{
if(GUILayout.Button("test"))
{
test (count);
count ++;
}
}
void test (int i)
{
switch(i)
{
case 1:
Debug.Log("count = " + i);
break;
case 2:
Debug.Log("count = " + i);
break;
default:
count = 0;
Debug.Log("count = " + i);
break;
}
}
This is my script that I use for animations…I play one animations forward and then backward…how can I add that in this script?
Also I think I already tried that…using booleans
var check1 : String = "played";
var check2 : String = "reset";
var Timecheck1 : boolean = false;
var Timecheck2 : boolean = false;
var front : float = 1;
var back : float = -1;
var firstA : AnimationClip;
var secondA : AnimationClip;
var Time = 0;
waiting = WaitForSeconds(3);
function Update () {
var leftmouse = Input.GetButtonDown("Fire1");
var rightmouse=Input.GetButtonDown("Fire2");
if(leftmouse){
animation["full beyblade parts"].speed=front ;
animation.Play("full beyblade parts");
Debug.Log(check1+Time);
Timecheck1=true;
}else if(rightmouse){
Time=2;
animation["full beyblade parts"].speed=back ;
animation["full beyblade parts"].time=animation["full beyblade parts"].length;
animation.Play("full beyblade parts");
Debug.Log(check2+Time);
Timecheck2=true;
}
if(Timecheck1){
Time = 0;
Debug.Log("Time back");
Timecheck1=false;
}
if(Timecheck2){
Time = 0;
Debug.Log("Time back 2");
Timecheck2=false;
}
}
Hey appels…I am working with java only cuz I am a beginner
Is void java code?
Also I know there is unnecessary checking…cuz I tried few times with different solutions that came into my mind…
You can also use switch case in Unityscript but in your case you use the mouse buttons. So your limiting yourself to 2 animations.
If you want to use more animations you’ll need to alter your script to work that way.
A simple Google search would also give you an answer to general coding questions. Search for javascript and switch case. It will even give you examples that way. It’s still alot faster then posting here and waiting for an answer