So, basically, I’m working on a Sonic recreation fangame. I simply want to be able to switch between an idle and walk animation. I tried making it so that if you’re velocity is 0, idle animation plays. Else, if the velocity is greater than or less than 0, walk animation plays. So I implemented my code, but it only runs idle. Walk doesn’t work. Here’s my code for the animation section:
PlayerController.prototype.animation = function() {
if (this.entity.rigidbody.linearVelocity.x === 0) {
this.entity.sprite.clip('Idle').play = true;
this.entity.sprite.clip('Walk').play = false;
}
else if (this.entity.rigidbody.linearVelocity.x > 0 || this.entity.rigidbody.linearVelocity < 0) {
this.entity.sprite.clip('Idle').play = false;
this.entity.sprite.clip('Walk').play = true;
}
};
This code is located in the PlayerController script. Does anyone know how to fix the problem? Did I make a mistake?
Link To Editor: https://playcanvas.com/editor/scene/898825