Jump to content


Photo

Проверка поля зрения


  • Please log in to reply
1 reply to this topic

#1 OFFLINE   Kurt212

Kurt212

    Рядовой

  • Пользователи
  • 29 posts

Posted 16 April 2016 - 23:14

Вроде как нет стандартных средств на проверку, может ли один юнит видеть другого юнита.
Вот тут спросил.
Поэтому выкладываю свою функцию для сей проверки. (Там скорее всего есть баги :) )

Kurt_fnc_isInFOV = {
	/*
		Author: Kurt

		Description:
			checks if the given unit can see another unit
	
		Parameter(s):
			0: OBJECT - the main character of this book
			1: OBJECT - the unit, we try to see
	
		Returns:
			BOOL
	*/

	params["_unit", "_target"];
	private ["_return", "_vis", "_uia"];
	_return = false;
	_vis = lineIntersects [eyePos _unit, eyePos _target, _unit, _target];
	if(_vis) exitWith { false };
	_uia = [getpos _unit, getdir _unit, 90, getpos _target] call BIS_fnc_inAngleSector;
	if(_uia) exitWith { true };
	_return;
};

Пример:

_s = [player, BILL] call Kurt_fnc_isInFOV;
if(_s) then { 
	hintSilent "I see you, Bill!";
};

Видео


Edited by Kurt212, 19 April 2016 - 23:06.

  • 2

#2 OFFLINE   Dimon UA

Dimon UA

    Ст.сержант

  • Пользователи
  • 304 posts
  • Откуда:Севастополь

Posted 20 April 2016 - 07:37

правильнее было бы: смотрит ли один юнит на другого

за функцию спасибо


  • 0




Яндекс.Метрика