Game Development Community

Determine cant angle in script

by Melvin Ewing · in Technical Issues · 10/18/2005 (6:00 am) · 10 replies

I have a player that conforms to the terrain, and when the player fires, I am providing an up adjustment from his point of aim (in order for the ballistic projectile to hit the point of aim at a given range). What I need to do though, is determine the amount of left/right cant that the player is at (when conforming to the terrain) in order to apply the up adjustment in relation to the player, not the world (as it currently does).

I would appreciate any pointers to figuring out that cant angle (in degrees or rads) from vertical...

thanks

MEL

#1
10/19/2005 (4:51 am)
Anyone have ideas?
#2
10/19/2005 (6:11 am)
What is a cant angle?
#3
10/19/2005 (8:32 pm)
By cant, I am meaning, the angle at which the player is tilted to the left or right.

MEL
#4
10/20/2005 (4:18 am)
I know I have the eye transform which gives me my orientation vector, but I am not sure how to get the angle left or right that I am "canted". Perhaps a 2D projection needs to be generated and then figure for the angle using arctan?

MEL
#5
10/20/2005 (7:04 am)
Dont got an answer for you but maybe tilted or turned would be a better term?
#6
10/20/2005 (10:58 am)
I still dont know whether you mean yaw or roll.
#7
10/21/2005 (9:45 am)
Sorry for the unclarity.

I mean "roll"

MEL
#8
10/21/2005 (2:40 pm)
To have the player conform to the terrain, I assume that you have that player's "up" vector. This should basically be the surface normal of the terrain you are conforming to. If you do an arccosine of the dot product between your up vector and the world up vector, that should give you the angle. So, something like arccos(myUp dot worldUp).
#9
10/24/2005 (5:10 am)
J. Alan,

Thank you for the info, unfortunately it gives me the angle between the up vector and the worlds upvector, which isn't quite what I'm looking for. I need the angle of "roll" from left to right or right to left of the players view of the world. If he is laying on the side of a hill looking down at an enemy and the player is rolled 20 degrees to the left, I need a way to determine that 20 degrees.

I do appreciate the info you provided, and any other ideas people are suggesting.

MEL
#10
10/24/2005 (6:59 am)
Melvin the angle between the players up vector and the world up vector is pretty close to the roll angle. you would need to project the world up vector onto the players x-z(vertical plane) coordinate axis to express this vector only in terms of the players current x and z vectors. instead of the angle between the players up vector and the world up vector, what you seek is the angle between the players up vector and the projection of the world up vector onto the players vertical coordinate axis. take the cross product of the players up vector and the eye vector to obtain a binormal vector. project the world up vector onto the binormal vector, then project the world up vector onto the players up vector. these two values now express the world up vector in terms of the players current vertical 2-d plane. you can find the angle between this projected vector and the players up vector to calculate the roll.