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:

What is BoundingBoxGizmo there? I thought the gizmos is something like visual debug lines, but it looks that I don’t see any gizmos there :smiley:
Why does gizmos can handle collisions? It’s hard to understand for me :grinning:
So that Gizmo creates a collider (actually bounding box) for a Mesh?

Why do we do those meshes not pickable? What if we need to pick that avatar mesh?

Sorry, I didn’t found any documentation on that.

The thread is more than 2 years old, and it looks like a lot of questions :slight_smile:

Could you start a new one with a simple targeted repro of your issue and we could try to help as best as possible.

2 Likes