Hello, I'd like to know if it's possible to hide or unhide a TSStatic based on the time of day in a level. If it is possible, could I get a tutorial on how it's done?
I'm not sure if there is an elegant way to hide a TSStatic object, and so the best way I found to "hide" it was by setting its position below the ground so you can't see it. And so the following code snippet would do just that. (I don't know exactly what you want so here's an example to start off on, which "hides" the object during the night (0.25 - 0.75 time) and makes it reappear during the day) Hope this helps! Edit: I forgot that you need to update the object's collision box after updating its position so the code becomes: Code: local M = {} local function onRaceTick(tick) local object = scenetree.findObject("name of object") local time = core_environment.getTimeOfDay().time --Its really inefficient to reload collision every single time --so its only done once when it switches from day-night, night-day local flag = false --This just hides an object during the night (0.25 - 0.75) if time > 0.25 and time < 0.75 then --Set z position to "hide" object if flag == false then object:setPosition(Point3F(x, y, -9999)) be:reloadStaticCollision(false) flag = true end else --Set object back to original position to "unhide" it if flag == true then object:setPosition(Point3F(x, y, z)) be:reloadStaticCollision(false) flag = false end end end M.onRaceTick = onRaceTick return M