IsotopicIO / iso-space-game

An open source 3D Unity Game
MIT License
11 stars 4 forks source link

Bug: Jittery horizontal movement speed near 0 #14

Open fourthedesign opened 1 year ago

fourthedesign commented 1 year ago

Turning speed on ShipController is calculated every frame with the following line of code:

CurrentTurningSpeed = Mathf.Clamp(
    CurrentTurningSpeed + 
    ((turningSign == 0 && !Mathf.Approximately(CurrentTurningSpeed, 0f)) ? 
        -Mathf.Sign(CurrentTurningSpeed) * TurningSpeedDamping * Time.deltaTime 
        : 
        turningSign * TurningAccceleration * Time.deltaTime
    ), -TurningMaxSpeed, TurningMaxSpeed);

in Move(), Assets/Scripts/Player/ShipController.cs.

This causes a jitter and "feedback loop" of the value of movement speed from negative to positive, whenever the speed approaches 0 as you stop pressing A or D to move horizontally.

Fixing this is quite important as there is currently a barely noticeable but still noticeable jitter.