Me again people.
@trevordev, yes I looked at the code @nogalo and I was impressed I do not know much about the javascript, but I thought to do this to create a joystick with the BABYLON.GUI.AdvancedDynamicTexture itself.
I spent a few hours and could use an external plugin called> nipplejs!
demo link -> Nipplejs by yoannmoinet
has its own system of listening and events, I have not yet mastered, but I can make it work! xD
Here’s what I did>
game_base.html: </ script>
So in my main.js I put these two variables.
var options = {
zone: document.getElementById ('zone_joystick'),
White color
size: 120,
threshold: 0.1,
fadeTime: 250,
multitouch: false,
maxNumberOfNipples: 1,
dataOnly: false,
position: {top: '500px', left: '120px'},
mode: 'static'
restJoystick: true
restOpacity: 0.5,
lockX: false,
lockY: false,
catchDistance: 200
};
var manager = nipplejs.create (options);
-----------------------------------------
so in the scene.onBeforeRenderObservable, I put this>
manager.on ('end', function (evt) {
manager [0] .frontPosition.y = 0;
manager [0] .frontPosition.x = 0;
})
if (manager.on ('move, end', function (evt, data) {
if (manager [0] .frontPosition.y == 0) {
manager [0] .frontPosition.y = 0;
manager [0] .frontPosition.x = 0;
};
})) {
browser.position.z- = manager [0] .frontPosition.y * (engine.getDeltaTime () / 1000) * movepeed;
browser.position.x + = manager [0] .frontPosition.x * (engine.getDeltaTime () / 1000) * movepeed;
}
I know this is awful I use the playground but not everything works there and I tested on the smartphone and other browsers the game I’m doing - I’m seriously studying 5 days of javascript -
Sorry if the code is crazy.
@trevordev I think you should do what I said do not know if it is one of the developers of Babylonjs more is the best webgl engine and searched the internet everyone believes! and babylonjs stands out for being simple and easy to use seeing me with 5 days I’m doing a game of rts. Babylonjs also helps me with javascript.
and @nogalo I’m going to spend some time dating your code.
I believe that with the @nogalo code everything is solved. hope @trevordev, bring something based on it. Thank you:slightly_smiling_face: