Beispiel #1
0
    public void Act()
    {
        Vector3    currentNormal        = c_collisionData.v_surfaceNormal;
        Quaternion currentRotation      = c_playerData.q_currentRotation;
        Quaternion currentModelRotation = c_positionData.q_currentModelRotation;
        float      currentVelocity      = c_playerData.f_currentSpeed;

        AngleCalculationCartridge.AlignToSurfaceByTail(c_collisionData.v_surfaceNormal,
                                                       ref currentRotation,
                                                       ref currentNormal,
                                                       1);
        AngleCalculationCartridge.AlignToSurfaceByTail(c_collisionData.v_surfaceNormal,
                                                       ref currentModelRotation,
                                                       ref currentNormal,
                                                       1);

        // boosting adds an extra acceleration force, scale boost rate by vertical direction
        float scaledBoost = Mathf.Max((c_playerData.q_currentRotation * Vector3.forward).y * c_playerData.f_boostAcceleration * Constants.NEGATIVE_ONE, Constants.ZERO_F);

        Debug.Log(scaledBoost);
        AccelerationCartridge.AccelerateAbs(ref currentVelocity, scaledBoost * Time.fixedDeltaTime, c_playerData.f_topSpeed);

        c_playerData.f_currentSpeed           = currentVelocity;
        c_playerData.v_currentNormal          = currentNormal;
        c_playerData.q_currentRotation        = currentRotation;
        c_positionData.q_currentModelRotation = currentModelRotation;

        c_aerialMoveData.f_verticalVelocity = Vector3.Dot(c_playerData.q_currentRotation * Vector3.forward, Vector3.up) * c_playerData.f_currentSpeed;
    }
Beispiel #2
0
    public void Act()
    {
        Quaternion currentModelRotation = c_positionData.q_currentModelRotation;
        Quaternion currentRotation      = c_playerData.q_currentRotation;

        float currentSpeed         = c_playerData.f_currentSpeed;
        float currentTurnSpeed     = c_turnData.f_currentTurnSpeed;
        float currentRealTurnSpeed = c_turnData.f_currentRealTurnSpeed;
        float targetTurnAccel      = c_turnData.f_turnAcceleration * c_playerInputData.f_inputAxisLHoriz;
        float turnSpeedCap         = Mathf.Abs(c_turnData.f_turnTopSpeed * c_playerInputData.f_inputAxisLHoriz);

        float turnSign = Mathf.Sign(targetTurnAccel);

        AccelerationCartridge.CalculateInterpolatedAcceleration(out float currentTurnAccel,
                                                                targetTurnAccel,
                                                                turnSpeedCap * turnSign * Constants.NEGATIVE_ONE,
                                                                turnSpeedCap * turnSign,
                                                                currentTurnSpeed);

        AccelerationCartridge.AccelerateAbs(ref currentTurnSpeed, currentTurnAccel, turnSpeedCap);
        AccelerationCartridge.AccelerateAbs(ref currentRealTurnSpeed, currentTurnAccel, turnSpeedCap, c_turnData.f_currentSurfaceFactor);

        HandlingCartridge.Turn(Vector3.up, currentTurnSpeed * Time.fixedDeltaTime, ref currentModelRotation);
        HandlingCartridge.Turn(Vector3.up, currentRealTurnSpeed * Time.fixedDeltaTime, ref currentRotation);

        HandlingCartridge.AddTurnCorrection(Vector3.up, ref currentModelRotation, currentRotation, c_positionData.i_switchStance);

        AccelerationCartridge.Decelerate(ref currentSpeed,
                                         Mathf.Abs(currentRealTurnSpeed / c_turnData.f_turnTopSpeed) * c_turnData.f_turnSpeedDeceleration * Time.fixedDeltaTime);

        c_positionData.q_currentModelRotation = currentModelRotation;
        c_playerData.q_currentRotation        = currentRotation;
        c_turnData.f_currentTurnSpeed         = currentTurnSpeed;
        c_turnData.f_currentRealTurnSpeed     = currentRealTurnSpeed;
        c_playerData.f_currentSpeed           = currentSpeed;
    }