Spawning at entityID?
8 posts • Page 1 of 1
Spawning at entityID?
Is there any way to spawn an object at another object, that has a changing position?
I've labelled the object that the newly spawned object will be spawned on "geom", in "materialName" of the script menu. I've tried
{...
pos = geom.pos
...}
and
{...
pos = geom
...}
and
{...
pos = [geom.pos[0], geom.pos[1]]
...}
and also
{...
pos = entityID.theentityidgoeshere
...}
But with no effective results.
Any ideas?
I've labelled the object that the newly spawned object will be spawned on "geom", in "materialName" of the script menu. I've tried
{...
pos = geom.pos
...}
and
{...
pos = geom
...}
and
{...
pos = [geom.pos[0], geom.pos[1]]
...}
and also
{...
pos = entityID.theentityidgoeshere
...}
But with no effective results.
Any ideas?
Phundementalism?
Ain't nobody got thyme fo dat.
Ain't nobody got thyme fo dat.
-

mold999 - Posts: 225
- Joined: Sun Jan 02, 2011 1:35 am
- Location: [176436, 3763234]
Re: Spawning at entityID?
you could do it the classic way and set a scene.my.var for the geom pos this will be the easiest way i think. you know how to do that i guess ?
yup yup
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
- hiltropper
- Posts: 85
- Joined: Mon Dec 20, 2010 12:02 pm
- Location: Germany
Re: Spawning at entityID?
if you put a laser on the movable object (attach it so it will always hit the object)
then in the laser(onlaserhit) something like
scene.my.pos=e.geom.pos;
then in your spawnscript
pos:=scene.my.pos
note:
geom-geom collision uses e.other and e.this
laser-geom uses e.laser(<== not sure about this one) and e.geom
then in the laser(onlaserhit) something like
scene.my.pos=e.geom.pos;
then in your spawnscript
pos:=scene.my.pos
note:
geom-geom collision uses e.other and e.this
laser-geom uses e.laser(<== not sure about this one) and e.geom
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: Spawning at entityID?
Last i checked the laser didn't count as "hitting" an object it was attached to. If I put a laser on a circle, it will go through the circle. This might not happen anymore, I've been away for a while.
Phundementalism?
Ain't nobody got thyme fo dat.
Ain't nobody got thyme fo dat.
-

mold999 - Posts: 225
- Joined: Sun Jan 02, 2011 1:35 am
- Location: [176436, 3763234]
Re: Spawning at entityID?
Is next scene what you would like to do?
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: Spawning at entityID?
Add the following to an onLaserHit event:
- Code: Select all
(e)=>{
scene.my.pos = (readable(e.geom)).pos;
sim.time - scene.my.oldTime > 1 ? {
Scene.addCircle({
pos := scene.my.pos;
radius := 0.062500000
});
scene.my.oldTime = sim.time
} : {}
}
- s_noonan
- Posts: 61
- Joined: Tue Mar 30, 2010 2:25 am
Re: Spawning at entityID?
tatt61880 wrote:Is next scene what you would like to do?
This will be an attempt to show you what I mean:
[] = Object 1
{} = Object 2
||-- = Laser
||----------------- []......................{}
and now it spawns object 1 in object 2's position
||----------------- []......................{}[]
And I want to be able to move object 2, and for this to still work.
Also, I'm a little confused about how readable comes into this?
Phundementalism?
Ain't nobody got thyme fo dat.
Ain't nobody got thyme fo dat.
-

mold999 - Posts: 225
- Joined: Sun Jan 02, 2011 1:35 am
- Location: [176436, 3763234]
Re: Spawning at entityID?
Initialize the following in the console:
Scene.my.theBox := 0;
Scene.my.oldTime := 0;
setup a laser,circle,box,laser like this:
||--------O..........[]--------||
code in left laser:
code in right laser:
Notes:
1. Readable is used for variables that can't be read directly.
2. scene.my.theBox is an object variable that contains all the properties of the box.
Regarding "And I want to be able to move object 2, and for this to still work.":
The code above will work if one or both objects are moving, but if you would like to control the exact position of the box, then you will probably need to use version 2.0.2 b15. If you move the box with the Controller, then the code above will still work.
Scene.my.theBox := 0;
Scene.my.oldTime := 0;
setup a laser,circle,box,laser like this:
||--------O..........[]--------||
code in left laser:
- Code: Select all
sim.time - scene.my.oldTime > 1 ? {
scene.my.oldTime = sim.time;
Scene.addCircle({
pos := (readable(scene.my.theBox)).pos;
color := e.geom.color;
radius := (readable(e.geom)).radius;
vel = [0.00000000, 0 - 1.0000000]
})
} : {}
code in right laser:
- Code: Select all
scene.my.theBox = e.geom;
scene.removeEntity(e.laser)
Notes:
1. Readable is used for variables that can't be read directly.
2. scene.my.theBox is an object variable that contains all the properties of the box.
Regarding "And I want to be able to move object 2, and for this to still work.":
The code above will work if one or both objects are moving, but if you would like to control the exact position of the box, then you will probably need to use version 2.0.2 b15. If you move the box with the Controller, then the code above will still work.
- s_noonan
- Posts: 61
- Joined: Tue Mar 30, 2010 2:25 am
8 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests




