Unexped result when coliding physicaggregates

Hello guys.
After reading physics section at BBjs docs.
I decided to add a simple obstacle on my character path, as shown bellow:


Expected:
The obstacle will move on x axis and should be able to push the character out from the path if this stays in the obstacle way.
Result:
Character is not pushed on x axis , instead , both models overlaps.

Notes:
1 When trying to push the obstacle on z axis the collision is working ok and I can also jump and stay on the obstacle as well.

2 I added a little box to push and place in front of the mobile obstacle but I got same behaviour … The big obstacule does not push the little box.

3 Also tryed incrementing mass and friction to the ground and the box , but it seems to have not any effect … in fact the box moves very far when I apply mínimum contact.

4 After some googling , I founded this PG:
It uses the onBeforeAnimationsObservable function , instead of apply the animations on the model. I wanted to try similar aproach but I got the message:

Property 'deltax' does not exist on type 'PhysicsAggregate'.ts(2339)

Anyway , Im really exited about continue learning on this.
In case you want to try , please clone this repo and checkout to physics_obstacle1 branch.
Thanks for your words.

The error you are getting comes from typescript itself - the playground you are referring to defines a new variable on a js object that is, incidentally, a class of a specific type. Now, in JS this is perfectly fine. in typesciprt? big no no! :slight_smile:

What you can do is store all of those metadata variables in some form of a store that is available to other modules - I will let you decide on the architecture that fits better to your app - and use it just like in the PG.

Dear @RaananW , thanks again for your help.
I wanted to ask you some thing beyond the typescript issue.
Question is , why the big mobile box can not push the little box ?
As I mentioned , I already tryed playing with mass , friction and PhysicsMotionType as well.
Later I will try to move critical code to PG so you can check this easily.
Thanks.

Our physics expert @Cedric is currently away, so I hope my answer is 100% correct! :slight_smile:

Using animations the physics bodies don’t have any linear velocity, so they are static bodies and therefore don’t collide with the rest of the word when they move towards them. This is why, in the playground you shared, the bodies’ linear velocity is updated on each frame.

Hi @Leandro_Roggerone
It would make life easier if you could indeed replicate in a PG.
In the mean time, did you check this blog post? Maybe you can re-use some concepts Character Controller with Physics V2 | by Babylon.js | Medium

1 Like