Forum

Static to dynamic?

22 May 2018 19:44
Hello,
I would like to change an object physic's from static to dynamic. It's on static so I can make it move with the nodes (transform object). And then I would like it to go to dynamic so the object cube (and camera parented to it) can fall. Plus the scene is meant to be seen from a head mounted display (the spectator is passive).
To do that I copied the VR scene available in Blend4Web (with the cubes and the funky carpet).

To add the fall, I tried to set gravity to the static object (in the js script, and calling the function with a js callback), but it doesn' work.

Furthermore, there seems to be a problem with the physics in the scene. I might have clicked on the wrong button in the properties tab, but when I put the cube physic's into rigid body, the cube falls even if there is a static plan under it (I also tried to put a second cube in static just underneath the rigib body cube, but it changes nothing).

I really don't get what's wrong with the environment…
25 May 2018 22:08
To add the fall, I tried to set gravity to the static object (in the js script, and calling the function with a js callback), but it doesn' work.
Well, like you said yourself, you have to set the Cube object to dynamic to make it fall, and the Plane which stops the fall to static. I didn't check the VR scene, but I set this up from the Default Startup Scene (Cube, Camera, Lamp) and it works.

Now, for "making the object dynamic", I don't think you can start the scene with a static physics object or non-physics object and then change it to dynamic physics or make it a physics object during runtime. However, you can start the scene with a dynamic physics object and then disable its physics with m_physics.disable_simulation(object).

So, my solution was to set the Cube Object to Dynamic Physics, the plane to Static Physics, then disable the physics for the Cube right at the start with a JS Callback (so you can move it), move it with a Transform Object or MoveTo Node to the fall position, and then re-enable its physics with another JS Callback (m_physics.enable_simulation(object)). I tested it and this actually works.
 
Please register or log in to leave a reply.