jorgenoro Posted September 12, 2015 Share Posted September 12, 2015 Hello, I'm trying to make this super simple demo, in wich I have a charecter and want to control it in 3rd person view.The first thing that came to my mind was this:if (up_arrow) position.z += some_valueif (left_arrow) position.x += some_value(...)Of course, this doesn't work as I want. I need to turn to left and right, and only move in the Z+ of my character.This is my problem. How do I move in the direction it's facing? EDIT:I think I found a solution:http://babylon.azurewebsites.net/This is the "Car game" from the Babylon website.I look through the code, by i'm not grasping the idea...Any help would be thankful Thanks a lot! Quote Link to comment Share on other sites More sharing options...
Temechon Posted September 12, 2015 Share Posted September 12, 2015 Hello, Did you check my tutorial here: http://pixelcodr.com/tutos/plane/plane.html This may answer to your question Quote Link to comment Share on other sites More sharing options...
jorgenoro Posted September 12, 2015 Author Share Posted September 12, 2015 Thank you for your answer, I even played the game for quite a bit I played a similar game on my Android phone Well, my objective is not that. In your example, the ship goes always in the world z+ during the game.what I want is the movement like Grand Theft Auto (the only that comes to my mind right now). Anyway, I'm giving a look at your other tutorials Thanks again! Quote Link to comment Share on other sites More sharing options...
JohnK Posted September 13, 2015 Share Posted September 13, 2015 Not sure if this approaches what you want or not but you could have a look at http://www.babylonjs...nd.com/#AGEQ3#4 Control instruction can be found here . NOTE Num Lock needs to be ON jerome 1 Quote Link to comment Share on other sites More sharing options...
jorgenoro Posted September 14, 2015 Author Share Posted September 14, 2015 Hi all, thank you for your replies.I managed do to what I was looking for. In the player update function I have this (pseudo, because my code is a little messed up now):player.update = function(){ if(game.keyboard.A) { player.mesh.rotation.y -= 0.05; } if(game.keyboard.W) { player.isAccelerating = true; player.speed += 0.1; } else { game.player.isAccelerating = false; } if(game.keyboard.D) { player.mesh.rotation.y += 0.05; } player.mesh.position.z -= Math.cos(player.mesh.rotation.y) * player.speed; player.mesh.position.x -= Math.sin(player.mesh.rotation.y) * player.speed; cameraPosition.x = player.mesh.position.x; cameraPosition.z = player.mesh.position.z;}I achieved it looking through the code of that Car Game example. webdva 1 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.