Example #1
0
    private void Update()
    {
        if (!ready || locked)
        {
            return;
        }

        TargetSystem.LockTarget(transform.position, gun.weapon.maxRange);
        if (TargetSystem.currentTarget != null)
        {
            LookAt(TargetSystem.currentTarget.transform.position);
            sprite.flipX = (TargetSystem.currentTarget.transform.position.x < transform.position.x) ? true : false;
        }
        else
        {
            walkVelocity = Vector2.zero;
            float rot = (sprite.flipX) ? 180 : 0;
            gun.transform.rotation = Quaternion.Euler(new Vector3(0, 0, rot));
        }
        body.velocity = walkVelocity + dashVelocity;
        anim.SetBool("Moving", (body.velocity.magnitude > 0.35f));
    }