Deleting with lasers
6 posts • Page 1 of 1
Deleting with lasers
There is a certain object I want to be able to delete when it is hit by a laser. What scripting code would I use to do so?
I don't want anything else to be destroyed by the laser though, just one object.
I don't want anything else to be destroyed by the laser though, just one object.
-

tallman1996 - Posts: 13
- Joined: Mon Mar 22, 2010 10:16 pm
Re: Deleting with lasers
Not so difficult.
Laser:
onLaserHit = (e)=>{e.geom.materialName == "DeletableGeom" ? {Scene.RemoveEntity(e.geom)} : {}}
Geom:
materialName = "DeletableGeom";
== Explanation ==
You can use Ternary operation for conditional-branch.
With Thyme, ternary operation needs {}. i.e. condition ? {true case} : {false case} . (cf. 1.8.0 Thyme expression error)
e.geom is a geom which is hit by laser.
Laser:
onLaserHit = (e)=>{e.geom.materialName == "DeletableGeom" ? {Scene.RemoveEntity(e.geom)} : {}}
Geom:
materialName = "DeletableGeom";
== Explanation ==
You can use Ternary operation for conditional-branch.
With Thyme, ternary operation needs {}. i.e. condition ? {true case} : {false case} . (cf. 1.8.0 Thyme expression error)
e.geom is a geom which is hit by laser.
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-

tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: Deleting with lasers
Just like this:
onLaserHit:
onCollide/onHitByLaser:
So basically just make the density to 0 and the object will vanish.
onLaserHit:
- Code: Select all
(e)=>{e.other.density = 0}
onCollide/onHitByLaser:
- Code: Select all
(e)=>{density = 0}
So basically just make the density to 0 and the object will vanish.
- egkteam
- Posts: 91
- Joined: Mon May 21, 2012 3:49 pm
- Location: East Java, Indonesia
Re: Deleting with lasers
egk, in the newer algodoo version they made it so you can use
Scene.RemoveEntity(e.geom)
as a entity remover, this is more reliable then setting the density 0
Scene.RemoveEntity(e.geom)
as a entity remover, this is more reliable then setting the density 0
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
-

monstertje3 - Posts: 343
- Joined: Sat Sep 05, 2009 4:29 pm
- Location: N-H, NL
Re: Deleting with lasers
monstertje3 wrote:as a entity remover, this is more reliable then setting the density 0
Oh, is this true? ...jk
I also believe that Scene.RemoveEntity is more proper for deleting entity than density = 0 method.
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
-

tatt61880 - [Most Helpful Person 2010]
- Posts: 1150
- Joined: Mon Aug 31, 2009 5:45 pm
- Location: Tokyo, Japan
Re: Deleting with lasers
How do you use that using scene.my?
- egkteam
- Posts: 91
- Joined: Mon May 21, 2012 3:49 pm
- Location: East Java, Indonesia
6 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests



