Script to make two circles appear on collide?
2 posts • Page 1 of 1
Script to make two circles appear on collide?
I would like to simulate a sort of nuclear chain reaction. My idea is to have a circle acting as the atom programmed with a certain script. Then, have another circle slightly smaller to act as the neutron. Upon collision between the neutron and atom, I want the atom to be deleted and I want two more neutrons to be made going off in different, random directions and velocities. Is this possible and if so, could you please explain how to make it so. Thanks.
- Gildon
- Posts: 4
- Joined: Thu Aug 15, 2013 10:17 am
Re: Script to make two circles appear on collide?
Bear in mind I'm clueless on nuclear reactions, but I'll try my best here! Does both the neutron and the atom get deleted?
First off, to delete the atom, simply set its density to 0, you can do this in either of the onCollide's.
If its in the atoms onCollide [the one being deleted] then the script would go:
If its in the neutons script then:
Then to execute the spawning of the two new neutrons, this is probably best done in the atoms script.
A simple way to spawn two of the same object is to do this:
Then, you can just select your neutron. press cntrl + c [copy], and in the middle of the two {}, press cntrl + v [paste]
So essentially it would look something like:
The number simply says how many of the same one you want spawned.
If they need to be different then you have to put the 'scene.addCircle' twice.
Kind of a bad explanation from me so fire away with questions
Hope this helps!!!
First off, to delete the atom, simply set its density to 0, you can do this in either of the onCollide's.
If its in the atoms onCollide [the one being deleted] then the script would go:
Spoiler: show
If its in the neutons script then:
Spoiler: show
Then to execute the spawning of the two new neutrons, this is probably best done in the atoms script.
A simple way to spawn two of the same object is to do this:
Spoiler: show
Then, you can just select your neutron. press cntrl + c [copy], and in the middle of the two {}, press cntrl + v [paste]
So essentially it would look something like:
Spoiler: show
The number simply says how many of the same one you want spawned.
If they need to be different then you have to put the 'scene.addCircle' twice.
Kind of a bad explanation from me so fire away with questions
Hope this helps!!!
- MrGlinzz
- Posts: 13
- Joined: Tue Mar 19, 2013 11:51 pm
2 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests



