Hey guys i was wondering if it is there any method for stopping current animation through lines of code
Hi @smokys,
You can easily do so by setting the current time of the animation component to be equal to the duration property, that is the duration of the current animation playing.
If looping is disabled the animation will stop.
this.entity.animation.currentTime = this.entity.animation.duration;
You can check these properties here:
https://developer.playcanvas.com/en/api/pc.AnimationComponent.html
2 Likes
Many thanks
1 Like
You can also modify the animation speed. Using a value of zero will stop the animation.
this.entity.animation.speed = 0;
Reset it to a positive value and the animation will resume from where it was stopped.
5 Likes