コード例 #1
0
ファイル: Player.cs プロジェクト: FlixonStudios/Battleping
    public void DecelerateToRest()
    {
        float inverseHorizontalAmplitude = (1 - Mathf.Abs(joystick.Horizontal));
        float inverseVerticalAmplitude   = (1 - Mathf.Abs(joystick.Vertical));

        float HorizontalVelocity = -myBody.velocity.x;
        float VerticalVelocity   = -myBody.velocity.y;

        float xDecelerationToDefault = mathController.DiminishingExponentialFunction(inverseHorizontalAmplitude) *
                                       mathController.DefaultDecelerationToUse(HorizontalVelocity, baseMaxBrakeSpeed);

        float yDecelerationToDefault = mathController.DiminishingExponentialFunction(inverseVerticalAmplitude) *
                                       mathController.DefaultDecelerationToUse(VerticalVelocity, baseMaxBrakeSpeed);

        Vector2 decelerationToDefaultForce = new Vector2(xDecelerationToDefault, yDecelerationToDefault);

        AddForceToPlayer(decelerationToDefaultForce);
    }