Specify Smart Property via Script - How?

I'm modifying the DayCycleController from Farmers Market. When I removed the huge moon and made the sun smaller, I found the sun was moving across the sky twice--once by day and once by night. I think I can turn off visibility at night ("night," "dawn," etc. are defined in the script) but what would be cooler is if I could change the shape property so that it's a moon at night and a sun disc during the day. The Sun Light component has a smart property called Shape that has a dropdown that includes types of sun discs and types of moon discs, which makes this data a string. What line do I add to the script when I want the smart property to change? The script includes changes in smart properties, but all of them are floats so I can't copy the pattern.

If anyone can help, thanks!

The smart property most likely requires a string value. For example:

(The code below is merely for demonstration purposes it most likely not work)

dayNightCycler:SetSmartProperty("Shape", "Sun")

Sadly, that didn't work. The line causes no errors but it doesn't do anything. For now, I'll just uncheck the box for drawing the sun.


It most likely did not work because you were using the wrong smart property name. Unfortunately, the Smart Property names in the editor are not always the same smart property names as shared by the SetSmartProperty() function. I would recommend dropping the day/night sky object into a script custom property and then debugging that script so you can see what properties and smart properties the sky object has.

Sorry, but how do you do this as I seem to be running into the same issue trying to set Planet Rotation via script.

You would first create some dummy script that you will delete late. Then, drag that dummy script into your hierarchy and add a "Core Object Reference" (call it "dummy1") custom property to that dummy script. Next, drop your day/night sky effect into the new core object reference custom property. Next, drop the code below into your dummy script and add a breakpoint at line 2 (to add the break point you will need to use Core's built-in Lua editor). Finally, run your game.

local dummy = script:GetCustomProperty("dummy1"):WaitForObject()

You should see a debug window pop-up immediately after running your game. Expand the "dummy` variable in the Debug Window and then expand the "GetSmartProperties()" item that is within your "dummy" variable. This will show you a list of all of the names of the smart properties for the day/night/ cycle.