drunkly Posted February 23, 2016 Share Posted February 23, 2016 Hi Everyone. I'm developing a game and I'm having problems with the controlss. I would like to do the same behaviour as VirtualJoystickCamera but including a mesh player. To do that, I add a virtual left joystick and check if the button is pressed to move the player (the camera follow always the player). However when I add the right virtual joystick I'm not able to rotate the camera or I'm not able to bind this joystick to the current camera. Anyone had this problem and could solve it? Do you know where to found the source code for the VJC?. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
drunkly Posted February 25, 2016 Author Share Posted February 25, 2016 //create joysticks leftJ = new BABYLON.VirtualJoystick(true); leftJ.setJoystickColor('red'); rightJ = new BABYLON.VirtualJoystick(false); rightJ.setJoystickColor('lime'); //on the loop engine.runRenderLoop(function() { scene.render(); if (scene.isReady() && meshPlayer) { if (leftJ.pressed) { if (leftJ.deltaPosition.y > 0) { keys.up= 1; keys.down= 0; } else if (leftJ.deltaPosition.y < 0) { keys.up= 1; keys.down= 0; } else { keys.up= 0; keys.down= 0; } if (leftJ.deltaPosition.x > 0) { keys.left = 1; } else if (leftJ.deltaPosition.x < 0) { keys.right = 1; } else { keys.left = 0; keys.right = 0; } } else { keys.up= 0; keys.down= 0; keys.left = 0; keys.right = 0; PlayAnnimation = false; scene.stopAnimation(skeletonsPlayer[0]); } //ROTATE CAMERA. -10000 is the rotation speed (negative to reverse direction) if (rightJ.pressed) { cameraArcRotative[0].alpha += rightJ._deltaJoystickVector.x/-10000; cameraArcRotative[0].beta += rightJ._deltaJoystickVector.y/-10000; } } }); If someone has also problems with this issue the trick is update the alpha and beta parameters for the arcrotatecamera Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.