minmay wrote:Use a WaterSurfaceComponent with no WaterSurfaceMeshComponent and make sure your tiles have "underwater = true".
minmay wrote:Whether the party (or a monster or item) is considered underwater or not actually has nothing to do with the water surface or water surface mesh object. It is tied solely to whether they are in a tile with the "underwater" flag and at a low enough world y position at the same time. You can even use the heightmap to let the party wade slowly into water (although the water shader looks incredibly bad when camera y is close to the plane y, so you don't want to do that).
What often trips people up is that the planeY value in the WaterSurfaceComponent determines the y position of the reflection plane. Generally you want this to be the same as the y position of the water plane, since objects are supposed to appear to reflect off the water, but I can imagine exceptions.
You might need to add an underwater side to your mesh, I forget.
I did it that way for the water surface, and used the sky object for the fog (not ideal I think):
Code: Select all
defineObject{
name = "big_ocean",
components = {
{
class = "Model",
model = "mod_assets/models/env/ocean_water_big.fbx",
offset = vec(0, -1.2, 0),
renderHack = "ForceZWrite",
sortOffset = 100000, -- force water rendering before other transparent surfaces
},
{
class = "Model",
name = "bottom",
model = "assets/models/env/water_bottom.fbx",
offset = vec(0, -2, 0),
},
{
class = "WaterSurface",
planeY = -1.2,
fogColor = vec(0.042, 0.09, 0.26) * 0.5,
fogDensity = 0.2,
reflectionColor = vec(0.77, 0.9, 1.0) * 0.9,
refractionColor = vec(1,1,1),
},
{
class = "Timer",
timerInterval = 0,
triggerOnStart = true,
onActivate = function(self)
if party:getWorldPositionY() < self.go:getWorldPositionY()-1.2 then
if self.go.model:getMaterial() ~= "water_surface_underwater" then
self.go.model:setMaterial("water_surface_underwater")
end
else
if self.go.model:getMaterial() ~= "ocean_water" then
self.go.model:setMaterial("ocean_water")
end
end
end,
},
},
placement = "floor",
dontAdjustHeight = true,
editorIcon = 264,
reflectionMode = "never",
}