Collider not moving with animation

Hey guys today i found out that collider is not moving with an animation, is there a way to tell collider to follow

those rollers have animated path

Unfortunately, no. Physics would be based on the entity position, not the mesh/animation.

If the colliders are just triggers, you could update the position and rotation on every frame based on the bone/node position of the mesh of the animation.

Yes they act as triggers, is there any topic related to this? I never tried tried it . I found only this scene where it is done but i dont understand what is nodeName which is MaleBaseMesh:LeftHand

https://playcanvas.com/editor/scene/980178

No tutorial on this.

You would work which graphNode in the hierarchy at runtime is the one animating. Use findByName on the entity that is animating and get the graphNode. Then you can get the position and rotation of the graphNode

1 Like

MaleBaseMesh:LeftHand is simply a name of the bone of the armature in that model. You can name the bones in your 3D modelling software and then address them as graph nodes in Playcanvas:

1 Like

Okay nice thanks, so will the box with collider follow the bone if i set it up through code?

Yes, if you add your box entity with the collider as a child to that bone node. Just make sure to avoid adding a rigid body to that entity unless you are using a kinematic object and you know what you are doing with that.

1 Like

Thank you so much :slight_smile: Its going to act as a trigger so there is no need to add a rigidbody

1 Like

Hmm any ideas where is the issue? Im trying to set an object with collider as a child of bone

image

this.entity already has a parent so you can’t use addChild.

Use reparent instead.

this.entity.reparent(this.nodeToFollow)

1 Like

Yes i found out thank you :slight_smile: