Physics Engine question

good find :slight_smile: looks promising, if someone has a decent repro I can try to add a fix using that method.

You can simulate falling manually, but you still need some kind collision checking. Four your style of game, you could have a metadata object for every platform, that stores at which angle is a hole. Based on that you can do a very simple custom collision checking without a big physics engine.

@trevordev I try to provide one tomorrow.

1 Like

Can you show some examples?

I’d try something like his for the metadata:

platforms: [
   {id: "whatever", mesh: plaformMesh, holes: [{from: 0, from: Math.PI/4}]}
   {id: "whatever2", mesh: plaformMesh2, holes: [{from: 0, size: Math.PI/4},{from: Math.PI, size: Math.PI/4}]}
] 

With that metadata you coud even genereate the platforms by code.
Use somehing like his for gravity: software engineering - How can I implement gravity? - Game Development Stack Exchange

And with the metadata + the roation of your platforms you can check whether the ball is on a platform or a hole. I would however only use his if he holes are of fixed size. Otherwise his approach gets complicated fast.

If you want it easy, you need to be patient, till this bug is fixed.

Here a set of playgrounds @trevordev

With restitution set to one and colliding the mid of the ground, everything is fine, I got 1 even.
https://playground.babylonjs.com/#RG2AQ4#2
The edge case with restitution set to 1, this produces 4 events for me, but should only give 1:
https://playground.babylonjs.com/#RG2AQ4#5

@Asagi 's case: Produces always 2 events for me, should be 1
https://playground.babylonjs.com/#RG2AQ4#3
Asagis Edge case: Produces 2-5 events for me, should be only 1, too
https://playground.babylonjs.com/#RG2AQ4#4

1 Like

May be problem with mesh? For ex. platforms?

I don’t know, but you could upload a platform mesh then we can take a quick look at it.

One platform for example.
http://www.mediafire.com/file/x4152q3cb0vzntv/p1.babylon/file

This smoothed out edge could be a problem. Making that a regular sharp edge might be a temporary solution until the bug is fixed.

edge

Hm. Thanks, i rebuild meshes. But what about double event when ball hit? This is no problem with mesh platform?

Yea this seems to be a bug. I also can’t guarantee that rebuilding the meshes will fix it, is just an idea.

Before you rebuild them, you might want to try commenting out your apply force and set restitution to 1 for the ball and the discs, like this:
https://playground.babylonjs.com/#RG2AQ4#2

Can i do next?
Manualy move sphere and check collision with platform mesh? Platform and voids in it?

So far when i’m investigating I’ve found the the double event isn’t even on the same simulation frame, even when checking the manifolds like you shared, the same issue is occurring. For some reason the sphere enters the object and bounces up but doesnt get fully out of the object. Right now i’m investigating if the calls to stepSimulation might be causing this.

1 Like

If this should be a problem of ammo/bullet couldn’t we ā€˜debounce’ that ourselves?
Thus sending the first event to the listener and only raise another event once the object was not in a collision for at least one frame, which is the case if it is not in the manifolds anymore.

EDIT: This would also solve the problem of this case: https://playground.babylonjs.com/#RG2AQ4#5

For performance reasons we could only debounce the cases that have listeners attached, so it should not be a huge performance impact.

Some video fragment.
As you can see all very bad.
http://www.mediafire.com/file/muy0camuf210x8s/screen-capture_%282%29.zip/file

image



Some details…

That looks bad. Maybe you should indeed write that physics part yourself. I currently have no time to explain that in much detail. You would have to do your own research with the snippets I already provided you.

As soon as I am done with my own current project I can do an extensive tutorial on that topic.

Can i correct detect holes in meshes manualy? Without physic engine? Any keys?
Or may be exist easy way to create normal collision box?

Here I already wrote something regarding that: