Пример #1
0
    void FixedUpdate()
    {
        if (CheckForSwing())
        {
            Swing();
        }

        maxAttackTime = stats.GetAttackTime() * wep.attackTime;
        if (!isSwinging)
        {
            currentAttackTime = maxAttackTime;
        }
        //Multiply by -1 to make it rotate the right way
        degreesPerSec = -1 * totalDegrees / maxAttackTime;

        if (isSwinging)
        {
            currentAttackTime -= Time.fixedDeltaTime;
            currentSwingRot.y += degreesPerSec * Time.fixedDeltaTime;

            if (currentAttackTime <= 0)
            {
                currentAttackTime             = maxAttackTime;
                isSwinging                    = false;
                currentSwingRot               = idleRot;
                weaponTransform.localPosition = idlePos;
                dmgDealer.ResetHitList();
                //TODO - MAKE AN IDLE POSITION/ANIMATION
            }
        }

        weaponTransform.localRotation = Quaternion.Euler(currentSwingRot);
    }