Example #1
0
    public override void Update(PlayerController player)
    {
        if (player.StateMachine.IsInState <Dead>() ||
            (!Input.GetKey(player.Inputf.drawWeapon) && Input.GetAxisRaw("CombatTrigger") < 0.1f))
        {
            player.UpperStateMachine.GoToState <Empty>();
            return;
        }

        if (player.Weapons.target == null)
        {
            CheckForTargets(player);
        }

        Vector3 aimDirection = player.Weapons.target != null ?
                               (player.Weapons.target.position - player.transform.position).normalized
            : UMath.ZeroYInVector(player.Cam.forward).normalized;

        float aimAngle = Vector3.SignedAngle(aimDirection, player.transform.forward, Vector3.up);

        player.Anim.SetFloat("AimAngle", aimAngle);
        player.Anim.SetBool("isFiring", Input.GetKey(player.Inputf.fireWeapon));

        // Stops player's waist wobbling
        player.WaistRotation = player.transform.rotation;
    }