Forum

Camera /character width

12 January 2016 06:19 #6463
I have created a first person type of scene where the character (long UV sphere) moves forward and a door is opened by clicking on it. The door width is significantly wide (about 4 times wider than the character and about twice the height); however the character/camera won't pass through. If I make the opening what I would call extreme, it will pass through the space, but this is not realistic. Is there some setting on the character or camera or in the .js code that should be changed to reduce it in size and allow it to pass through? I used the settings that were described in the First Person tutorial

Also, is there any way to associate sound with the physics. I have a beer can falling off a desk, but it makes no sound. Is there a way to have it make a sound when it impacts the floor?

Thanks,
Cluetrekk

12 January 2016 18:26 #6500
Hi,
The door width is significantly wide (about 4 times wider than the character and about twice the height); however the character/camera won't pass through.
Please make sure that you used a physics material instead of a physics primitive for your wall model. More info here.
Development Lead | Twitter
12 January 2016 18:37 #6501
Also, is there any way to associate sound with the physics. I have a beer can falling off a desk, but it makes no sound. Is there a way to have it make a sound when it impacts the floor?

Please take a look at this code snippet:

    
    var m_ctl = require("controls");
    var m_scs = require("scenes");
    var m_sfx = require("sfx");

    var speaker = m_scs.get_object_by_name("YOUR_SPEAKER_OBJECT_NAME");
    var beer_can = m_scs.get_object_by_name("YOUR_BEER_CAN_OBJECT_NAME");
    var sensor = m_ctl.create_collision_sensor(beer_can, "YOUR_MATERIAL_COLLISION_ID", false);  

    var callback = function(obj, id, pulse, param) {
        m_sfx.play_def(param);
    }
    m_ctl.create_sensor_manifold(null, "SOME_UNIQUE_ID", m_ctl.CT_SHOT,
            [sensor], null, callback, speaker);


Every time some physics object touches you physics material there will be sound playback.

Hope this helps!
Development Lead | Twitter
13 January 2016 06:32 #6509
Thanks for the help; however, I did not have much success with this.
With regards to the door opening issue, it made sure the material was set to Special: Collision but the problem persisted. I did some testing by moving the room forward and left the door behind and I was able to go through the opening. It seems that once the door moves, it seems to leave behind a 'ghost' of itself which continues to block the opening. I have attached the blend file.

Regarding the beer can dropping, I have placed the code in the .js file and ensured the objects were named appropriately. I left the sensor manifold ID as "SOME_UNIQUE_ID", assuming that it was not important what it was called. However, I still did not hear any sound when the can falls. I noticed that the var_sensor is set to 'false', is this correct? (The beer can is the one that rolls off the right side of the table when the scene opens)

Your help on this matter is much appreciated.
Thanks again,

Cluetrekk
13 January 2016 13:06 #6528
Hi!
With regards to the door opening issue, it made sure the material was set to Special: Collision but the problem persisted. I did some testing by moving the room forward and left the door behind and I was able to go through the opening. It seems that once the door moves, it seems to leave behind a 'ghost' of itself which continues to block the opening. I have attached the blend file.
Currently, moving objects with static mesh physics is not possible. We need to clarify this moment in the docs. In order for your example to work you need to enable Object Physics flag in object's physics settings instead of Special: Collision on its material. And it is better to apply scale for the door object (Ctr+A -> Scale).

Regarding the beer can dropping, I have placed the code in the .js file and ensured the objects were named appropriately. I left the sensor manifold ID as "SOME_UNIQUE_ID", assuming that it was not important what it was called. )
ID here is an important param. You have assigned "ROOM" id to the Floor material. This id should be placed instead of "SOME_UNIQUE_ID".

However, I still did not hear any sound when the can falls. I noticed that the var_sensor is set to 'false', is this correct? (The beer can is the one that rolls off the right side of the table when the scene opens)
You can always check what function parameters mean in our API doc. In our case the function create_collision_sensor uses the last param to check if it should calculate position and normal of the collision point.
Blend4Web developer
14 January 2016 03:31 #6544
Thanks Evengy.
I changed the door physics to allow object physics with a static physics type but left the special collisions on the material as that was needed for other parts of the scene. This worked like a charm and the door opens and I can pass through easily .

The sound is still not occurring when the can drops. The name of the can is "Beer_Can", the name of the speaker is "Can_Fall_Speak" and the material ID for the floor is "ROOM" and the ID for the can is "CAN". The following code was inserted into the .js file.
Any further ideas?
    var m_ctl = require("controls");
    var m_scs = require("scenes");
    var m_sfx = require("sfx");

    var speaker = m_scs.get_object_by_name("Can_Fall_Speak");
    var beer_can = m_scs.get_object_by_name("Beer_Can");
    var sensor = m_ctl.create_collision_sensor(beer_can, "CAN", false);  

    var callback = function(obj, id, pulse, param) {
        m_sfx.play_def(param);
    }
    m_ctl.create_sensor_manifold(null, "ROOM", m_ctl.CT_SHOT,
            [sensor], null, callback, speaker);

14 January 2016 19:28 #6570
Hi, you may want to place some console.log() inside the callback function and check the browser console output. If it works, then it's something with the sound. If console.log does not print anything then it the physics which is not working properly.
Blend4Web Team
https://twitter.com/AlexKowel
15 January 2016 04:15 #6578
Hmmm…still no success.
I've created a simple scene to test it in another environment and it was not successful. I put the console() log in the .js file (assuming it is in the correct location (I'm new to this coding thing)). I've attached the simple blend file and the corresponding .js file in case you (someone) has a minute to look it over.
Thanks,
Cluetrekk
15 January 2016 10:30 #6581
Hello!
It should be "GROUND" id here:
var sensor = m_ctl.create_collision_sensor(beer_can, "GROUND", false);

ID is the one with which the collision occures.
Blend4Web developer
16 January 2016 19:56 #6615
Thanks, but unfortunately it is still not working. Would there be an issue trying to hear it in the Fast Preview?
 
Please register or log in to leave a reply.