[SOLVED] Change CollideSet with "OnHitByLaser"
11 posts • Page 1 of 1
[SOLVED] Change CollideSet with "OnHitByLaser"
Hi,
I would like to change the collideSet of my geometry after a laserhit.
I tried to test with :
OnHitByLaser = (e)=>{e.this.collideSet = 2}
but it didn't work ...
In the end, I would like to do :
- CollideSet = 9
- Laser hit -> CollideSet = 2
- Laser hit -> CollideSet = 9
- Laser hit -> CollideSet = 2
...
...etc
Thank you.
( Screen in attachment )
I would like to change the collideSet of my geometry after a laserhit.
I tried to test with :
OnHitByLaser = (e)=>{e.this.collideSet = 2}
but it didn't work ...
In the end, I would like to do :
- CollideSet = 9
- Laser hit -> CollideSet = 2
- Laser hit -> CollideSet = 9
- Laser hit -> CollideSet = 2
...
...etc
Thank you.
( Screen in attachment )
- Attachments
-
- Sans titre.jpg
- (66.38 KiB) Not downloaded yet
Last edited by nylan on Sat May 08, 2010 1:11 pm, edited 1 time in total.
- nylan
- Posts: 11
- Joined: Fri Apr 16, 2010 4:23 pm
Re: Change CollideSet with "OnHitByLaser"
In onLaserHit It's not "this" and "other". it's "geom" and "laser".
- Code: Select all
(e)=>{e.geom.collideSet}
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Change CollideSet with "OnHitByLaser"
For the 9 3 9 3 etc. you have to use an if-statement. This is the code for OnHitByLaser of the box
Or the "reversed" way:
- Code: Select all
(e)=>{e.geom.collideSet == 9 ? {e.geom.collideSet := 3}:{e.geom.collideSet := 9}}
Or the "reversed" way:
- Code: Select all
(e)=>{e.geom.collideSet == 3 ? {e.geom.collideSet := 9}:{e.geom.collideSet := 3}}
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
-
Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: Change CollideSet with "OnHitByLaser"
Hello,
Rideg, thank you for this, I'll know this know.
Matten, Thank you too, it's a nice script but the collision layer is switching too fast.
I used this script for a geometry, pointing a laser on it :
http://www.youtube.com/watch?v=iTcudAJ3714
I would like a "pause" before re-switch for about 2sec, is it possible ?
Thank you.
Rideg, thank you for this, I'll know this know.
Matten, Thank you too, it's a nice script but the collision layer is switching too fast.
I used this script for a geometry, pointing a laser on it :
http://www.youtube.com/watch?v=iTcudAJ3714
I would like a "pause" before re-switch for about 2sec, is it possible ?
Thank you.
- nylan
- Posts: 11
- Joined: Fri Apr 16, 2010 4:23 pm
Re: Change CollideSet with "OnHitByLaser"
That the collision script changes to fast is simple: the laser fires every sec. 10000 "beams" or something like that, so every 0.0001 sec. the script is executed. If you want to make a "wait" option the only thing I can think of is this:
Make a variable named something like scene.my.wait and give it the value (beams per sec.×the number of seconds wait). And put the following code into the box (onHitByLaser)
I think that you can find in the config the number of beams a laser fires per sec.
Edit I think I have found the beams per sec. In the config you can find a "maxfps" with the value 60. And a beam is fired every frame, so the value you have to give to scene.my.wait is 60×the number of sec.
Here the edit of the code (with 2 sec. waiting)
Don't forget to declare scene.my.wait in the console first! (with value 120!)
Make a variable named something like scene.my.wait and give it the value (beams per sec.×the number of seconds wait). And put the following code into the box (onHitByLaser)
- Code: Select all
(e)=>{scene.my.wait == 0 ? {e.geom.collideSet == 9 ? {e.geom.collideSet := 3}:{e.geom.collideSet := 9}; scene.my.wait := 20000}:{scene.my.wait := scene.my.wait - 1}}
I think that you can find in the config the number of beams a laser fires per sec.
Edit I think I have found the beams per sec. In the config you can find a "maxfps" with the value 60. And a beam is fired every frame, so the value you have to give to scene.my.wait is 60×the number of sec.
Here the edit of the code (with 2 sec. waiting)
- Code: Select all
(e)=>{scene.my.wait == 0 ? {e.geom.collideSet == 9 ? {e.geom.collideSet := 3}:{e.geom.collideSet := 9}; scene.my.wait := 120}:{scene.my.wait := scene.my.wait - 1}}
Don't forget to declare scene.my.wait in the console first! (with value 120!)
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
-
Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: Change CollideSet with "OnHitByLaser"
That's overcomplicated here's an easy way that i use almost every time I script. first you set the controllerAcc to 0. Then you type
- Code: Select all
(e)=>{
(sim.time - e.geom.controllerAcc) >= 2 ? {
e.geom.collideSet == 9 ? {e.geom.collideSet := 3} : {e.geom.collideSet := 9};
e.geom.controllerAcc = sim.time
} : {}
}
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Change CollideSet with "OnHitByLaser"
The way Rideg used is better, because in his code it really switches every 2 sec. I've tested my script and that isn't every 2 sec. (but if you want an interval that isn't in sec. you can use my method)
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
-
Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: Change CollideSet with "OnHitByLaser"
I tried yours Matten, it's working, and i can do a fine tune for this timer
Rideg, I think yours is good too bug i don't know how to set controllerAcc to 0
I'm a newbie in scripting
Rideg, I think yours is good too bug i don't know how to set controllerAcc to 0
I'm a newbie in scripting
- nylan
- Posts: 11
- Joined: Fri Apr 16, 2010 4:23 pm
Re: Change CollideSet with "OnHitByLaser"
Select an object click geometry controller and drag the bar to 0.
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Change CollideSet with "OnHitByLaser"
Damn I thought you were talking about other setting
Thank you again
Thank you again
- nylan
- Posts: 11
- Joined: Fri Apr 16, 2010 4:23 pm
11 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests