AndrewBGS
Member
|
Player Orientation
What is the BEST way to get a vector of magnitude 1 (one) pointing in the direction my player character is looking? (I know some ways by finding the head slot and use direction, or using character angles . But I want to know the most neat way to do this.
|
|
08-01-2013 09:38 PM |
|
Tottel
Member
|
RE: Player Orientation
If you really want the look direction, then I would get the headbone and check the Matrix.z vec.
If it doesn't have to be as precise, you could also use the controller matrix.
It might be faster not to look up the bone every frame. It might just be me, but string operations are pretty slow.
|
|
08-01-2013 09:59 PM |
|
AndrewBGS
Member
|
RE: Player Orientation
Thanks a lot! The matrix's Z sounds like a good idea, and for some reason I didn't think of it. Thanks a lot, that was just the kind of answer I was hoping for.
|
|
08-01-2013 10:07 PM |
|
SamNainocard
Member
|
RE: Player Orientation
Keep in mind that using matrix.z may get altered by moving while strafing (W,S+A,D), animation, and some.
So, if you want a precision, try get matrix.z from a new Matrix based from controller matrix that rotated by character's angle.
|
|
08-02-2013 06:03 AM |
|
AndrewBGS
Member
|
RE: Player Orientation
I'll have to check and see how much this effects me. In the 2 minutes of testing it I didn't notice any problems, but thanks for the heads up.
I saw what you mean, indeed that orientation gets lost when I use A/D. I'll try your idea with the character's angle also.
However I got lost in the multitude of matrix functions :|. Can you please tell me in more detail what I should do?
(This post was last modified: 08-02-2013 08:57 AM by AndrewBGS.)
|
|
08-02-2013 08:27 AM |
|
Rubeus
Member
|
RE: Player Orientation
Vec forward( 0, 0, 1 );
forward.mul( PlayerMatOrControllerMat.Orn( ) );
forward should remain a unit vector. Does that work for you?
|
|
08-02-2013 01:48 PM |
|
AndrewBGS
Member
|
RE: Player Orientation
I used player.ctrl.actor.orn().z .... Quite a long story, but it seemed to work. I'll check yours in a little also.
|
|
08-02-2013 02:27 PM |
|