- Home /
Trouble with animation Rewind/stop
Hi, im having trouble with the animation rewind/ stop function.
I basically want the animation, once clicked to play to the end of its cycle(frame 60), then to revert back the beginning (frame 1). Ive changed the wrap mode from once to ping pong, which gets it animating the way I want it to, but it wont stop.
Thanks in advance Mark.
using UnityEngine; using System.Collections;
public class TP_Attack : MonoBehaviour {
public int Counter = 1;
void Update (){
if (Input.GetKeyDown(KeyCode.Mouse0))
{
if (Counter == 1) {
animation.CrossFade("Attack1");
Counter = 2;
}
if (Counter == 2) {
animation.Rewind("Attack1");
Counter = 1;
}
}
}
},Hi, I need help regarding the animation rewinding/stop function.
I basically want to play an animation when I click on the mouse, once it hits the end of its cycle (frame 60), for it to revert back and play the animation in reverse (frame 1).
If I change the Wrap Mode to ping pong, it plays it correctly, but it wont stop.
Thanks in Advance Mark.
Here is my code:
using UnityEngine; using System.Collections;
public class TP_Attack : MonoBehaviour {
public int Counter = 1;
void Update (){
if (Input.GetKeyDown(KeyCode.Mouse0))
{
if (Counter == 1) {
animation.CrossFade("Attack1");
Counter = 2;
}
if (Counter == 2) {
animation.Rewind("Attack1");
Counter = 1;
}
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613104850im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
ANimation doesn't rewind on animation.Stop 3 Answers
pingpong animation question 2 Answers
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers
Detect if is playing an animation 1 Answer