Hello everyone,
I am new to the forum but not so new to unity. I have searched the forums and the web, but haven’t quite find the solution I am looking for. So what better place is there to ask than here. The problem I am currently having is that I need an animation to play, once a gui texture has been click. So far, everything is set-up and works. However, when it comes time to play the animation, it is cut off and does not play in its entirety.
I have verified that the animation does in fact work, used onMouseDrag() and it played.
Here is a snippet of the problem area:
function OnMouseDown()
{
mover.animation.Play("roll");
}
Any help would be greatly appreciated, BAM
If it works when using OnMouseDrag(), then its probably not playing completely because OnMouseDown() only fires for the frame that the GUIElement is clicked on…
try yielding OnMouseDown() for the duration of the animation, maybe?
function OnMouseDown()
{
mover.animation.Play("roll");
yield WaitForSeconds(mover.animation["roll"].length);
}
Ok, I just tried this approach and it yielded (no pun intended) the same result as before. When I used onMouseDrag, the animation played completely, but only while I had the mouse clicked down.
BAM
Hmm… I’m not really familiar with the OnMouse functions because I never use GUIElements, I always just use the OnGUI() stuff…
Maybe use a boolean var, set it to true OnMouseDown, and then in Update(), check if its true, and play the animation?
private var rollIsPlaying : boolean = false;
function Update(){
if(rollIsPlaying == true){
mover.animation.Play("roll");
}
}
function OnMouseDown()
{
rollIsPlaying = true;
}
Ok, so the animation is playing, and you…are awesome! I am just having a little problem stopping it from repeating, but that’s nice and easy.
Once again, Thank you for the help I am very very grateful.
BryanM
No problem my man, glad to help.
Hey legend ,
I want a help in animation . i’m rotating cube with help of animation . But what issue is when i play animation it always start form same position . i want to rotated cube the basics of swipe in which direction i;m doing swipe . here is link what i smiler want to Do