Moving Light Source / OnSimulationUpdate

Hi there!
Could someone explain to me when is OnSimulationUpdate triggered?
I would like to have a light attached to a robot. Since it cannot be added as a feature, I thought of using OnSimulationUpdate, as suggested in this thread Light source, but I can’t make it work…
Also, is there a way to make a light source move continuosly, like a vehicle?
Thanks!

Whenever the simulation is updated, so reset, start, stop, etc. and when render is done during runtime.

I had an old project with vehicle light, but that is long gone, my friend. Just play around with it.

Here is quick example, and note that depending on light type you might not need to set certain properties. I turned off the 3 directional lights as well in the scene to give Minecraft, Silent Hill vibes. Clean up the 5-min code as needed.

from vcScript import *
import vcVector

def getLightPosition():
m = comp.WorldPositionMatrix
return m.P

def OnSimulationUpdate(time):
sean_paul.Position = getLightPosition()

comp = getComponent()
app = getApplication()
sean_paul = app.findLight(“BigUpsWidIt”)
if not sean_paul:
sean_paul = app.createLight(“BigUpsWidIt”)
sean_paul.Type = VC_LIGHT_POINT
sean_paul.Intensity = 1.0
sean_paul.ConstantAttenuation = 1000.0
sean_paul.Position = getLightPosition()
sean_paul.Direction = vcVector.new(0.5,0,0)
sean_paul.LinearAttenuation = 1000.0
sean_paul.QuadraticAttenuation = 1000.0
sean_paul.SpotAngle = 0.0
sean_paul.SpotExponent = 5.0

for l in app.Lights:
if l.Name != “BigUpsWidIt”:
l.Enabled = False
app.render()

Get creativity with the component material too. I prefer salmon or pink gold if you are feeling edgy.

For attachment, updating the light position will take care of that for you. (Sorry, no idea if mp4 will play here these days)

4 Likes