Forum

Some physics in a first-person view

13 January 2016 12:45
Hi,
How center mouse in the center of window when are captioned? thx.
Could you please provide some details on what you're trying to achieve? Maybe some links or videos? Thanks.
The Founder | Twitter
14 January 2016 18:29
Ответ на сообщение пользователя Yuri Kovelenov
Hi,
Could you please provide some details on what you're trying to achieve? Maybe some links or videos? Thanks.

I'm creating a scene first person test. And to interact with objects.
The problem is that when I want to interact with them is difficult, if the mouse was hidden without being in the center of the screen. Also when I do not click on the canvas first, the "W", "A", "S", "D" keys, move in reverse direction.

My code: http://pastebin.com/1tXVSrrN
Blender 2.76b
Blend4web 15,12,0

Thanks.
15 January 2016 17:00
Ответ на сообщение пользователя pakirrote
I'm creating a scene first person test. And to interact with objects.
The problem is that when I want to interact with them is difficult, if the mouse was hidden without being in the center of the screen. Also when I do not click on the canvas first, the "W", "A", "S", "D" keys, move in reverse direction.

My code: http://pastebin.com/1tXVSrrN
Blender 2.76b
Blend4web 15,12,0

Thanks.
There is no code which deals with character->objects interaction under your link, so If I understood you correctly, you want to use mouse position to check if there are some interactive objects on the screen. Actually, there are better/easier solutions exist.

First - you can just use the center of the screen to check for objects. The center is canvas width/2; canvas height/2. Then x,y can be used in the https://www.blend4web.com/api_doc/module-scenes.html#.pick_object function like this:
var canvas = m_container.get_canvas();
var x = canvas.width;
var y = canvas.height;
var obj = m_scenes.pick_object(x, y);

But this solution is not the fastest one.

The best approach is to use physical "picker" which must be parented to the camera and to register if it is in collision with some required object.
Blend4Web developer
19 January 2016 15:49

Ответ на сообщение пользователя Evgeny Rodygin
There is no code which deals with character->objects interaction under your link, so If I understood you correctly, you want to use mouse position to check if there are some interactive objects on the screen. Actually, there are better/easier solutions exist.

First - you can just use the center of the screen to check for objects. The center is canvas width/2; canvas height/2. Then x,y can be used in the https://www.blend4web.com/api_doc/module-scenes.html#.pick_object function like this:
var canvas = m_container.get_canvas();
var x = canvas.width;
var y = canvas.height;
var obj = m_scenes.pick_object(x, y);


But this solution is not the fastest one.

The best approach is to use physical "picker" which must be parented to the camera and to register if it is in collision with some required object.

Thanks!! :)
19 January 2016 23:25
And if to simulate the movement of the camera up and down a little when walking? To simulate head movements to take steps. Thank you.
21 January 2016 18:52
And if to simulate the movement of the camera up and down a little when walking? To simulate head movements to take steps.
This can be simulated by using the translate _view function.
Blend4Web Team
11 November 2016 00:47
I put in the code but it won't run I get this:

[Error] ReferenceError: Can't find variable: m_ctl
Global Code (firstperson.html:31)
[Error] ReferenceError: Can't find variable: m_scs
load_cb (firstperson.html:17)
c (b4w.min.js:2505:403)


Here is my full code (copy pasted from the article):
http://pasteall.org/108088
 
Please register or log in to leave a reply.