Delete an Object by modifying OnCollide
9 posts • Page 1 of 1
Delete an Object by modifying OnCollide
Hi,
Iam a scripting Noobie.
I was looking for a way to destroy/delete an object by using OnCollide.
I did find a way , on the net, and it involves setting density of the object to 0.(e.this.density =1.0) .This approach appears a bit contrived
Is there any other way?
Rgds
Narya
Iam a scripting Noobie.
I was looking for a way to destroy/delete an object by using OnCollide.
I did find a way , on the net, and it involves setting density of the object to 0.(e.this.density =1.0) .This approach appears a bit contrived
Is there any other way?
Rgds
Narya
- Narya
- Posts: 2
- Joined: Mon Jan 04, 2016 6:37 pm
Re: Delete an Object by modifying OnCollide
the legit way to do it:
Never use density = 0, it causes a memory leak as objects are set to an invalid state and not cleared from the memory.
- Code: Select all
scene.removeEntity(e.other)
Never use density = 0, it causes a memory leak as objects are set to an invalid state and not cleared from the memory.
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: Delete an Object by modifying OnCollide
scene.removeEntity(e.other) still causes a memory leak. It's a problem with algodoo, there is no way to delete an object and free memory . So setting density to 0 works just as well as any other type of "deleting".
-
homieeee - Posts: 14
- Joined: Thu Oct 09, 2014 2:13 am
Re: Delete an Object by modifying OnCollide
Density and removeEntity delete the objects in a nearly identical way, since algodoo can't clear memory properly, and the objects are in fact removed from the scene when they turn invalid by density or similar(exception is when having negative radius/size )
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: Delete an Object by modifying OnCollide
I may be wrong, I got the information from Electronicboy.
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: Delete an Object by modifying OnCollide
timetolive=0 is also an option, but using density=0 never had any negative effect for me
yup yup
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
- hiltropper
- Posts: 85
- Joined: Mon Dec 20, 2010 12:02 pm
- Location: Germany
Re: Delete an Object by modifying OnCollide
I usually take timetolive=0 nowadays since algodoo uses that itself, so it MUST be kinda legit? Well, usually you don't need to worry, since, if there ARE increased memory leak chances on one of the solutions, then you will still see it only after you deleted over about 1000 objects.
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: Delete an Object by modifying OnCollide
From my expirience, onCollide=(e)=>{}; timeToLive=0 is safest way to delete object.
Scene.removeEntity cause postStep event skip
Density=0 works well, but there was some negative effects like console warnings...
Scene.removeEntity cause postStep event skip
Density=0 works well, but there was some negative effects like console warnings...
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Delete an Object by modifying OnCollide
I believe you can also remove an object by setting it's inertiamultiplier to 0, but I usually use timetolive.
.
-
icrls984 - Posts: 80
- Joined: Thu Jun 13, 2013 6:33 am
9 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 9 guests