Lightnet Posted November 29, 2016 Share Posted November 29, 2016 Trying to create a third person camera. Where the character move in right direct when facing the pointer to move while you rotation the camera around. Need some help how to move the character/pointer where it pointing. A,S,D,W = character movement. Mouse orbit the character. Here a simple demo. http://www.babylonjs-playground.com/#1RHSYU#0 Been trying to figure thing out which hard to do. Trying to work toward game pad joy stick movement. Any Idea? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 29, 2016 Share Posted November 29, 2016 Here we are: http://www.babylonjs-playground.com/#1RHSYU#1 Quote Link to comment Share on other sites More sharing options...
Lightnet Posted November 29, 2016 Author Share Posted November 29, 2016 Oh that work but I wanted the camera to follow the camera and it acting odd. --update- Here the update the version but I need the joy stick. That can go 360 direction. http://www.babylonjs-playground.com/#1RHSYU#2 //this breaks move in different direction when reach out side of the center bounder of the plane //var forward = camera.getFrontPosition(1).subtract(camera.position).normalize(); //does not work bug //this works var target = model.position.clone(); var forward = target.subtract(camera.position).normalize(); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 29, 2016 Share Posted November 29, 2016 I'll fix the getFrontPosition issue Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 29, 2016 Share Posted November 29, 2016 Done PG is updated Quote Link to comment Share on other sites More sharing options...
Lightnet Posted November 29, 2016 Author Share Posted November 29, 2016 Oh cool. Manage to get the gamepad left joystick to move the pointer around but felt that left and right x axis is not really going right direction as angle little off. But not sure how to deal with the input conflict with orbit controls. Since gamepad left stick y axis does zoom in and out. Here the working example. http://www.babylonjs-playground.com/#1BA9FJ#1 Converting angle I have trouble. I wonder if the coding is right since I need to making sure it right way to code. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 29, 2016 Share Posted November 29, 2016 Here is how camera input works:http://doc.babylonjs.com/tutorials/Customizing_Camera_Inputs You can simply desactivate keyboard or gamepad input from your camera Quote Link to comment Share on other sites More sharing options...
hydrix Posted December 20, 2016 Share Posted December 20, 2016 nice script lightnet, thanks. A word of advice- avoid declaring new variables in update structures, because those variables are just getting thrown away after the loop and have to be handled by the browser's garbage collector. At 60 fps with like 10 variables that's 3000 collected every 5 seconds. It causes framerate spikes Wingnut and BeanstalkBlue 2 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 20, 2016 Share Posted December 20, 2016 why don't you reserve the memory space and just reassign it instead of dumping it and recreating it? Quote Link to comment Share on other sites More sharing options...
tebell Posted January 20, 2018 Share Posted January 20, 2018 My way of achieving this was to rely on BabylonJS to do the calculations for me. I first get the forward direction ray position of the camera, and then create a version of that without the Y value ('camera' is an instance of BABYLON.ArcRotateCamera) : var cameraForwardRayPosition = camera.getForwardRay().direction; var cameraForwardRayPositionWithoutY = new BABYLON.Vector3(cameraForwardRayPosition.x, 0, cameraForwardRayPosition.z); I then apply that to the mesh itself by adding the new camera ray direction data to the current mesh position, and then using 'lookAt' to face in that direction ('model' is an instance of BABYLON.Mesh): model.lookAt(model.position.add(cameraForwardRayPositionWithoutY), 0, 0, 0); See the playground example below (I changed the controls a bit to use A and D for 'strafing'): http://www.babylonjs-playground.com/#0D883E Wingnut and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 20, 2018 Share Posted January 20, 2018 Welcome to the forum, tebell. Helping others with your very first post? Too cool! (Wingnut shakes your hand enthusiastically.) tebell and pichou 2 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.