- Home /
UI objects move at different speeds on different resolutions
I am working on a music game kind of like a piano tiles game but I keep encountering the same issue. The blocks on the UI move at slightly different speeds on different resolutions. The canvas i am using is set to Screen Space - Camera, changing it to this got the speeds more accurate but up to 5 seconds faster at the end of a level. Here is the script I attached to all the blocks for them to move:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class MoveEasy : MonoBehaviour { // Update is called once per frame void FixedUpdate() { // print(height); // print(move); // 2 - Movement Vector3 movement = new Vector3(0, -3.15f, 0); movement *= Time.deltaTime; transform.Translate(movement); } }
I think the problem has something to do with me using vector3.
Answer by highpockets · May 27, 2019 at 09:29 PM
Because you are dealing with pixels, you can avoid this problem by moving based on screen size instead. Use Screen.width
And Screen.height
to define your space and then move around based on percentages.