Forum

[SOLVED] Can invert drag motion in mobile fps?

29 June 2017 12:52
Hi guys!.
I can invert the drag movement in mobile fps ?

for example:
m_fps.enable_fps_controls(character, mobileInvert);


Thanks.
29 June 2017 13:08
Solved with my little hack:

In the fps module:
var move_sensor_cb = function(obj, id, pulse) {
if (pulse == 1) {
var payload = m_ctl.get_sensor_payload(obj, id, 0);
var coords = payload.coords;
if (m_main.detect_mobile()){
_move_delta[0] -= (coords[0] - move_x) * drag_mult;
_move_delta[1] -= (coords[1] - move_y) * drag_mult;
} else {
_move_delta[0] += (coords[0] - move_x) * drag_mult;
_move_delta[1] += (coords[1] - move_y) * drag_mult;
}

move_x = coords[0];
move_y = coords[1];
}
}
03 July 2017 16:35
if (m_main.detect_mobile()){
        _move_delta[0] -= (coords[0] - move_x) * drag_mult;
        _move_delta[1] -= (coords[1] - move_y) * drag_mult;
    } else {
        _move_delta[0] += (coords[0] - move_x) * drag_mult;
        _move_delta[1] += (coords[1] - move_y) * drag_mult;
    }


I think it is a good solution. Also you can freely copy/paste code from modules in the "addons" directory to your application code.
Blend4Web Team
kirill@blend4web.com
05 July 2017 15:41
Reply to post of user Kirill Osipov
Also you can freely copy/paste code from modules in the "addons" directory to your application code.

Any tutorial for this?, thanks.
06 July 2017 17:09
Hi,

There is no particular tutorial unfortunately, but the code of addons (such as of the fps.js addon) is implemented external in regards to the core engine API. So you can freely copy/override any methods offered by them.
The Founder | Twitter | Facebook | Linkedin
06 October 2017 13:14
Reply to post of user Kirill Osipov
Also you can freely copy/paste code from modules in the "addons" directory to your application code.

Can someone explain to me how this is done?, Please.
Thank you!.
 
Please register or log in to leave a reply.