If you look at the setState function, you can see that it requires the property name of the animation to be passed to. In this case, âpunchâ property is set to the âGreat_Sword_Slash.jsonâ and âidleâ to âRifle Run.jsonâ.
So either:
Change the property names in AnimationBlending.states to much what you want them to be
Call the existing property names in AnimationBlending.states
thatâs very vague did the link go through for you
call the existing properties what,
to get the character to respond to a key trigger
or that the .fbx is responsive to pressing_P
AnimationBlending.prototype.setState = function (state) {
var states = AnimationBlending.states;
this.state = state;
// Set the current animation, taking 0.2 seconds to blend from
// the current animation state to the start of the target animation.
this.entity.animation.play(states[state].animation, this.blendTime);
};
The param state is a string of the property that should refer to one of the properties in AnimationBlending.states which are currently âidleâ or âpunchâ.
However, you are passing âRifle Runâ which doesnât exist and you get an undefined error.
Therefore you have two ways to fix it:
Change the property names in AnimationBlending.states to be what you want them to be (I assume it be âGreat Sword Slashâ and âRifle Runâ)
Call setState with a property that already exists in AnimationBlending.states which is âidleâ and âpunchâ.
how is this so @*!^ itâs literally the most basic thing you can call it an animation blend but itâs not, its a simple trigger itâs hardly a keyboard input, i want i press p and it triggers the punch in this case the riffle run
var AnimationBlending = pc.createScript(âanimationBlendingâ);
Iâve been trying to steer you in understanding the code by explaining what it is doing. Below is an âanswerâ but I worry you will just run into similar problems.
Change
AnimationBlending.prototype.keyDown = function {
if ((P.key === pc.KEY_P) && (this.state !== 'Two Hand Spell Casting.json')) {
this.setState('Two Hand Spell Casting.json');
}
}
(Yes, I 'm asking you to change it to the âpunchâ state. Try it, if it works, refer back to my reply here that explains why: Animation Blending - keyboard input