[SOLVED] How to attach a collision to an animation?

Hi. I am interested in the question, how can I attach a collision to an animation? If anyone has an example, I will be very grateful. :slightly_smiling_face:
Project: https://playcanvas.com/editor/scene/750784

Short answer: You can’t. You could teleport it every frame but that’s not recommended.

You best bet here in this case is to prevent any physics objects being near the door when it opens (eg. applying a force away from the door, playing an animation to step backwards etc).

Or you can apply rotation velocity to it so that it is roughly the same speed as the door when it opens. You may need to use a hinge in this case.

Thanks for the answer. I found this project, and I want to try to implement it in my project. I would be glad if you help me. :sweat_smile:

Ah, good catch.

What I said before only applies to rigidBodies.

What that project does is use the collider only (as a trigger) so that can be set/moved every frame. The downside is that it has no collision, so you have work out what to do if something enters the trigger. In that project, the developer gives an impulse to the entity that enters the collider.

I can listen to the trigger event, get the current coordinates of the trigger and move the player’s entity every frame?

@yaustar, I solved it. If you’re interested, here’s my solution :slightly_smiling_face:: https://playcanvas.com/editor/scene/750784

1 Like

I’m surprised you can set the rotation of a kinematic rigidbody through the entity. :thinking:

1 Like