Third Person Camera/Movement

Level 6
Joined
May 1, 2009
Messages
156
Hi, I'm trying to make a specific unit move with the arrow keys, or WASD.
W is forward, S backwards, A turns the unit left, D turns the unit right.
Only difference is the camera. I don't want it FPS camera, i want a camera that is set and turns as the unit turns, as to keep it looking in the direction you are facing.

If someone could link or explain the triggering... thank you. +Rep
 
Level 8
Joined
Aug 2, 2006
Messages
346
I think you mean A and D strafe, not turn. Even if you DID mean turn, I'd highly recommend against that. Those controls ruined "Alone in the Dark" for me.

Basically, what you should do is make a blank unit in the data editor with no model, but it can move, and this is what you use as the unit with the "follow unit group" action with the camera.

You need to have two triggers for each key, one detecting when the key goes down, another when it is released. Have a boolean variable for each key that corresponds to it's current state (so if the key is down, it's "true", if it's up, it's "false").

Then you'll have a trigger for your main movement loop. Event for this trigger should be "every 0.3125 real time seconds". Use a bunch of if-then-else statements for each key to see if it's pressed. I used 8 because you're not just moving up/back, left/right, you can also move diagonally by holding two down. The way I dealt with that was I just had it check every key (ie. "if up true, down false, left false, right false" then move forward.)

Inside each "if" statement, you'll want to make the unit move relative to the camera's facing, NOT THE UNIT'S facing. I'm pretty sure there's a function in there, like point with offset, or something like that.
 
Level 6
Joined
May 1, 2009
Messages
156
Uhm for what i'm trying to do, since it's fixed camera.... No, I would not want it to strafe. A goes left, D goes right. Because the camera follows where the unit is looking. For what i'm trying to do it doesn't need to be easy and fluent to move like you would think, not trying to be manuverable or anything, turning right and left works fine.
 
Top