//public bool FindPlayer => target?GetDistance(transform.position, target.position) < range : false; //public float GetDistance(Vector3 _from, Vector3 _target) => Vector3.Distance(_from, _target); #region custom methods void UpdateSight() { sightTickTimer += Time.deltaTime; if (sightTickTimer > tickMax) { switch (sightType) { case AgentSightType.EcoPlus: TargetDetected = EcoPlus.GetEcoSight(transform.position, transform.forward, sightHeight, sightRange, targetLayer, obstacleLayer, ref target); break; case AgentSightType.MultiRay: TargetDetected = MultiRay.GetMultiRay(transform, transform.forward, sightHeight, sightRange, sightAngle, targetLayer, obstacleLayer, ref target); break; case AgentSightType.Overlap: TargetDetected = OverlapRay.GetOverlapSight(transform, ref target, obstacleLayer, targetLayer, sightRange, sightAngle); break; } if (!TargetDetected) { target = null; } sightTickTimer = 0; } }
private void DrawDebugRay() { //if (Application.isPlaying) return; switch (sightType) { case AgentSightType.EcoPlus: EcoPlus.DrawGizmos(transform, sightHeight, sightRange); break; case AgentSightType.MultiRay: MultiRay.DrawGizmos(transform, sightHeight, sightRange, sightAngle, targetLayer, obstacleLayer); break; case AgentSightType.Overlap: OverlapRay.DrawGizmo(transform, sightRange, target); break; } }