Jump to content

3rd person movement, how to?


Recommended Posts



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?



I think I found a solution:


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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...