Interkarma / daggerfall-unity

Open source recreation of Daggerfall in the Unity engine
http://www.dfworkshop.net
MIT License
2.73k stars 333 forks source link

Player not considered underwater even when surface of water is above eye level #2600

Open John-Leitch opened 8 months ago

John-Leitch commented 8 months ago

Describe the issue

The calculations for when a player begins holding their breath appear to be slightly off. In some cases, the player is not considered underwater even when the surface of the water is above eye level.

To Reproduce

Steps to reproduce the behavior:

  1. Enter a body of water.
  2. Begin to descend.
  3. Observe that breath is not tracked even when the surface of the water is above eye level.

Expected behavior

The player should be considered underwater sooner, probably when eye level is below the surface.

Screenshots and Logs

image

And a little bit further down:

image

Desktop (please complete the following information):

Jagget commented 8 months ago

There's one more related issue. When you are on the surface, the green filter still applies, like you're still under water.

Screenshot 2024-02-25 172830

John-Leitch commented 8 months ago

Looking at the code and experimenting with some changes, these appear to be two similar, but distinct issues. The breathing issue is caused by a multiplier of the player y position in PlayerEnterExit.Update, while the underwater issue is caused by a multiplier of the same in UnderwaterFog.UpdateFog. While I haven't tested the fix enough to send a PR out, I believe the breathing problem should be an easy fix.

However, the fog issue is going to be a little more complicated. I tested some changes to the modifier and managed to make the fog present when the player is just below the surface, and gone when above:

image

image

However, when swimming as high as possible, the camera is not entirely above the water.

image

And looking down, the player is able to see into the water with no fog.

image