Jump to content
Sign in to follow this  
tortuosit

eyeDirection (vector) to horizontal angle (number) conversion?

Recommended Posts

Hi guys, I guess this is atan magic.

It goes over my head and I searched and couldn't find.

 

- Player looks to a direction on the map. Lets say, to 42.42°

- I want to find out the direction where he looks (0-360 degrees numeric value)

 

I just found vector based commands. Like:

 

_verctor = eyeDirection player;

 

So how do I convert the vector to my desired angle?

 

TIA

Share this post


Link to post
Share on other sites

Got it.

_azimuth = (((eyeDirection player) select 0) atan2 ((eyeDirection player) select 1) + 360) % 360;

Share this post


Link to post
Share on other sites

I don't quite follow you. You want to know the eye direction in degrees? 

[0,0,0] getdir (eyeDirection player)

Wait. That gives odd results; if you freelook, it doesn't go beyond +-60 degrees from body direction.... Must be meant for AI units, whose necks are a bit stiffer.

 

Edit.  

[0,0,0] getdir getCameraViewDirection  player

is better.

 

Or maybe:

(positionCameraToWorld [0,0,0]) getdir (positionCameraToWorld [0,0,1])

Share this post


Link to post
Share on other sites

My code works, but oh, I have overlooked "getdir", which makes life easier :) Thx.

[0,0,0] getdir getCameraViewDirection player

Is good :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×