Beispiel #1
0
 private void DrawBaseCircle()
 {
     //Draw Radius
     DebugDrawers.DrawCircle(V3.zero, 1, Axis.Z, C.white, 0, 64);
     //Construct a triangle
     G.color = C.blue;
     G.DrawLine(V3.zero, new V3(cosine, sine));
     G.color = C.red;
     G.DrawLine(V3.zero, V3.right * cosine);
     G.color = C.green;
     G.DrawRay(V3.zero + V3.right * cosine, V3.up * sine);
 }
Beispiel #2
0
    void LateUpdate()
    {
        //
        if (Input.GetKey(KeyCode.L))
        {
            loops += Time.deltaTime;
        }
        if (Input.GetKeyDown(KeyCode.K))
        {
            resolution++;
        }
        //
        if (Input.GetKeyDown(KeyCode.A))
        {
            foreach (var n in nodes)
            {
                n.RotateCCW();
            }
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            foreach (var n in nodes)
            {
                n.RotateCW();
            }
        }

        nodes.Visualize(Color.yellow * .5f, .4f);
        nodes.Visualize(Color.red, .35f);



        DebugDrawers.DrawArc(transform.position, Vector3.zero, Color.yellow, 1);

        //rotate = Time.time * 180;

        Debug.DrawRay(seeker.position, seeker.forward);
        Debug.DrawRay(target.position, target.forward);

        DebugDrawers.DrawCircle(seeker.position, 3, Axis.Y);
        Collider[] c = Physics.OverlapSphere(seeker.position, 3, seekablesLayer);

        if (c.Length > 0)
        {
            print("Found " + target.name);

            Debug.DrawLine(seeker.position, target.position);

            angle = Vector3.Angle(seeker.forward, target.position - seeker.position);

            angle = Vector3.SignedAngle(seeker.forward, target.position - seeker.position, Vector3.up);
            var a = angle;
            print(state);
            if (a > -45 && a < 45)
            {
                state = State.Forward;
            }
            else if (a > 45 && a < 135)
            {
                state = State.Right;
            }
            else if (a > -135 && a < -45)
            {
                state = State.Left;
            }
            else if (a > 135 || a < -135)
            {
                state = State.Back;
            }
            else
            {
                state = State.Nothing;
            }
        }
        else
        {
            state = State.Nothing;
        }
    }
Beispiel #3
0
 public static void Visualize(this Node n, Color color, float radius, int xOffset = 0, int yOffset = 0)
 {
     DebugDrawers.DrawCircle(new Vector2(n.x + xOffset, n.y + yOffset), radius, Axis.Z, color, 0);
 }