/** * Creates 4 points for vision cone shape, left and right are just reverse of each other * Get the appropriate compoenent and assign them starting values */ private void SetUpVisionCone() { _leftVision.Add(new Vector2(-0.2f, 0.5f)); _leftVision.Add(new Vector2(-5f, 1.6f)); _leftVision.Add(new Vector2(-5f, -0.8f)); _leftVision.Add(new Vector2(-0.2f, _detection.GetEyeDistance())); for (int i = 0; i < 4; i++) { var rightEye = Vector2.Scale(_leftVision.ElementAt(i), new Vector2(-1f, 1f)); _rightVision.Add(rightEye); } _visionCone = GetComponent <PolygonCollider2D>(); _visionCone.points = _rightVision.ToArray(); _coneRender = GetComponent <VisionConeRender>(); _coneRender.SetConeShape(_visionCone.points); _coneRender.ActivateState(_blind); }
/** * Sets the vision cone to the direction guard walking */ public void SetVisionCone(bool goingLeft) { _coneRender.SetConeShape(_visionCone.points); }