Jump to content

moveWithCollisions issue


satguru
 Share

Recommended Posts

see 

https://www.babylonjs-playground.com/indexstable#97B3B7#12

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  !!

 

Link to comment
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.
But what about box2?
It is NOT being moved by moveWithCollision?
Does the collider system uses its ellipsoid too or does it use its bounding box as impostor?

 

 

 


 

 

 

Link to comment
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)

 

Link to comment
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?

 

 

Link to comment
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?

 

IMG_20171107_200240.thumb.jpg.d4bf24b3f93b17d7939b562c9206bdd6.jpg

Link to comment
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:

image.thumb.png.76bca51cf2e8d4038e3e30a158a66418.png

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

Link to comment
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

 image.png.34cdb51be01350351e695ba336455e08.png

The top of the ellipsoid at the center of mesh?

And thanks for indulging all my questions.

 

Link to comment
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 :P 
Link to comment
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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...