Graphics quality influences transform position

Hello there.
I am trying to create a pong game. Player paddle movement is controlled by such script

float yPositon = gameObject.transform.position.y + (Input.GetAxisRaw("Vertical") * speed);
            paddlePosition = new Vector3(-8.5f, Mathf.Clamp(yPositon, -4.2f, 4.2f), 0);
            gameObject.transform.position = paddlePosition;

Where paddlePosition is Vector3 variable.

When I’m running game on Fantastic/Beautiful/Good graphics quality everything works fine, but when I change quality to Simple or below the paddle is moving with enormous speed. And only player paddle is moving so fast. Everything else works as in other qualities.

What may be wrong? I’d be grateful for any help :slight_smile:

i think, you should make it frame independent. Try something like: speed * Time.deltaTime

2 Likes

Yes, low graphics settings = higher framerate = more calls to Update() every second.

Time.deltaTime is the time that has passed since the last frame. At high framerate, this value is very low. Multiplying speed by this makes it so that your paddle will always move at “speed” units per second, regardless of how many times Update was called.

1 Like

Thank both of you very much :slight_smile: It did the trick.