## Lasers

### Lasers

I have no clue how the lasers work, with all the scripts, can somebody make a small tutorial for the lasers? like what you can do with the maxrays, and stuff like that, and how you can calculate a distance with the lasers, i can't find anything to measure with inside the lasers. I tried to measure the maxrays, and fadedist, but that's a static number

Tnx

Jelmerholland

Posts: 61
Joined: Mon Aug 31, 2009 7:51 pm
Location: NL

### Re: Lasers

according to some scenes i've seen I think it's like how the app.mousepos variable works, because there are 2 positions on the imaginary grid in algodoo that are being created with lasers and/or oncollide, and then math does the rest in terms of how far the two coordinates are from each other. There's also the extremely simple way to read distance, with multiple lasers at different fadedistances, but that is not perfect and can fill up fast. Those latter choices are mostly for using simple distances with a few lengths measured.
"THE BEST 2 PLAYER SCENE EVER MADE!!!" - ianno
http://www.algodoo.com/algobox/details.php?id=24204

Ian151

Posts: 47
Joined: Tue Sep 01, 2009 12:02 am

### Re: Lasers

And how do u get the laserpos?
smth like laser.pos? app.mousepos, so app.laserpos? but that won't work, becuz you have more lasers, and what's the poscode for the touchingdistance? I can do the math myself, but i need those 2 codes

Jelmerholland

Posts: 61
Joined: Mon Aug 31, 2009 7:51 pm
Location: NL

### Re: Lasers

To get the position of the laser hit it would be e.geom.pos

standardtoaster

Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

### Re: Lasers

Doesn't work, when i do this:

-Define variables
Scene.my.laser = [0,0] or Scene.my.laser = 0
Scene.my.geom = [0,0] or Scene.my.geom = 0

-Change it
Scene.my.laser = e.laser.pos;
Scene.my.geom = e.geom.pos

I putted these codes in the laser collision line.

Tnx

Jelmerholland

Posts: 61
Joined: Mon Aug 31, 2009 7:51 pm
Location: NL

### Re: Lasers

Sorry, it is actually e.pos not e.geom.pos

standardtoaster

Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

### Re: Lasers

but thats the pos of the geom? or the laser?
And what's the pos of the laser if that's the geom? becuz you will need both i guess?

Jelmerholland

Posts: 61
Joined: Mon Aug 31, 2009 7:51 pm
Location: NL