Player movement is frame dependant even with Time.deltaTime
16:21 08 Jun 2022

I'm trying to port my friend's Scratch game to Unity for fun, but the code for deceleration is causing the player to speed up and slow down depending on the framerate. The maximum X velocity should be 6.75, which it is at 30 fps, (scratch's usual framerate), but when the FPS changes his speed varies up to ~7.5. Code (Unfinished):

 using System.Collections.Generic;
 using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public Vector2 Velocity, WallJumpForce;
    public float Acceleration, Decceleration;
    public float Gravity, JumpForce;
    public int TargetFPS;

    void Update()
    {
        Velocity.y -= Gravity;
        if(Input.GetKey("right") || Input.GetKey("d"))
        Velocity.x += Acceleration * SDT();
        if(Input.GetKey("left") || Input.GetKey("a"))
        Velocity.x -= Acceleration * SDT();
        Velocity.x -= Velocity.x*(1-Decceleration) * SDT();
        Move(Velocity.x, 0);
        Debug.Log(1 / Time.deltaTime + ", " + SDT());
        Application.targetFrameRate = TargetFPS;
    }

    void Move(float x, float y) //Converts Scratch Units to Unity Units
    {
        transform.position += new Vector3(x, y, 0) * 1.2f * Time.deltaTime;
    }
    
    float SDT() //Basically allows Scratch variables designed for 30fps work in unity
    {
        return 30 * Time.deltaTime;
    }
}

I've discovered that changing Velocity.x *= Decceleration * SDT(); to Velocity.x -= Velocity.x*(1-Decceleration) * SDT(); helps, but does not fix the problem. For reference, this is the game I'm porting. https://scratch.mit.edu/projects/590825095

c# unity-game-engine frame-rate