TPS character movements

I made a third person shooter control cube that always move relatively to where the camera look at him (not local nor global movements) but the problem is… that I want the character, that is parented to the cube, to always face where he he is going… and I have no idea how to do that. The control cube alway face the camera.

Its for Dark Feild, in the vilage map. If someone could help me it would be greatly apreciated.

Here is the .blend (without the character cause Its for Dark Feild and Dark Feild only… sorry :o). Use arrow keys to move around.

Attachments

TPS_control_template_test.blend (391 KB)

Your side motion means that the character does steps to the side.
With left/right you need to rotate the control cube and not move. The forward motion should be relative to the character (local).
Your camera is not parented to the control cube. You could

  • parent the camera to the control cube
  • set slow parent (F7) + TimeOffset (e.g. 30) to the camera for smooth following
  • remove all actuators from the camera
  • remove the trackTo actuator from the control cube
  • change the control cube’s motion actuators from the Left/Right motion to left/right rotation.

By the way it would make sense to name your sensors, actuators and objects. Without that you might loose the overview of the scene.

I hope it helps

Aligning an object to the direction its moving it actually really, really easy: Velocity is a vector, meaning it has size and direction:

# Aligning an object to the direction its moving:

object = ...
velocity = object.getLinearVelocity()

object.alignAxisToVect(velocity, 1, 1) # Align Y axis to the velocity
object.alignAxisToVect([0,0,1], 2, 1) # Align Z axis to point directly up (stops flipping bugs)

Note, this will only work if you are using velocity rather than Dloc movement.

Your side motion means that the character does steps to the side.
With left/right you need to rotate the control cube and not move. The forward motion should be relative to the character (local).
Your camera is not parented to the control cube. You could

  • parent the camera to the control cube
  • set slow parent (F7) + TimeOffset (e.g. 30) to the camera for smooth following
  • remove all actuators from the camera
  • remove the trackTo actuator from the control cube
  • change the control cube’s motion actuators from the Left/Right motion to left/right rotation.

By the way it would make sense to name your sensors, actuators and objects. Without that you might loose the overview of the scene.

I hope it helps

That is not the type of control I wanted him to have. I don’t want to have a FPS control on a TPS view… I want a TPS control. Almost every modern game use this controls… you just have to press the key where you want to go (relative to camera) and the character automaticaly walk in that direction… humpfff… sorry if it sound weird, I realy have trouble explaining myself… I’m french.

Aligning an object to the direction its moving it actually really, really easy: Velocity is a vector, meaning it has size and direction:

Code:
[LEFT]# Aligning an object to the direction its moving:object = …velocity = object.getLinearVelocity()object.alignAxisToVect(velocity, 1, 1) # Align Y axis to the velocityobject.alignAxisToVect([0,0,1], 2, 1) # Align Z axis to point directly up (stops flipping bugs)[/LEFT]

Note, this will only work if you are using velocity rather than Dloc movement.

This is exactly what I wanted and I use velocity :D… but how would I use this script in my game ??? (the logic boxes configuration, I mean)

but how would I use this script in my game ??? (the logic boxes configuration, I mean)

If you are asking about a logic brick version, there is none afaik. To implement just use the script connected to an always sensor ( You need to fill in the object var though), no other logic bricks.

Wow :slight_smile: thank you. You’re a real help here.