Last week was the alpha version of my platform game and I'm pleased to say it went well. So from now on I'll be working towards the beta version.
There's a lot of stuff to do for the beta version and one of these things is when the player falls in to a pit, he needs to spawn at a safe location. Previously the player would just die and have to start the level all over again. We decided that that was too much of a punishment and instead the player should lose a little bit of health and spawn back at a safe location. To find that safe location we keep track of when the player was last on the ground. This is shown in the picture below.
Here the player falls in to a pit and the last location on the ground is shown with the transparent model. A problem here is that when spawning the player at the transparent model he is right at the edge and could fall off again, instead we should make sure the player spawns at a position that is not too close to the edge. A solution would be to spawn the player at the last location on the ground plus a displacement in the negative direction the player was looking. Then in the above case the player would be spawned away from the edge. But unfortunately that is not a good solution as can be seen in the next case, where the player would then not even be spawned on the ground and immediately fall in to the pit again:
Instead we cast rays to the left and right of the player, straight down and see which rays hit the ground within a short distance. If both rays hit then the location is safe. If only the left ray hits then we displace the safe position to the left and similarly for the right ray. And this solution will work fine for now.
-- Stijn
Geen opmerkingen:
Een reactie posten