How to use moveWithCollisions with a composed object?

Hello!

I am trying to make a 3D game with Babylonjs, and I am currently working on enemies’ movements and physic. I struggle to use the moveWithCollision method on my “avatar” class, extending the Mesh class.

Setting the avatar’s physic with an Ellipsoid doesn’t seem to work as no collisions are detected and avatars go through each other. If I try to set the checkCollisions attribute of a sub mesh to true instead, the avatar doesn’t follow the direction given at all.

Here’s a playground that sums up my problem:

How should I proceed so my avatars work with collisions and all related things and move as expected with the moveWithCollisions method?

Thanks a lot for reading me!

I get better result when setting the tail with collisions

move With Collisions | Babylon.js Playground (babylonjs.com)

There is something going wrong with the body. Can you open an issue @carolhmj . I won’t have time to check it before going on vacation.

2 Likes

MoveWithCollisions issues · Issue #12710 · BabylonJS/Babylon.js (github.com) Created! In the meantime, using MakeNotPickableAndWrapInBoundingBox seems to be a workaround :smiley: move With Collisions | Babylon.js Playground (babylonjs.com)

1 Like

The avatar does not have geometry information and is skipped by the collision detection. The solution proposed by @carolhmj is the best one: create geometry (boundingBox geometry) and move it.
This way, the other avatar is properly tested against the ellipsoid.

2 Likes

Thanks a lot! :smile: