private void DibujarLineasCono(ViewCone cv) { //Vectores limites del cono Vector3 vectorAnguloA = cv.DirectionFromAngle(-cv._angle / 2); Vector3 vectorAnguloB = cv.DirectionFromAngle(cv._angle / 2); Handles.DrawLine(cv.transform.position, cv.transform.position + vectorAnguloA * cv._radius); Handles.DrawLine(cv.transform.position, cv.transform.position + vectorAnguloB * cv._radius); }
void FixedUpdate() { Behavior.Invoke(this); ProcessSoundEvents(); ViewCone.UpdateVectors(this.transform.forward); if (DebugShowViewCone) { ViewCone.DebugDrawVectors(this, true); } }
/***************************************************/ private static List <Polyline> ClipActivityArea(Polyline projected, ViewCone viewCone, Spectator origin, Plane viewPlane) { List <Polyline> clippedArea = new List <Polyline>(); for (int i = 0; i < viewCone.ConeBoundary.Count; i++) { var subject = projected.DeepClone(); Polyline temp = Geometry.Compute.ClipPolylines(subject, viewCone.ConeBoundary[i]); clippedArea.Add(temp); } return(clippedArea); }
private void OnSceneGUI() { ViewCone VC = (ViewCone)target; Handles.color = Color.white; Handles.DrawWireArc(VC.transform.position, Vector3.forward, Vector3.up, 360, VC.viewRadius); Vector2 viewAngleA = VC.dirFromAngle(-VC.viewAngle / 2, false); Vector2 viewAngleB = VC.dirFromAngle(VC.viewAngle / 2, false); Handles.DrawLine(VC.transform.position, (Vector2)VC.transform.position + viewAngleA * VC.viewRadius); Handles.DrawLine(VC.transform.position, (Vector2)VC.transform.position + viewAngleB * VC.viewRadius); }
// Use this for initialization void Start() { objectName = "Enemy"; player = GameObject.Find("Player"); enemyObject = GameObject.Find("Enemy"); detectCone = GameObject.Find("Enemy").GetComponentInChildren<DetectCone>(); viewCone = GameObject.Find("Enemy").GetComponentInChildren<ViewCone>(); detectBox = detectCone.GetComponent<BoxCollider2D>(); viewBox = detectCone.GetComponent<BoxCollider2D>(); // PolygonCollider2D detectCone = enemyObject.GetComponentInChildren<DetectCone>().PolygonCollider2D; // viewAngle = detectCone.GetComponent<Transform>().rotate(); }
/***************************************************/ private static List <Polyline> ClipActivityArea(Polyline projected, ViewCone viewCone, Spectator origin, Plane viewPlane) { List <Polyline> clippedArea = new List <Polyline>(); for (int i = 0; i < viewCone.ConeBoundary.Count; i++) { var subject = projected.DeepClone(); List <Polyline> temp = Geometry.Compute.BooleanIntersection(viewCone.ConeBoundary[i], subject); if (temp.Count > 0) { clippedArea.Add(temp[0]); } } return(clippedArea); }
private void OnSceneGUI() { ViewCone cv = (ViewCone)target; Handles.color = Color.white; //Dibujo lo que seria el circulo dentro del cual puedo captar las colisiones y ver al jugador. Vector3 normal = Vector3.forward; //normal -= new Vector3(normal.x, normal.y, normal.z - 10); Handles.DrawWireArc(cv.transform.position, normal, Vector3.up, 360, cv._radius); DibujarLineasCono(cv); //Normal que necesito en 2D Debug.DrawRay(cv.transform.position, normal, Color.red); Vector3 mouse = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10)); Debug.DrawRay(cv.transform.position, mouse - cv.transform.position, Color.magenta); }
void Start() { _viewCone = GetComponentInChildren <ViewCone>(); _pathFollower.AddPathDoneListener(OnPathDone); _pathFollower.AddPathStopListener(OnPathInterupt); _pathFollower.AddPathNotFoundListener(OnPathNotFound); Transform[] points = _patrolPointContainer.GetComponentsInChildren <Transform>(); for (int i = 1; i < points.Length; i++) { _patrolPoints.Add(points[i]); } _guardState = GuardState.Patrolling; UpdateState(); }
/// <summary> /// Check whether the target is in the Npc's field-of-view and line-of-sight /// </summary> public bool SightCheck(GameObject target, float dist) { if (target == null) { return(false); } // Vector3 dir = ( target.transform.position - ViewConeOriginPos ).normalized; Vector3 dir = target.transform.position - ViewConeOriginPos; Vector3 viewChk = dir; viewChk.y = 0.0f; if (ViewCone.IsInView(this.transform.forward, viewChk)) { return(Util.RayCheckTarget(ViewConeOriginPos, dir, TargetDistSqr, target, SightMask)); } return(false); }
public override void Update(Chunk chunk) { float dt = Game1.DeltaT; float direction, view; ViewCone.ToDegrees(out direction, out view); switch (State) { case AIState.Turning: if (direction < Extents.X || Extents.Y < direction) { Velocity = 0; EdgeTimer = EdgeWaitTime; State = AIState.Waiting; } break; case AIState.Waiting: EdgeTimer -= dt; if (EdgeTimer <= 0) { State = AIState.Turning; if (direction < Extents.X) { Velocity = +RotationSpeed; } else { Velocity = -RotationSpeed; } } break; } direction += Velocity * dt; ViewCone.FromDegrees(direction, view); base.Update(chunk); }
public PivotCamera(Vector2 position, Game1 game) : base(position, 0, game) { ViewCone.FromDegrees(Extents.X, 33); }