Notifications
Clear all
[Closed] collision position script controller help
Page 2 / 2
Prev
Mar 16, 2014 11:26 am
here is with max distance
delete objects
(
local p, d, s, maxdist = 30
p = plane name:"terrain" width:100 length:100 widthsegs:40 lengthsegs:40 wirecolor:green
d = point name:"control" pos:[0,0,30] size:10 box:on axistripod:on cross:on wirecolor:yellow isselected:on
in d (s = sphere name:"target" radius:3 wirecolor:orange)
addmodifier p (NoiseModifier fractal:on strength:[0,0,20] seed:2)
addmodifier p (Bend BendAxis:0 BendAngle:-120)
addmodifier p (Bend BendAxis:1 BendAngle:-120 BendDir:-90)
c = s.pos.controller = position_script()
c.addconstant "maxdist" maxdist
c.addnode "terrain" p
c.addnode "parent" d
c.addtarget "radius" s.baseobject[#radius]
ss = "r = intersectRay terrain (ray parent.transform.pos -parent.dir)
"
ss += "if r != undefined and (distance r.pos parent.pos) < maxdist then (r.pos + parent.dir * radius) * (inverse parent.transform) else [0,0,0]
"
c.setexpression ss
c.update()
)
edited… just cleaned it up
Page 2 / 2
Prev