|
Hello, I'm creating a game that uses Kinect to control flight, but I am having really big problems. The speed is constant, and the camera is attached to the head joint, so the idea is wherever the player turns the head, is where the player should turn and look at and continue moving forward. Right now instead of turning, the character it's only changing the forward vector's direction, and it's making my character fly sideways or even backwards. Any ideas on how can I achieve that???? Here's my code: Any help is appreciated
(comments are locked)
|
|
The problem here is the Translate direction: Translate by default uses local coordinates, thus you can simply use Vector3.forward to make it go in its forward direction.
Vector3 newDirection = Camera.main.transform.forward;
newDirection.y = 0; // force direction to the horizontal plane only
transform.forward = newDirection; // turn the character to newDirection
// move in the character's local forward direction:
transform.Translate(Vector3.forward * (movementSpeed / 2) * Time.deltaTime);
It worked!!! Thanks a lot!!!
Mar 04 '12 at 06:18 AM
avillago
(comments are locked)
|
