Spawning help
20 posts • Page 1 of 1
Spawning help
I wanted to spawn a circle on collision that was slightly transparent and of Grey color and would fly in the sky.
I used the following code :
But when I play the scene, the circles fall down rather than float up (as they should since they have such a low density.)
Please help
I used the following code :
- Code: Select all
(e)=>{
scene.my.addcircle({
pos := e.pos;
density := 0.0001;
color := [0.27, 0.24567446, 0.19845001, 0.645];
radius := 0.01;
collideSet := 64;
collideWater := false;
drawCake := false
})
}
But when I play the scene, the circles fall down rather than float up (as they should since they have such a low density.)
Please help
- Nisheeth
- Posts: 99
- Joined: Thu Mar 31, 2011 11:15 am
Re: Spawning help
Ah. Thanks. It worked. By the way is there a way to make those circles spread out after they spawn rather than go in a straight line?
Thanks in advance.
Thanks in advance.
- Nisheeth
- Posts: 99
- Joined: Thu Mar 31, 2011 11:15 am
Re: Spawning help
Try the following:
Make sure Air is turned on. You may need to expand the menu with Play/Pause, Undo, and Redo.
Make the density := 0.001. This, I think, is the smallest positive number Algodoo will accept in that field.
If this causes the circles to float too slowly for you, try adding this bit of code to the spawning code:
This will have the effect of making the circles thinner, so air friction has less effect. And the circles will float faster. The lower the number, the faster it will float.
Note: I started typing the above before I saw Kilinich's post.
As for making them go in different directions, try either setting vel to a random function (Kilinich can show you one). Or, spawn two circles by doubling the code-
And for random velocity, use
Make sure Air is turned on. You may need to expand the menu with Play/Pause, Undo, and Redo.
Make the density := 0.001. This, I think, is the smallest positive number Algodoo will accept in that field.
If this causes the circles to float too slowly for you, try adding this bit of code to the spawning code:
- Code: Select all
airFrictionMult = 0.01
This will have the effect of making the circles thinner, so air friction has less effect. And the circles will float faster. The lower the number, the faster it will float.
Note: I started typing the above before I saw Kilinich's post.
As for making them go in different directions, try either setting vel to a random function (Kilinich can show you one). Or, spawn two circles by doubling the code-
- Code: Select all
scene.addCircle ({ blahblah});
scene.addCircle ({blahblah})
And for random velocity, use
- Code: Select all
vel := [scene.my.rnd, scene.my.rnd]
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Spawning help
Umm... SE, I think you have to define the scene.my.rnd function before you can use it. 
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Spawning help
Nisheeth wrote:Ah. Thanks. It worked. By the way is there a way to make those circles spread out after they spawn rather than go in a straight line?
Thanks in advance.
set initial speed to "flow" spawned circles
vel := [sin(time),0]
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: Spawning help
Could you please explain it? I didn't understand it. I have just started using thyme.
- Nisheeth
- Posts: 99
- Joined: Thu Mar 31, 2011 11:15 am
Re: Spawning help
vel is initial velocity [Vx,Vy]
sin(time) is just a function that set velocity depends on simulation time. You can use any function here.
sin(time) is just a function that set velocity depends on simulation time. You can use any function here.
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: Spawning help
It didn't workout for some reason. I put it in the scene.addcircle.
It was:
By the way I wanted to simulate dense smoke.
It was:
- Code: Select all
(e)=>{
scene.my.addcircle({
pos := e.pos;
density := 0.001;
color := [0.27, 0.24567446, 0.19845001, 0.645];
radius := 0.03;
collideSet := 64;
collideWater := false;
drawCake := false;
vel := [sin(time), 0]
})
By the way I wanted to simulate dense smoke.
- Nisheeth
- Posts: 99
- Joined: Thu Mar 31, 2011 11:15 am
Re: Spawning help
@TC42: I knew that.
Try vel := [math.sin(sim.time), 0].
And for dense smoke, you probably want to set collideSet := 0 and use "random" velocity. And low airFrictionMult.
Or perhaps collideSet := 64;
heteroCollide = true.
Try vel := [math.sin(sim.time), 0].
And for dense smoke, you probably want to set collideSet := 0 and use "random" velocity. And low airFrictionMult.
Or perhaps collideSet := 64;
heteroCollide = true.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Spawning help
Is there a way to set a timer so that after a set amount of time it falls down rather than go up?
- Nisheeth
- Posts: 99
- Joined: Thu Mar 31, 2011 11:15 am
Re: Spawning help
Umm... Spawn a laser on the circle that gradually increases e.geom.density over time?
Try this:
It spawns circles significantly bigger than the original circles, but in such a way as to make it actually look like dense fog. Every single circle also has a small laser attached. However, I have not figured out how to make it actually change density more than once.
Try this:
- Code: Select all
scene.addCircle({
geomID := 3141;
pos := e.pos;
airFrictionMult := 0.1;
density := 0.001;
color := [0.27, 0.24567446, 0.19845001, 0.645];
radius := 1.0;
collideSet := 64;
collideWater := false;
heteroCollide = true;
drawCake := false;
onHitByLaser := (e)=>{};
vel := [(math.sin(sim.time * 100)) * 10, 0]
});
scene.addLaserPen({
pos := e.pos;
geom := 3141;
maxRays := 1;
collideSet := 64;
onLaserHit := (e)=>{};
size := 0.3
})
It spawns circles significantly bigger than the original circles, but in such a way as to make it actually look like dense fog. Every single circle also has a small laser attached. However, I have not figured out how to make it actually change density more than once.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Spawning help
Thanks. Its now behaving like smoke. But it is not dense. I was making a volcano. No the smoke was the one that accompanied the eruption. It is dense enough to fall down after the force that threw it up dies out. So it is supposed to be thick smoke, but it is too thin smoke.
By the way I did try using the code multiple times (as you suggested before). But apparently there was no effect.
By the way I did try using the code multiple times (as you suggested before). But apparently there was no effect.
- Nisheeth
- Posts: 99
- Joined: Thu Mar 31, 2011 11:15 am
Re: Spawning help
I added to that code (the scene.addCircle part) a bit that makes the circles not collide with each other. That's what heteroCollide does. If you want something more volcanic ash-like, try this:
This will spawn the circles with a constant upward velocity (I think) and they will be a bit denser than air.
If they spawn moving downward, change the vel(1) from 50 to -50.
- Code: Select all
scene.addCircle({
pos := e.pos;
airFrictionMult := 0.1;
density := 0.011;
color := [0.27, 0.24567446, 0.19845001, 0.645];
radius := 1.0;
collideSet := 64;
collideWater := false;
heteroCollide = true;
drawCake := false;
onHitByLaser := (e)=>{};
vel := [(math.sin(sim.time * 100)) * 10, 50]
})
This will spawn the circles with a constant upward velocity (I think) and they will be a bit denser than air.
If they spawn moving downward, change the vel(1) from 50 to -50.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Spawning help
It worked. Thanks. Just one final problem. They are too large for my scene, actually larger than my volcano!
I tried reducing the radius to 0.3 (the correct size), but it didn't seem like smoke any more. I couldn't increase the size of the Volcano as well because it was using large amounts of water in a small place to cause the eruption.
I tried reducing the radius to 0.3 (the correct size), but it didn't seem like smoke any more. I couldn't increase the size of the Volcano as well because it was using large amounts of water in a small place to cause the eruption.
- Nisheeth
- Posts: 99
- Joined: Thu Mar 31, 2011 11:15 am
Re: Spawning help
Decrease the velocities.
Try vel := [(math.sin(sim.time * 100)) * 3, 15]
This should be correctly scaled.
On the other hand, I think you will really like this. I figured out how to change density over time.
Try vel := [(math.sin(sim.time * 100)) * 3, 15]
This should be correctly scaled.
On the other hand, I think you will really like this. I figured out how to change density over time.
- Code: Select all
scene.addCircle({
geomID := 3141;
pos := e.pos;
airFrictionMult := 0.1;
density := 0.001;
color := [0.27, 0.24567446, 0.19845001, 0.645];
radius := 0.3;
collideSet := 64;
collideWater := false;
heteroCollide = true;
drawCake := false;
onHitByLaser := (e)=>{e.geom.density = e.geom.density + 0.0003};
vel := [(math.sin(sim.time * 124)) * 3, 0]
});
scene.addLaserPen({
pos := e.pos;
geom := 3141;
maxRays := 1;
collideSet := 64;
onLaserHit := (e)=>{};
size := 0.03
})
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Spawning help
Thanks a lot It worked perfectly. But what did you do to increase its density?
And here is the volcano I had been making:
And here is the volcano I had been making:
- Nisheeth
- Posts: 99
- Joined: Thu Mar 31, 2011 11:15 am
Re: Spawning help
The density increasing code is in the circle's onLaserHit. Or is it onHitByLaser? I can't remember.... It's onHitByLaser.
And I made some tweaks on the volcano:
Very interesting using tracers to thicken smoke without lag.
And I made some tweaks on the volcano:
Very interesting using tracers to thicken smoke without lag.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Spawning help
What didn't you understand?
Basically the codes here create the smoke from the volcano, that will go to a height and then begin to fall down.
Basically the codes here create the smoke from the volcano, that will go to a height and then begin to fall down.
- Nisheeth
- Posts: 99
- Joined: Thu Mar 31, 2011 11:15 am
Re: Spawning help
Who didn't understand what?
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
20 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests





