Okay, I run into this problem a lot and always forget the solution, so I need some help.
I need to set the player's view angles based on the HitNormal of the surface they're standing on. Yaw won't be effected. Can someone help me figure out how to get an output angle?
[lua]local tr = util.GetPlayerTrace( pl, pl:GetUp() * -1 )
local ang = tr.HitNormal:Angle()[/lua]
Like that, you mean?
Fair warning though, this works but you can get twisted and turned in different directions. Just ignoring yaw probably won't solve the problem if the angle is slanted.
[QUOTE=Entoros;21397508][lua]local tr = util.GetPlayerTrace( pl, pl:GetUp() * -1 )
local ang = tr.HitNormal:Angle()[/lua]
Like that, you mean?
Fair warning though, this works but you can get twisted and turned in different directions. Just ignoring yaw probably won't solve the problem if the angle is slanted.[/QUOTE]
That will set angles to that OF the normal. That won't make it so it looks like they're walking on the angle will it?
Your request is very vague. I assume you want the player's view to be parallel to the surface, no?
[lua]local normalAngle = trace.HitNormal:Angle( );
normalAngle:RotateAroundAxis( normalAngle:Right( ), 90 );[/lua]
The normal does not provide you with any proper angle information, so the result may not be reliable.
[QUOTE=Nevec;21398587]Your request is very vague. I assume you want the player's view to be parallel to the surface, no?
[lua]local normalAngle = trace.HitNormal:Angle( );
normalAngle:RotateAroundAxis( normalAngle:Right( ), 90 );[/lua]
The normal does not provide you with any proper angle information, so the result may not be reliable.[/QUOTE]
That looks more like what I'm looking for.
Sorry, you need to Log In to post a reply to this thread.