[SOLVED]OnLaserHit/OnHitByLaser

If you have problems installing or running Algodoo, have found a bug or need in-game help - this is it!

[SOLVED]OnLaserHit/OnHitByLaser

Postby Torn » Tue Sep 01, 2009 1:15 pm

Hi,

I've been trying to use OnLaserHit/OnHitByLaser, but neither seem to work. I used this code...

(e)=>{e.this.color = [0, 0, 0, 1]}


...in OnHitByLaser to change the target's colour, and it didn't do anything. I copied the script into the OnCollide text field and dropped an object on the target, and the colour changed fine! Does anyone know what's wrong? Is it a bug, or am I just missing something very obvious? :P

Thanks
Last edited by tatt61880 on Thu Nov 11, 2010 10:23 am, edited 1 time in total.
Reason: Solved!
Torn
 
Posts: 32
Joined: Tue Sep 01, 2009 8:06 am

Re: OnLaserHit/OnHitByLaser

Postby RicH » Tue Sep 01, 2009 1:20 pm

I think it's supposed to be e.geom.color or e.laser.color instead of e.this.color, I haven't messed with laser scripting for a long time, so it might have changed since then :P
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am

Re: OnLaserHit/OnHitByLaser

Postby Torn » Tue Sep 01, 2009 1:38 pm

Thanks! e.geom.color worked perfectly, and e.laser.color changed the colour of the laser - handy to know. Again, thank you!

Now I've got another question... does anyone know how to measure a laser? I can't time it since it's instantaneous, and the only other way I can think of is scripting the laser to shorten bit by bit until you don't get an OnLaserHit... but that is a bit beyond me. Does anyone know another way?
Torn
 
Posts: 32
Joined: Tue Sep 01, 2009 8:06 am

Re: OnLaserHit/OnHitByLaser

Postby Torpedo » Tue Sep 01, 2009 2:46 pm

Torn wrote:Thanks! e.geom.color worked perfectly, and e.laser.color changed the colour of the laser - handy to know. Again, thank you!

Now I've got another question... does anyone know how to measure a laser? I can't time it since it's instantaneous, and the only other way I can think of is scripting the laser to shorten bit by bit until you don't get an OnLaserHit... but that is a bit beyond me. Does anyone know another way?


I'm making a scene to do that, you need either a Kprobe style unit or another laser (im using another laser, i cant make probes proper to save my life) so i have one laser in my unit, which is taking the e.pos(0) and e.pos(1) of where it hits (which is a circle inside the unit infront of the laser) and a laser on the units outside fires at an object, then using some math you can work out the distance between the two objects.

hope that makes sense lol, i still dont know how to use the .math feature, so i'm not sure how im going to get the direct range yet, but i can get a co-ordinate output.
Image
User avatar
Torpedo
 
Posts: 120
Joined: Mon Aug 31, 2009 8:51 pm

Re: OnLaserHit/OnHitByLaser

Postby Torn » Tue Sep 01, 2009 3:01 pm

Torpedo wrote:
Torn wrote:Thanks! e.geom.color worked perfectly, and e.laser.color changed the colour of the laser - handy to know. Again, thank you!

Now I've got another question... does anyone know how to measure a laser? I can't time it since it's instantaneous, and the only other way I can think of is scripting the laser to shorten bit by bit until you don't get an OnLaserHit... but that is a bit beyond me. Does anyone know another way?


I'm making a scene to do that, you need either a Kprobe style unit or another laser (im using another laser, i cant make probes proper to save my life) so i have one laser in my unit, which is taking the e.pos(0) and e.pos(1) of where it hits (which is a circle inside the unit infront of the laser) and a laser on the units outside fires at an object, then using some math you can work out the distance between the two objects.

hope that makes sense lol, i still dont know how to use the .math feature, so i'm not sure how im going to get the direct range yet, but i can get a co-ordinate output.


0.o Yikes... I wouldn't have the faintest idea how to do any of that, I think I'll just stick to my limited little ways...
Torn
 
Posts: 32
Joined: Tue Sep 01, 2009 8:06 am

Re: OnLaserHit/OnHitByLaser

Postby Paradigm 29 » Tue Sep 01, 2009 4:31 pm

Image
Author: RaRaMalum
Title: Rangefinder
File Size: 11.79 kB
Rating: Image
ImageImage

It's been done for you.
Image
User avatar
Paradigm 29
 
Posts: 284
Joined: Tue Sep 01, 2009 12:06 am
Location: Houston, Tx


Return to Help / Bug reports

Who is online

Users browsing this forum: No registered users and 9 guests

cron