- Home /
Making player move based on mouse position universal for all screens
I current have the player moving based on the mouse position and it adds force. The issue with this is if you're playing on a bigger screen you will move faster, if you play on a smaller screen, you move slower. How can I make this universal so that the player moves the same speed on all screens? I want the player to still accelerate and not move at a static speed, i just want the acceleration to be the same on all screens. Thank you for anyone who helps!
myRigid.AddForce(mousePosition.x / (Screen.width / 2 ),
0,
mousePosition.y / (Screen.height / 2 ),
ForceMode.Force);
Answer by THICC_GANDHI · Jul 07, 2021 at 08:37 PM
Are you sure that the screen is the problem, because 1920 / (1920 / 2) = 2
on a Full-HD monitor gets the same max. acceleration compared to 4096 / (4096 / 2) = 2
on a 4K monitor. Same with 3/4 acceleration 1440 / (1920 / 2) = 1.5
and 3072 / (4096 / 2) = 1.5
.