Spawning a circle then deleting it.
13 posts • Page 1 of 1
Spawning a circle then deleting it.
I want to make something spawn a circle and then the circle is erased in a second without the circle hitting anything, Is it possible?
-
Dadasas - Posts: 46
- Joined: Tue Sep 01, 2009 2:03 am
Re: Spawning a circle then deleting it.
- Code: Select all
(e) => { scene.addcircle({collideset := 0; airfrictionmult := NaN}) }
But you need air friction for it to work
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Spawning a circle then deleting it.
I want the circle to stay there for a second or more like 10 seconds, I don't want scene.my thing, I also want it possible to make more than one at the same time.
-
Dadasas - Posts: 46
- Joined: Tue Sep 01, 2009 2:03 am
Re: Spawning a circle then deleting it.
you can use the for(number of times you want to, (variable if you want to change something according to spawns)=>{script to be executed}) function(a looping structure) to avoid having to type everything tons of times.
for the time-limit, you might want to use a built-in variable, stored in the circle itself, and put on the density value something like that
{timetodeleteobject <= sim.time ? 0 : density of normal object}
also, i'm assuming you're using algodoo, as using density = 0 in A:PE can cause crashes.
for the time-limit, you might want to use a built-in variable, stored in the circle itself, and put on the density value something like that
{timetodeleteobject <= sim.time ? 0 : density of normal object}
also, i'm assuming you're using algodoo, as using density = 0 in A:PE can cause crashes.
Jrv wrote:TC42 wrote:Quite honestly, I didn't think anyone on 4chan has that good a use of grammar, spelling, usage, mechanics, ect.
But I've never been there, so I may be wrong.
GTFO newfgt
-
RA2lover - Posts: 607
- Joined: Mon Aug 31, 2009 8:43 pm
- Location: Brazil
Re: Spawning a circle then deleting it.
Hmm, So if I wanted to make it be deleted in 5 sim.time units after being spawned , how would I do that?
-
Dadasas - Posts: 46
- Joined: Tue Sep 01, 2009 2:03 am
Re: Spawning a circle then deleting it.
if you want to spawn an object before the last one gets deleted it can be a problem because the script will be deleted from the first object that was spawned.
If you want it to last 5 time units and if only one circle every 5 units is spawned this works:
But are you using phun or algodoo? This is important to know.
If you want it to last 5 time units and if only one circle every 5 units is spawned this works:
- Code: Select all
(e) => { scene.addcircle({spawntime := sim.time; density := {(sim.time - spawntime) > (5.0 / sim.frequency) ? {0} : {2.0}} }) }
But are you using phun or algodoo? This is important to know.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Spawning a circle then deleting it.
Algodoo. Thanks for all your help.
Last edited by Dadasas on Sat Dec 19, 2009 8:37 pm, edited 1 time in total.
-
Dadasas - Posts: 46
- Joined: Tue Sep 01, 2009 2:03 am
Re: Spawning a circle then deleting it.
Ok it will work then. Otherwise you'd have to use airfrictionmult = NaN instead of density = 0
try it. If it's too fast use a higher number than 5.0
And you really want to delete it after 5 time units and not 5 seconds or something like that?
try it. If it's too fast use a higher number than 5.0
And you really want to delete it after 5 time units and not 5 seconds or something like that?
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Spawning a circle then deleting it.
Okay , but why can it only spawn one at a time?
-
Dadasas - Posts: 46
- Joined: Tue Sep 01, 2009 2:03 am
Re: Spawning a circle then deleting it.
You can spawn more at a time but then only the last spawned will be deleted. the others will stay because once a new object is spawned before the last one is deleted the script gets deleted from the old one and only works for the new spawned object. i don't know why this happens. maybe a bug.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Spawning a circle then deleting it.
Hmm, well my problem is solved, Thanks everybody!
EDIT : One quick question, is it possible to make an if statement that ask if the other thing is water?
EDIT : One quick question, is it possible to make an if statement that ask if the other thing is water?
-
Dadasas - Posts: 46
- Joined: Tue Sep 01, 2009 2:03 am
Re: Spawning a circle then deleting it.
Yes - e.other + "" is how you work out what it is (I am not sure if I have spelt it right) - so this is the code -
You can also make it so it can recognise what type of geomitery the other thing is -
if it's a plane - e.other + "" equals "plane"
if it's a box - e.other + "" equals "box"
if it's a polygon - e.other + "" equals "polygon"
and so on - you get the idea
- Code: Select all
e.other + "" == "water" ? {What happens if it IS water} : {What happens if it ISN'T water}
You can also make it so it can recognise what type of geomitery the other thing is -
if it's a plane - e.other + "" equals "plane"
if it's a box - e.other + "" equals "box"
if it's a polygon - e.other + "" equals "polygon"
and so on - you get the idea
<-- Made with GIMP
-
blahblah200 - Posts: 61
- Joined: Tue Sep 01, 2009 11:33 am
- Location: Somewhere over the rainbow...
Re: Spawning a circle then deleting it.
No that doesn't work. I already tried it. I only know this kind of code for the normal geometries but not for water. I also tried "splash of water" but that doesn't work, too
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
13 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 24 guests