Page 1 of 1

If laser is hitting...

PostPosted: Sat Feb 27, 2010 11:18 pm
by The mask
Could anyone explain me how to change a variable when a laser is hitting and change it again when it stops hitting an object? :roll:


For example I've got a box and a laser when the laser hits the box scene.my.var1 = 0 and when it stops hitting the box scene.my.var1 = 1.

It could be used as a kind of movement sensor or tilting sensor just like here:

Rating: rated 5
Filesize: 9.06 kB
Comments: 0
Ratings: 1
download

Re: If laser is hitting...

PostPosted: Sun Feb 28, 2010 1:09 am
by StephenAlverez
Take a circle and put an offcenter motor in it, put it at +inf strength and 600 rpm, and put that circles on collide to scene.my.var1=1.

Re: If laser is hitting...

PostPosted: Thu Mar 04, 2010 9:12 am
by Mr_Stabby
if its motion sensor you want use this in laser

Code: Select all
(e)=> {e.laser.color==[1,0,0,1]?{e.laser.color=[e.pos(0), e.pos(1), 0, 1]}:{}; e.pos != [e.laser.color(0), e.laser.color(1), 0, 1]?{scene.my.var=1}:{scene.my.var=0} }


yells when anything tries to pass under it but you cant move it unless you compensate with extra scripting to reevaluate its default pos when moved, another way would be

Code: Select all
(e)=>{check=0; check=e.geom.entityID; check==0?{e.geom.entityID:=1; app.step; app.undo}:{}; e.laser.color==[1,0, 0, 1]?{e.laser.color=[e.geom.entityID, 0, 0, 1]}:{}; e.geom.entityID!=e.laser.color(0)?{scene.my.var=1}:{scene.my.var=0}}


doesent detect motion but rather what object its hitting, immune to movement as long as the default backstop remains the same