This is usually handled by decoupling the game's simulation space from the screen pixels.
Your game physics and logic then operate in a "world coordinate system" of arbitrarily-chosen measurement units (1 world unit = 1 tile width or 1 in-game meter are common choices) which represent the ground truth of what's happening in the game's universe.
Then displaying a view of this world on the player's screen becomes a matter of transforming from world coordinates to screen or pixel coordinates. Many such schemes are possible, depending on whether your game is top-down or side-scrolling, or some form of 2.5D / oblique / isometric perspective. What's great about this decoupling is that you can even support multiple display perspectives for different situations without re-implementing your game logic.
A simple display scheme is something like this:
Vector2 ToScreenPoint(Vector2 worldPoint) {
// Adjust for your current "camera" viewpoint, if you have one.
Vector2 relativeToView = worldPoint - currentView.worldspaceCenter;
// Scale by a translation factor that maps some controllable number
// of world-space units to always match the full height of the screen.
Vector2 pixelOffset = relativeToView * Screen.pixelHeight / currentView.worldHeight;
// (You could also choose to match the width instead, or some compromise formula)
// Add (Screen.pixelWidth, Screen.pixelHeight)/2 to convert into a range
// from 0 to the screen's extents. Now we have a pixel position.
return pixelOffset + Screen.center;
}
Note that if your game uses pixel art or needs pixel-perfect display, then you may need to make additional changes to your world-to-screen scaling logic or visual asset selection to keep it looking crisp on different resolutions. Pixel art does not handle arbitrary scales cleanly.
(As an aside: I think this question has been asked and answered before, but the keywords show up in so many other questions that I haven't been able to find the match. Please feel free to suggest duplicates if you find one)