论坛

由用户创建的信息 mveny
26 October 2016 07:34
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!
26 October 2016 07:21
After 2 jumps don't allow any more force to be applied in the Z direction until a collision with the ground occurs, the reset the jump counter ;).

Still no luck with the material special collision but using just the collision ID on the physics panel worked so I got my double jump.

Another problem showed up, if I enable the 'Character' checkbox on the physics panel the regular collision stops working again.
26 October 2016 02:53
If I enable the 'Stone' object in Blender as a character the collision sensor stops working?
26 October 2016 00:20
So after more testing It doesn't appear that the Material Special Collision Works No matter what I try? How does this work, what settings should be enabled and how, does anyone have an example of how you would use multiple materials as well as how the collision layers work?


In case someone else is looking for just a basic working collision example the code below works with the attached collisionTest.blend file
The only thing you need to get basic collision working is a Collision ID in the Physics panel.
No Actor, No Ghost, No Collision Bounds. I set the controls to CT_TRIGGER so the collision would fire every time it makes contact. I wouldn't mind seeing some kind of examples for each case, the purpose for actor, ghost collision bounds if someone knows how they work and when you use them.

// get the object being thrown
var stone = m_scenes.get_object_by_name("Stone");

// create the sensors
var sensor_impact_terrain = m_controls.create_collision_sensor(stone, "TERRAIN");
var sensor_impact_wall    = m_controls.create_collision_sensor(stone, "WALL");

// array of the sensors
var impact_sens_array = [sensor_impact_terrain, sensor_impact_wall];

// manifold logic function
var impact_sens_logic = function(s) {return (s[0] || s[1]);}

// callback
var impact_cb = function(obj, manifold_id, pulse) {

    // NOTE: it's possible to play both sounds simultaneously

    if (m_controls.get_sensor_value(obj, manifold_id, 0) == 1) {
        // ...
        console.log("play the terrain impact sound");
    }

    if (m_controls.get_sensor_value(obj, manifold_id, 1) == 1) {
        // ...
        console.log("play the wall impact sound");
    }
}

// create the manifold
m_controls.create_sensor_manifold(stone, "IMPACT", m_controls.CT_TRIGGER,
    impact_sens_array, impact_sens_logic, impact_cb);

}
25 October 2016 21:09
I'm looking at this article trying to see if I can sort out the manual example
https://www.blend4web.com/en/community/article/66/
I've tried some variations of the settings in this article to try and get manual example working, so far no luck.

I can't find anything that explains what this function does?
m_phy.enable_simulation(obj);
25 October 2016 19:46
Hey Luke, thanks for the additional info!

I found a simple way to get double jump. Use physics velocity instead of character controls for jump!
Once the spacebar is hit twice don't allow any more jumps until the character collides with the ground and reset the counter.

So the code for the sensors I get pretty well now after playing around with them unfortunately.. the documentation on how to set up the .blend file with physics and the collisions is lacking. Maybe I did something silly but can't get the example to work.

I made a new post about collision detection & sensors
https://www.blend4web.com/en/forums/forum/16/

almost there! ;)

thanks again
25 October 2016 19:37
Hello All!

Is there a link to more details on collisions sensors and how they should be used, how they work somewhere? There are many scenarios for how this feature could be used and very short on docs. When to use materials with special collision properties, when to use Physics Collision ID, when and why to use collision bounds or not, how should the margin be set on collision bounds and why.. so many questions..

My particular situation is, I'm trying to reset some variables when a character collides with the ground.. but like the attached and example from manual, I can't get the sensor to fire on collision.

here are some more details, any help would be much appreciated!!
I'm trying to figure out how collision detection works. I'm using the example from APP developer section of API. https://www.blend4web.com/doc/en/developers.html#event-driven-model

Attached a simple project to test out the example in documentation.. doesn't work?

I found a type-o in the documentation .. m_ctl in the following line should be m_controls.
// create the manifold
m_controls.create_sensor_manifold(stone, "IMPACT", m_ctl.CT_SHOT,
impact_sens_array, impact_sens_logic, impact_cb);
22 October 2016 06:43
Thanks Luke, good idea I'll try it out!
21 October 2016 03:38
Hi Evgeny!

Yes what you described is what I was looking for.. and your solution of dividing the terrain into tiles is what I'm doing now.

Thought I would check to see if I was missing something or if there were any plans to implement something like this in the future in B4W.

Does B4W have a roadmap for software development that is publicly available?

Thanks!
Mike
19 October 2016 03:03
Hello B4W team!

Do you have any suggestions for programming a 'double jump'.

If I hit space again while the character is in a current Jump I want him to jump again in the air.

I'm using this sensor and function:

var jump_cb = function(_character, id, pulse) {
m_phy.character_jump(_character);
}
m_ctl.create_sensor_manifold(_character, "JUMP", m_ctl.CT_SHOT, [key_space], null, jump_cb);