# solved moveWithCollisions issue

## Recommended Posts

see

Here I have 2 boxes box1 and box 2.

box1 is way above box2

I move box2  down by 1m  using moveWithCollision().

I print the before and after position on console.

Everthing works as expected.

But now if i turn on collision on box1 (uncomment line 21), box2 does not move  !!

##### Share on other sites

Hello, you just need to compute world matrix for box1 if you want to do the move without waiting for a render:

##### Share on other sites

Thanks. Keep forgetting about compute world matrix

Here is another issue though

Now I am trying to move box1 down towards box2 by 0.25m

Gap between them is 1m.

But box1 does not move down at all.

Infact it moves up by 0.01.

##### Share on other sites

Remember that meshes are using the ellipsoid property to define their impostor when using collisions

##### Share on other sites

Yes I was wondering about the ellipsoid property.

Can you clarify few points below?

a. In the above example the gap between the boxes is 1m. Does box1's ellipsoid extends outside the box1 bounding box by 1m?

b. If I move box1 with moveWithCollision then I am assuming the collider system uses its ellipsoid  as the impostor.
It is NOT being moved by moveWithCollision?
Does the collider system uses its ellipsoid too or does it use its bounding box as impostor?

##### Share on other sites

Collision system only uses ellipsoid on the caller (so only on box2 hereif you call moveWithCollisions on box2)

So :

a. by default the ellipsoid is 0.5,1,0.5 so 1m from the center of the box1 on every side which leads to a 2m height ellipsoid centered on the box

b. Correct. box2 is used directly (the vertices are used)

##### Share on other sites

Regarding a.
If the height of the ellipsoid is 2m and is centered on the box and height of the box is 1m then that means the ellipsoid should only extend 0.5m outside the box, at the top and bottom.
That means the gap between the bottom of box1's ellipsoid and top surface of box2  is 0.5m.
Should I not be able to move the box1 down by atleast 0.25m?

##### Share on other sites

Sure but you need to center the ellispoid on the box:

by default it uses 0,0,0 as origin

##### Share on other sites

Sorry to be a bother but I still don't get it.
I do not see why we have to move the ellipsoid up by 1m.
As you can see from, my very professionally drawn, sketch below   there is already a gap of 0.5 meter between the ellipsoid and box2.
What am I missing?

##### Share on other sites

No worry

Initially ellipsoid based collision was made for the FreeCamera to simulate FPS. In this mindset, the ellipsoid is positioned to have his top aligned with the camera top (as you expect the camera to be the eyes of the player)

Based on this assertion, all ellipsoids are created like this:

So in your case you need to move it up by 1 (as the ellipsoid is 2 units tall)

##### Share on other sites

So if I move the ellisoid up by 1m I should then be able to move box1 down by 1 m.
But that does not happen. It only moves down by 0.5m.
See https://www.babylonjs-playground.com/indexstable#97B3B7#17

So it would seem the ellipsoid is positioned as follows

The top of the ellipsoid at the center of mesh?

And thanks for indulging all my questions.

##### Share on other sites

@satguru  & @Deltakosh

Stange indeed, when the ellipsoid is default y 1 and ellipsoidOffset y is also 1 so center of ellipsoid is at box1's top and bottom of ellipsoid is at box1's bottom,
it isn't working as your PG displays,

If you change both values to .5, so center of ellipsoid is at box1's center and bottom of ellipsoid is still at box1's bottom it works..
https://www.babylonjs-playground.com/indexstable#97B3B7#18

something does seem fishy
##### Share on other sites

@satguru yeah you are right actually. The goal is still to represents a head initially. So your schema is correct

This may require a bit of documentation

##### Share on other sites

@Deltakosh nice. Have few more questions but will ask them in the question forum. Thx

@aWeirdo Not fishy anymore  When you make ellipsoid.y=0.5, you are changing the  ellipsoid height to 1m (same as that of box) and when you make ellipsoidOffset.y = 0.5 you move the ellipsoid's top to the top of box thus moving the ellipsoid completely inside the box

##### Share on other sites

What i ment is fishy,
is when both values are 1,
the bottom of the ellipsoid should also align with the bottom of box1,
as it does when the values are 0.5

But in your PG, box1 cannot be moved down on top of box2 like you can when the values are 0.5

##### Share on other sites

Nicely drawn
Based on the above discussion the offset is the distance of  ellipsoid top from  mesh center
So

##### Share on other sites

Ahh i missed that,

Okay, that makes sense

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.