Dear people of community,
I am creating a game where I need help to count how many times a certain animation has been played? So I could create a scoreboard out of that count. Any ideas?
Thank you all!
Dear people of community,
I am creating a game where I need help to count how many times a certain animation has been played? So I could create a scoreboard out of that count. Any ideas?
Thank you all!
Hmmm, don’t know the animation system well enough but if looping then the animation must have a duration.
Find that, for example let’s say the animation takes 1.49 seconds. Then let’s say you’ve got a bool that is true if the animation is playing, we’ll call the playMyAnimaton, also hold an int playedMyAnimation and increment that:
playedMyAnimation ++;
When that bool is set to true from false record the animation start time with a float like animStartTime.
animStartTime = Time.time;
then in update the playMyAnimation is true check if the current time is > animStartTime + 1.49f
if(Time.time > startAnimTime + 1.49f)
{
animStartTime = Time.time;
playedMyAnimation ++;
}
When you stop playing the animation set the bool to false.
playedMyAnimation should equal the amount of times played.
This is C# and you need to let us know what you’re language you’re coding in as well. Sorry it’s a bit vague but give us as much information as you can so the answer can be tailored to what you want.
there are probably better ways of doing this but it should work.