Pagina's

Thursday 21 February 2019

Drowning

Being a genius, sometimes ideas just pop up in my head in the bus or somewhere else. While I was pushing it ahead until I had enough of a grasp of how Unity deals with these issues, I found out a way to detect the player is in the water. There's a problem with just detecting collision with the water, because water is kind of just the surface and when the pond gets deep enough for the player to be inside it, below the surface of the water and not touching it, things are difficult.

The ingenious thing I came up with is this:

The thing on the right is a meassuring stick and the stick figure is the First Person Controller in the game. The blue semicircle is the water. What I came up with is a system with a dual Collider under the surface of the water. The purple "Water" collider and the red "Deep water" one. 

Because normal gravity rules do not apply to water bodies (we don't just walk over the bottom and up the banks), we have something detecting that, while not having the extra drowning perks. the collider is half the size of the FPC, so it'll allow the player to keep his/her head above the surface, literally. When the player drops to the red zone, the same gravity rules apply, but there are some more perks, including a timer that starts running. When the timer hits a certain level, the player is out of oxigen and health will drop quickly.

Another thing, nice idea from my colleague Annika, when the player is in the red zone, the UI will get a semi-transparant blue mask to have it visually obvious we're in a dangerous spot.

Other things I'll put in there will be about slowness and the possibility to fight, with some way to move up and down (probably by jumping-a-like behaviour). And probably more, but that's for later.

No comments:

Post a Comment