Well-met Posted July 20, 2021 Share Posted July 20, 2021 Is there a layer that only renders above the land but NOT into the sea? I have a mechanic that produces sinkholes but they keep overlapping into the sea and it's not pretty Link to comment https://forums.kleientertainment.com/forums/topic/132008-layer/ Share on other sites More sharing options...
Monti18 Posted July 21, 2021 Share Posted July 21, 2021 I'm not sure if there is a layer like this, but why don't you make it like the component sinkholespawner? Spoiler local SINKHOLD_BLOCKER_TAGS = { "antlion_sinkhole_blocker" } function SinkholeSpawner:SpawnSinkhole(spawnpt) local x = GetRandomWithVariance(spawnpt.x, TUNING.ANTLION_SINKHOLE.RADIUS) local z = GetRandomWithVariance(spawnpt.z, TUNING.ANTLION_SINKHOLE.RADIUS) local function IsValidSinkholePosition(offset) local x1, z1 = x + offset.x, z + offset.z if #TheSim:FindEntities(x1, 0, z1, TUNING.ANTLION_SINKHOLE.RADIUS * 1.9, SINKHOLD_BLOCKER_TAGS) > 0 then return false end for dx = -1, 1 do for dz = -1, 1 do if not TheWorld.Map:IsPassableAtPoint(x1 + dx * TUNING.ANTLION_SINKHOLE.RADIUS, 0, z1 + dz * TUNING.ANTLION_SINKHOLE.RADIUS, false, true) then return false end end end return true end local offset = Vector3(0, 0, 0) offset = IsValidSinkholePosition(offset) and offset or FindValidPositionByFan(math.random() * 2 * PI, TUNING.ANTLION_SINKHOLE.RADIUS * 1.8 + math.random(), 9, IsValidSinkholePosition) or FindValidPositionByFan(math.random() * 2 * PI, TUNING.ANTLION_SINKHOLE.RADIUS * 2.9 + math.random(), 17, IsValidSinkholePosition) or FindValidPositionByFan(math.random() * 2 * PI, TUNING.ANTLION_SINKHOLE.RADIUS * 3.9 + math.random(), 17, IsValidSinkholePosition) or nil if offset ~= nil then local sinkhole = SpawnPrefab("antlion_sinkhole") sinkhole.Transform:SetPosition(x + offset.x, 0, z + offset.z) sinkhole:PushEvent("startcollapse") end end This function chooses the exact point where the character is standing or a random point near the character and checks if the point is passable, which also includes a check if there is water at this point. You could change this function to your preferences. 2 Link to comment https://forums.kleientertainment.com/forums/topic/132008-layer/#findComment-1480661 Share on other sites More sharing options...
Well-met Posted July 22, 2021 Author Share Posted July 22, 2021 well, yes, but my special sinkhole has a bigger graphic scale so it'll clip into the sea even with this failsafe Link to comment https://forums.kleientertainment.com/forums/topic/132008-layer/#findComment-1480815 Share on other sites More sharing options...
Monti18 Posted July 22, 2021 Share Posted July 22, 2021 If that's the case, replace all instances of TUNING.ANTLION_SINKHOLE.RADIUS with the radius of your sinkhole. The sinkhole of the antlion has a radius of 2.5, the function should find a place without overlapping into the sea if you choose the right radius. You can make it even bigger if you want more space in between the sea and your sinkholes. 2 Link to comment https://forums.kleientertainment.com/forums/topic/132008-layer/#findComment-1480895 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now