- Home /
(CharacterController's) transform.Lookat not working as expected
I'm using the CharacterController (together with my own scripts) to control the player character.
I want to make the up-vector of the player to point in the same direction as the normal of the ground he's standing on, but for some reason that just won't work.
I've used the transform.Lookat() function for this, but it often seems to not do anything at all. So I'm wondering if the CharacterController perhaps alters it's upvector itself ?
cause even when I do a simple test like this:
newup = transform.forward*0.5 + transform.up*0.5;
newdir = Quaternion.FromToRotation ( transform.up, newup ) * transform.forward;
transform.LookAt( transform.position+newDir, newup );
it does nothing at all
transform.forward and transform.up are unchanged afterwards, instead of beeing equal to newdir and newup.
I've also tried rotating the player character, but this doesn't work correctly either
Any help ?
Answer by Eric5h5 · Aug 14, 2010 at 10:37 AM
Character controllers always remain upright, and can only be rotated around the Y axis.
great :s guess I can't use the Character controller then
thanks for the fast answer
hm, that doesn't seem right do (about your answer) when I use the Rotate funtcion, the Character controller does rotate (but incorrectly) and the lookat function does somethimes rotate the upvector
@Steven: no, a character controller does not rotate, ever, except around the Y axis. If you look at the collider in the scene view, it is always upright.