- Home /
Question by
SenhorNinja · Aug 19, 2017 at 01:09 AM ·
c#animationstop animations
Stop sliding animation
How do I stop my player animation (slide) after a certain time?
if (Input.GetButtonDown ("Slide") && grounded == true) {
slide = true;
}
grounded = Physics2D.OverlapCircle (GroundCheck.position, 0.2f, whatIsGround);
if (slide == true) {
timeTemp += Time.deltaTime;
if (timeTemp >= slideTemp)
{
slide = false;
}
}
Comment
Answer by Igor_Vasiak · Aug 19, 2017 at 01:49 AM
timeTemp += 1 * Time.deltaTime;
You need to add some value, and then multiply it by Time.deltaTime.
Hope I've helped.
The animation is still looping... Idk why but once I press the action button the animation starts looping.
You can change the whole "if (slide == true)" to:
if (slide) //This checks if it's true.
{
timeTemp += 1 * Time.deltaTime;
slide = timeTemp < slideTemp; //If this doesn't work, try putting the equasion of who is bigger than who between these things ().
}
else
timeTemp = 0;
Your answer
![](https://koobas.hobune.stream/wayback/20220612133042im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to play animation (C#) 3 Answers
Animation at the end of the level 1 Answer