Exemplo n.º 1
0
    void Update()
    {
        if (Health <= 0)
        {
            WS.EnemyDie();
            Destroy(this.gameObject);
        }

        if (hit)
        {
            sr.material = matWhite;
            Invoke("resetWhite", 0.01f);
        }
        else
        {
            sr.material = matDefualt;
        }
    }
Exemplo n.º 2
0
    private void Update()
    {
        if (Health <= 0)
        {
            WS.EnemyDie();
            Destroy(this.gameObject);
        }

        Vector3 direction = playerPosition.position - transform.position;
        float   angle     = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg + 90;

        rb.rotation = angle;

        transform.position = Vector2.MoveTowards(transform.position, playerPosition.position, SpeedMovement * Time.deltaTime);
        if (hit)
        {
            sr.material = matWhite;
            Invoke("resetWhite", 0.01f);
        }
        else
        {
            sr.material = matDefualt;
        }
    }