Basic Thrid Person Character Controller

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
lesPaul456
Posts: 18
Joined: Sat Jan 02, 2010 4:48 pm

Basic Thrid Person Character Controller

Post by lesPaul456 »

Hello,

I'm starting on a new project and I'm hoping to get some advice. So far, I've created mainly first person shooters. This time, I want to make a third person action/adventure type game. The problem right now is the character controls.

I'm not sure how to go about getting the controls the way I'd like them. Basically, I want the character to turn left or right when the corresponding key is held down (obviously). I'd like the character to move forward according to the direction its facing. I don't want the character to move backward, though. If the tries to move the character back, I want the character to turn completely around. So, really I want the character to be facing whatever direction it's moving. I'm not sure the best way to go about all this...

Now, I'm not necessarily asking for code. I'm just looking for some practical ideas on how I can get this to work right.

Thanks!
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

search the forum for third person camera, there've already been posted several good implementations. ;)
lesPaul456
Posts: 18
Joined: Sat Jan 02, 2010 4:48 pm

Post by lesPaul456 »

Thanks for the reply.

I'm really not worried about the camera right now, though, I just can't seem to get the character controls right.
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

check out this one.

I think it's pretty much what you want. A rotating camera around a SceneNode and turning/moving to camera direction on key forward.

For strafing or turning you will have to take a look at this very part and just implement more key inputs for doing sideward movement instead of forward.

Code: Select all

if (keys[KEY_KEY_W]){

// player movement vector
vector3df playerStep = sphericalXYZ(cameraOrbit,0,playerMoveSpeed);
playerX -= playerStep.X;
playerY -= playerStep.Y;
playerZ -= playerStep.Z;
(... and more)
Never take advice from someone who likes to give advice, so take my advice and don't take it.
lesPaul456
Posts: 18
Joined: Sat Jan 02, 2010 4:48 pm

Post by lesPaul456 »

Thanks for the link. I'm not sure that I like that method for controlling the character (I'm using a laptop and it makes it hard to move).

For some reason, I just can't get this to work the way I want. I'll keep searching, though.

Thanks again!
Post Reply