Enabling physics seems to disable all of my actionmanager events

Hey everyone I’m new to babylon, this is my first post.

I’m considering building a board game engine within Babylon, similar to Table Top Simulator, but I’m running into some beginner problems:


I successfully implemented action managers, which i’m using to lift a checker off the board as its being dragged. Before this, I tried using events connected directly to the drag behavior, but the onDragObservable event only fires as the piece is being moved, resulting in a jerky motion where the piece jumps back to the board when the mouse is not moving. Using the onPickDownTrigger and onPickUpTrigger with actionmanager resolved this.

The problem is that I also would like to have a physics engine running, and that was made simple enough by Babylon. However, when I enable the physics engine, I seem to lose all behaviors connected to actionmanagers. You can enable physics in my playground example by uncommenting line 9 to observe this behavior.

At first I thought that it was related to the gravity being enabled and somehow counteracting the checker’s upward movement off the table, but eventually I tried setting the scene gravity to zero and I still had the same results. Regardless of gravity, and regardless of which physics engine i use, the actionmanager events dont seem to work anymore, regardless of which events I use.

The end goal is to have collision and gravity enabled, and also have dragging enabled, while maintaining control of the elevation of my checker off of the board. For example, when i drag my checker off the board now with physics enabled, I cannot prevent it from falling to the floor by forcing a change to its position.y value, even while i am still dragging the checker.

Any help would be appreaciated, and I just want to say that so far I’m realy enjoying babylon. I think I made the right decision, and I hope someone can help me to get actionmanager events working alongside physics. Thanks!

Hey and welcome
let me introduce you to our physics grandmaster: @trevordev

Haven’t worked out how to send him a message. Any tips?

I was just kind of asking the community at large here.
Does anyone know why enabling a physics engine disables my action manager events?

I could be wrong but I’m not sure its really a question that requires a physics grandmaster, I’ve been working with babylon for less than a day.

Theres a playground link and everything @trevordev

Hey @FreeThought,

Yep, deltakosh was just pinging me in case no one else had input.

Unfortunately, dragging and interpolateValueAction were created without expecting physics to exist so you might need to get a bit creative to get this to work. I would recommend trying to disable physics while control of the mesh is occurring. Sleep and wakeup might work here, see this example https://www.babylonjs-playground.com/#8VV68R#2 .

Another idea would be since physics object with mass don’t expect their positions to change abruptly, you could try to implement your own dragging behavior and instead of instantly changing the position of the object, continuously apply a force to where you want the object to be.

Thank you :lollipop::snowflake::moyai:

I’ll work with your suggestions, and post back here if i manage any positive results in case anyone else is trying to do something similar.

1 Like