3 ms·
Scenario: - you have a 1m thick floor in your video game. - your video game has physics in it (like gravity, collisions, etc). - your game runs at 60 fps Gi
by umvi 5y ago
Scenario:
- you have a 1m thick floor in your video game.
- your video game has physics in it (like gravity, collisions, etc).
- your game runs at 60 fps
Given these assumptions, if any in-game object ever exceeds a velocity 60 m/s then on one frame it will be above the floor and on the next frame it will be below the floor without ever triggering a collision. Oops.
Let me guess: "Just make the floor infinitely thick". Sure that would work but it sort of limits the kinds of maps and terrain you can make if the floor is always infinitely thick.
One way to solve it without infinitely thick floors is to draw an imaginary line between your current position and previous position every frame and check if the line would have collided with anything . If it does - do something (make the player die, move them back above the floor, etc.). It gets more complex when it's not just the floor you have to worry about clipping through but the wall and the ceiling and all other objects.