Need help with simple animation script

Hello, I would like some help with my script please.

So this is my script.

var ColliderLeverPull = pc.createScript('colliderLeverPull');

// initialize code called once per entity
ColliderLeverPull.prototype.initialize = function () {
    this.entity.collision.on('collisionstart', this.onCollisionStart, this);
};








ColliderLeverPull.prototype.onCollisionStart = function (result) {
    
    
       if (result.other.rigidbody && this.entity.animation) {
        this.entity.animation.play("pull animation");
      }



    

};


What I want is the object (In this case the lever) to play an animation when I touch it.
I already have the animation ready and I added an Animation Legacy component to the entity, but when I touch it Nothing happens so I would really appreciate some help.

And thank you very much

Hi @DinoCalebProductions,

I would first verify that the trigger works e.g. add a console.log inside your if statement. If it prints, it works.

Secondly, I would verify that’s the full animation asset name (if it has an extension, add that too!).

If you keep having trouble try sharing an example project to take a look at.

Thank you very much for the help. (=