Jump to content
Sign in to follow this  
rejenorst

Finding out which way the player view is facing (not direction)

Recommended Posts

I am trying to find a way to tell which way the player's camera view is facing. I don't want to use getdir as players will often use mouselook/freelook.

Share this post


Link to post
Share on other sites

you can use cursorTarget, but it will only work sometimes, ie only when looking at a object.

you can run a loop and add the direction to the cursor target from player, to get latest "valid direction" but this will be not 100%.

also this is a theory, but see if you can atach something to the head of the player or if you can get the glasses object on player then getDir from that.

but i believe this is impossible atm in Arma2.

in Arma3 this will be possible as we can change gear ie helmets and then get the dir from that, (my theory)

Share this post


Link to post
Share on other sites

Yeah I had thought of attachto with a gamelogic to the players head but I yeah I think it's impossible to access the infantry model heads as an object.

I'll look into cursor target.

Also I found this:

http://community.bistudio.com/wiki/positionCameraToWorld

Dunno if this command might come in handy.

There's a community addon which allows for functions related to player head dir.

EDIT:

Have found the following topic which would be my best lead at the moment:

http://forums.bistudio.com/showthread.php?t=91431

Edited by Rejenorst

Share this post


Link to post
Share on other sites

I'm just guessing here but if the camera space is:

x is +right

y is +up

z is +away

or, that you some how can find the away camera axis then you can do this (let's assume the z axis is away):

_pointAhead = positionCameraToWorld [0,0,5];
_playerPos = getPos player;
_xDiff = (_pointAhead select 0) - (_playerPos select 0);
_yDiff = (_pointAhead select 1) - (_playerPos select 1);

Then based _xDiff and _yDiff you can find the compass direction.

Share this post


Link to post
Share on other sites

this is tested and working, changed celerys code but he got me on right track.

_null = [] spawn {
while {true} do {
	[b]_pos1 = screenToWorld [0.5,0.5];
	_pos2 = getPos player;
	_dirWatching = ((((_pos1 select 0) - (_pos2 select 0)) atan2 ((_pos1 select 1) - (_pos2 select 1))) + 360) % 360;[/b]
	hint format["looking in %1 direction",(round _dirWatching)];
	sleep 1;
};
};

palced in a trigger on act field for testing, the relevant code is highlighted.

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  

×