bangabob 45 Posted May 1, 2014 (edited) So this script creates a sheep behind the player. The while loop at the end is getting the players direction and should exit the loop when the player is within 30 degrees (+-) of facing the sheep. Therefore if the players initial direction is 210. The loop will exit when the direction is between 420 and 360 degrees. (Players Direction + 180 (+-30)) The problem is that the 'GETDIR' is 0-360. So it will never trigger for the 420 or Minus figues. Please math genius's. HELP ME!!!!!!!!!! _player = _this select 0; _randDir = getDir vehicle _player; _randDist =4; _enemyLoc = [(getPos vehicle _player select 0) - (_randDist * sin(_randDir)), (getPos vehicle _player select 1) - (_randDist * cos(_randDir)), 0]; _veh = createVehicle ["Sheep_random_F", _enemyLoc, [], 0, "CAN_COLLIDE"]; _veh setpos [_enemyLoc select 0,_enemyLoc select 1,(_enemyLoc select 2)+2]; _dir= [_veh,_player]call BIS_fnc_relativeDirTo; _veh setdir _dir; _veh enablesimulation False; _behind=_dir -180; _left=_behind + 30; _right=_behind - 30; while {true} do { _currentDir=getdir _player; hint format ["%1||Left:%2 | Right:%3",_currentDir,_left,_right]; if (_currentDir > _right AND _currentDir < _left) exitwith { deletevehicle _veh; //null=[] execVM "screenFlare.sqf"; }; sleep 0.5; }; Edited May 1, 2014 by BangaBob Share this post Link to post Share on other sites
champ-1 40 Posted May 1, 2014 I'm scared to ask. But what is the intention of this script? Share this post Link to post Share on other sites
bangabob 45 Posted May 1, 2014 I'm scared to ask. But what is the intention of this script? Nothing scary or exciting. I can assure you Share this post Link to post Share on other sites
champ-1 40 Posted May 1, 2014 Creepy ship following you and then disapearing when you not looking? Slendership :D Not sure I get what you going for but player direction and player's eyes direction completly different things. Just saying. Share this post Link to post Share on other sites
bangabob 45 Posted May 1, 2014 Not sure I get what you going for but player direction and player's eyes direction completly different things. Just saying. Good point. I basically need a script that can detect when a unit is facing towards something. Share this post Link to post Share on other sites
champ-1 40 Posted May 1, 2014 (edited) I have a little something for you. That's how you get eye direction. _player_raw_dir = eyeDirection player; _player_eye_dir = ((_player_raw_dir select 0) atan2 (_player_raw_dir select 1)); ---------- Post added at 17:47 ---------- Previous post was at 17:44 ---------- how is this? Would it work? (_direction - 180 + 360 == _relative_direction + 360) Edited May 1, 2014 by Champ-1 Share this post Link to post Share on other sites
bangabob 45 Posted May 1, 2014 Cheers, I'll give that a go Share this post Link to post Share on other sites
Larrow 2822 Posted May 2, 2014 Use BIS_fnc_inAngleSector... [getPosATL player, getdir player, 30, getposATL _sheep] call BIS_fnc_inAngleSector; Will return true if the sheep is within a 30degree arc of the players facing direction. Share this post Link to post Share on other sites
bangabob 45 Posted May 2, 2014 Use BIS_fnc_inAngleSector... [getPosATL player, getdir player, 30, getposATL _sheep] call BIS_fnc_inAngleSector; Will return true if the sheep is within a 30degree arc of the players facing direction. Nice one. Had no idea this function existed. Combined with the eyeposition command this could be my problem solved! :D Share this post Link to post Share on other sites