I am trying to cast spotlights with the same spot size towards the same moving object. This requires modifying both the Distance variable and the Spot Size variable of each of the spotlights in real time. It’s very easy to do this with bpy calls, but these don’t affect the properties in real time. How does one go about changing these properties in real time?
Included is a .blend showing some spot lights tracking an object with my script:
import bpy import bge import mathutils import math co = bge.logic.getCurrentController() obj = co.owner track = co.actuators["Track"] trackobj = track.object objpos = obj.position trackobjpos = trackobj.position colorvec = mathutils.Vector((1,1,1)) bge.render.drawLine(objpos,trackobjpos,colorvec) dist = obj.getDistanceTo(trackobj) # lampobj = bpy.data.lamps.get(obj.name) # lampobj.distance = dist # ^ How do I do this in real time in the game engine? spotRadius = 1 ang = math.atan(spotRadius/dist) # lampobj.spot_size = ang co.activate(track)
How can I apply the commented out code in real time?
Also, as you can see in my script, I am drawing lines from the lights to the object, however if you run the game engine these lines only appear for a split second at the beginning, why is this?
Another quick question, is there any light source besides spot light that will do real time shadows?
TrackLightingExample.blend (389 KB)