I wanted to create a hurt/hit sprite for my character whenever she hits a wall, but it seems she also plays the sprite whenever she collects items. I modified the code found here Collision and Triggers | Learn PlayCanvas and used contact
as my event.
Below is the code I used to activate the hurt/hit sprite. I want to make an exception for the “ORBS” category of entities. The orbs have a RigidBody (Static) and Collision component, and have no scripts.
Movement.prototype.onCollisionStart = function (result) {
if (result.other.rigidbody)) {
this.entity.sprite.play("HurtSprite");
}
};
I’m at a loss on what to do and help would be most appreciated! Thanks!
project link: PlayCanvas | HTML5 Game Engine