Phantom lava and lukewarm lava in ILZ, analysis and fixes

BelgarelBelgarel Join Date: 2017-07-03 Member: 231570Members, Subnautica Developer Posts: 115 Advanced user
You might have noticed buggy lava in ILZ where you're damaged by standing on things that do not look like lava and also can stand in some lava without taking damage. I debugged and fixed both of these, details for how to fix them follow.

Here's an example of the first type, the phantom lava. Note how the prawn takes damage from nothing:

The issue is in TemperatureDamage.OnCollisionStay(). The MeshRenderer for the VoxelandChunk I'm on in that video has the following materials:

lava04tolava09 (instance)
lava03 (instance)
lava04 (instance)
lava05 (instance)
lava06 (instance)

The 'standing in lava' check looks for any material containing the string "lava09". That matches "lava04tolava09 (instance)" and after a raycast to see if I'm colliding with it passes it thinks I'm in lava. It likely should be matching that lava09 one exactly instead as lava04tolava09 doesn't look very lava-ish to me. Here's a video of that same area where I'm having the game draw 1m tall green spikes that linger for 10s along the raycast hit showing the locations that it considered to be lava due to the lava04tolava09 material matching "lava09":

Now about the second type of buggy lava, the kind you can stand in but not take damage. I'll use the same green spikes as above and walk across some "real" lava as an example - note how the game isn't considering a big patch of lava to be lava (no spikes indicating a raycast hit on lava):

Standing in that patch you see the missing spikes on I take no damage, I'm not considered to be in lava here:

The materials at this point are:

lava04tolava09 (instance)
lava03 (instance)
lava04 (instance)
lava09 (instance)

Note how it has both lava09 and the lava04tolava09 as before but now neither are matching. In fact, the raycast doesn't intersect any of these, I'm effectively standing on nothing. So that's our second bug, a problem with the raycasting. This turns out to be a precision issue as the ray is being cast from the exact point of the collision into the ground and it will thus sometimes be treated as slightly below the ground. By hoisting the starting position of the ray out of the ground by 0.1m in the opposite direction (and lengthening the max distance from 0.3 to 0.4) it intersects both lava04tolava09 and lava09 as expected.

So let's put it all together and try out both fixes and see how it plays:

No more invisible lava, and no more lava you can stand in. Note that the few remaining gaps aren't dead zones as before, they're likely the prawn skipping across the landscape. You can see that when I walk through one gap near the end that it does register as lava.


Sign In or Register to comment.