Forum

Rotate Object Using m_phy

26 October 2016 07:34 #13093
Hello again B4W!

With the 'Character' box checked in the physics panel I can use this to rotate my character:
character_rotation_inc(obj, h_angle, v_angle)
But I'm not using Character in physics panel.

How do I rotate my _character object on the Z axis if I'm not using B4W out of box API controls?

Plz help!

thanks!
27 October 2016 03:12 #13112
I thought I found what I was looking for here:
https://www.blend4web.com/en/forums/topic/1052/

var cube = m_scenes.get_object_by_name("Cube");
m_transform.rotate_y_local(cube, angle);

var trans = m_transform.get_translation(cube);

m_transform.set_translation(cube, trans)

I think this function needs to be extended to the API?
m_trans.update_transform(cube);

m_physics.sync_transform(cube);

I've tried all different methods of transforms and the m_physics.sync_tranform(obj) does not work?

Evgeny Rodygin please help!! ;)
27 October 2016 12:36 #13117
Hi, Mike!

The help is not that swift as we are a bit busy with the release at the moment.
Using the transform module with Rigid Body or Dynamic objects generally gives no result. That's because physics engine tries to overwrite positions and rotations at the same moment.
I would recommend using the physics.set_transform method.

This behavior may be simplified in the future but currently that's how things work.

On the other hand, If you use STATIC physics, the transform module should satisfy your requirements.
Blend4Web developer
27 October 2016 17:54 #13126
Thanks for the reply , I know you guys are busy ! :) your great support is always appreciated regardless of how long it takes.

So the real problem is that there is no way to rotate an object using physics. Torque doesn't do anything, at least not for my scenario.

I've tried the physics.set_transform method as you suggested (it's the only option) and it does what I want physically however it's not useable.

Since the method requires both a transform and a quat rotation when I use this method to update my rotation it causes terrible jittering.
set_transform(obj, trans, quat)

It seems that by the time the set.transform method is activated the location the trans is outdated.
maybe I've tried to many different ways to get it working and now I'm just making a mistake.

I can send you an example file direct but I'd rather not post in the forum. Once I figure it out (hopefully with your help when you have time) I can post the results in the forum in case anyone else is having the same problem.) I really dislike dead end forum posts ;).

thanks!!! and thanks for the hard work on B4W, it's great!
02 November 2016 20:59 #13285
for my case, stick with
m_phy.character_rotation_inc(obj, h_angle, v_angle)
to rotate character.

I read that there may be physics movement added to the logic node system, that may help this situation in the future.
02 November 2016 21:19 #13287
I read that there may be physics movement added to the logic node system, that may help this situation in the future.
At Blender Conference many guys were excited about the Logic node system and we received many request for improvements. Physical objects controls are among them. So yeah, we gonna add this possibility in one of the upcoming releases.
Blend4Web developer
07 November 2016 20:41 #13520
Hi Evgeny,

I've run into this issue on a couple of occasions:
this was the other attempt
https://www.blend4web.com/en/forums/topic/2293/

When controlling a Player / Character but not using the 'Character' checkbox on the physics panel there is no way to rotate the character.

would it not be as simple as allowing
m_phy.character_rotation_inc(obj, h_angle, v_angle) to work even if the 'Character' checkbox is off?

when 'Character' box is checked the ability to modify physics.gravity(X) is also removed.

I'm really just asking for an update, do you have an idea of when this ability may be added in a future release?

thanks!
10 November 2016 17:29 #13714
Found the way to simulate gravity when in 'character mode'
apply_force_world(obj, fx_world, fy_world, fz_world). Set fz_world to gravity strength.

Similar to the set.gravity(obj) function, this can be applied to individual characters.

Also, since the set_transform(obj, trans, quat) and sync_transform(obj) in the physics module don't work when you are using B4W 'character' mode, if you want to use the translation module on your object you can disable physics simulate make the translation and then re-enable physics.
disable_simulation(obj)
enable_simulation(obj)

It's interesting:
has_physics(obj) → {Boolean}
has_simulated_physics(obj) → {Boolean}
even though both these checks return true, the 'character' setting bypasses physics.

Hopefully this info will help others that run in to the problem.
 
Please register or log in to leave a reply.