My animation is all in one so I am trying to seperate it. Here is the code for that:
document.body.onclick=function(){
var anim = en.entity.animation.getAnimation('FireGun');
anim.firstFrame = 0;
anim.lastFrame = 8;
en.entity.animation.play("FireGun");
};
But I can’t get it to work. Can you help me or suggest a better way? Thanks!
here is the link:
https://playcanvas.com/editor/project/747902
yaustar
December 19, 2020, 12:55am
#2
firstFrame and lastFrame are not valid properties for the Animation object as shown by the API docs https://developer.playcanvas.com/en/api/pc.Animation.html
You will have to start digging into the engine source code to work out what is needed to play a sub set of the animation.
Not quite sure what that means but ok…
Can you please explain what you mean by that?
yaustar
December 19, 2020, 6:36pm
#5
Okay, to put it another way: where do you see firstFrame and lastFrame in the PlayCanvas documentation?
I didn’t. I got it from here:
I’ve modified the animation system to do this in my code, it isn’t possible with the base animation stuff.
I “think” that all you should need to do to include it in your project is to put this code somewhere and then set .startFrame and .lastFrame on your animation instance or skeleton (either should be fine).
pc.Skeleton.prototype.addTime = function(delta) {
if (this._animation !== null) {
this.firstFrame = this._animation.firstFrame !== undefined ? this._animation.firstFrame : t…
I am really just trying to split an animation without the use of any other software.
yaustar
December 19, 2020, 6:53pm
#7
I believe that post modified the engine with the patch code in that post which changes how the engine works. If you haven’t added that patch to the project, the code you have posted will not work.
Also bear in the mind that the engine code may have changed since 3 years ago so the patch may no longer work anyway.
Are there any other options?
All the skethfab gun models have all the animations put together.
yaustar
December 19, 2020, 7:23pm
#9
Like whydoidoit did, you will have to dig into the engine source and work out what you would need to change/patch to get the functionality you need.
Or contact the original animator of the file you are using to upload a version with the animations split.