a script for objects along ray sensors ray sensors?

i’ve thought up a pretty clever way to do glare filters(not to mention, HIGH SPEED!), but the problem is, i’m terrible with python. if someone write(or direct me to) a script that keeps a parented object along a ray sensor, i could post the blend.

“keeps a parented object along a ray sensor” have too many different meanings. If what you want is to just place the child in the direction of a ray towards something else with a specific distance, then you could do it like:

Run this every gametick on the father:


child_name = "ChildName" #put whatever the name of the parented object is here
child_distance = 10 #put whatever distance the child should be placed from the father
ray_target = "Ray goes where?" #put name of target ray object, or point here

import GameLogic
cont = GameLogic.getCurrentController()
own = cont.owner
child = own.children[child_name]

d, gv, lv = own.getVectTo(ray_target)

p = own.worldPosition
p[0] += gv[0]*child_distance
p[1] += gv[1]*child_distance
p[2] += gv[2]*child_distance
child.worldPosition = p

#just wrote this by head and didn't test it so could have some silly syntax mistake

Or do you want something else? If so, tell me exactly what ray is it (from and to) and where in the ray do you want the child in.

it would work, but,

File “Text”, line 8, in <module>
KeyError: “CList[key]: ''Plane” key not in list"

The name should start with “OB” eg. “OBPlane”

wow…don’t I feel like a noob.:o i’ll post the blend for glare in resources later.

and the file, as promised. here