Exemple #1
0
    private void Update()
    {
        this.direction = _npc.Direction();

        RaycastHit2D hit = Physics2D.Raycast(transform.position, new Vector2(direction, 0f), 2f, layerMask);

        if (hit && hit.collider.CompareTag("Player") && dashingAvailable)
        {
            StartCoroutine(Dash());
        }

        hit = Physics2D.Raycast(transform.position, new Vector2(direction, 0f), 0.25f, layerMask);

        if (hit && hit.collider.CompareTag("Enemy Limits"))
        {
            _npc.ChangeDirection();
        }
    }
Exemple #2
0
    private void Update()
    {
        this.direction = _npc.Direction();

        if (_captured && !_secured)
        {
            this.transform.position = player.transform.position + new Vector3(0, .2f, 0);
            // Sets the baby behind the player
            this.transform.localScale = new Vector3(-player.transform.localScale.x, player.transform.localScale.y, player.transform.localScale.z);
        }

        RaycastHit2D hit = Physics2D.Raycast(transform.position, new Vector2(direction, 0f), 0.5f, layerMask);

        if (hit && hit.collider.CompareTag("Baby Limits"))
        {
            _npc.ChangeDirection();
        }
    }