Look towards movement direction

Hey script gurus. A (probably) simple scripting question…

Here’s the scenario: The scene has a camera that sits in a fixed position facing the level. Also in the scene is a CharacterController. The controller moves in relation to the camera’s position, so ‘up’ is away from the camera, ‘down’ is towards the camera, etc. Now, what I’m trying to figure out is how to make the controller rotate around the Y axis to face the direction of movement.

My math has gotten a little rusty as of late… :expressionless:

Any solutions?

the simplest way:

transform.eulerAngles = Vector3(0,90,0); // else angles you can use is 45,135,180,225,270,315

Play with those angles, and fit what you need :wink:

Thanks Jaxas!

Although, that solution only partially solves my problem. I’m trying to find a way to make it truly analogous, so a plethora of ‘face’ directions would be possible. :?

I’d figure there has to be some formula utilizing the Input.GetAxis() inputs in some way.

The Locomotion System project includes controllers that work like this. You can use those controllers and disregard the Locomotion System itself. :slight_smile:

Rune

Thanks Rune!

Didn’t know that kind of stuff was included. Although I would’ve ended up getting the Locomotion system at some point because it is just awesome! :smile: