Gravity toggle on and off

25 November 2015 07:04 #5278
Hi all. How do you change the gravity for the world or the object to zero? It seems there isn't an option for this. Please help as I'm trying to make a 3D fish swim in the sea.
26 November 2015 10:56 #5344
Good day.
If you don't need your object to collide with anything, you can just leave physics for it turned off.
Blend4Web team - Editor
26 November 2015 12:38 #5351
Hi, thanks for replying.
I do need to check for collision later on. Is there any other way to turn off the gravity and have physics for the fish?
26 November 2015 16:10 #5364

Try to use static physics type. Not Rigid Body. It will provide and detect collisions. If you want only detect collisions, you should enable the "Ghost" object physical property.

And don't forget, that if the object uses physics you should use the "physics" methods to translate and rotate object.
Blend4Web developer
27 November 2015 06:04 #5377
Hi, thanks for replying.
If the object is static, how do you move it from point A to point B? How do I go about using the "physics" methods to move the object?
27 November 2015 10:25 #5383

You can use the following method: set_transform

I forgot to mention one important aspect. As this object is static it will only move its physical entity and won't affect rendering. Thus, we need to move it on the rendering side as well.

m_phy.set_transform(object, trans, quat);
m_transform.set_translation(object, trans)
Blend4Web developer
27 November 2015 12:11 #5387
And here is the example. I've combined this lesson and this example.
Blend4Web developer
30 November 2015 06:14 #5432
Thank you all. Case closed.
Please register or log in to leave a reply.