Exemple #1
0
    void checkBoundaries()
    {
        Vector2      proj = rb2d.position + Vector2.right * facing;
        RaycastHit2D hit  = Physics2D.Raycast(proj, Vector2.down, 10f, walkable_mask);

        if (hit.collider == null || !PatrolBoundary.isInBoundary(proj))
        {
            if (current_state == State.IDLE)
            {
                facing *= -1;
            }
        }
        else if (hit.collider != null)
        {
            ground_pos = hit.point;
        }
    }
Exemple #2
0
    void checkBoundaries()
    {
        Vector2      proj = rb2d.position + Vector2.right * dir;
        RaycastHit2D hit  = Physics2D.Raycast(proj, Vector2.down, 3f, walkable_mask);

        if (hit.collider == null || !PatrolBoundary.isInBoundary(proj))
        {
            is_on_edge = true;
            if (current_state == State.WALKING)
            {
                dir *= -1f;
                aim  = Vector2.right * dir;
            }
        }
        else
        {
            is_on_edge = false;
        }
    }