HELP! PLEASE!
10 posts • Page 1 of 1
HELP! PLEASE!
How do you script an object like a circle so when it collides with another object, it clones itself?
- crytek
- Posts: 355
- Joined: Mon Aug 31, 2009 9:55 pm
Re: HELP! PLEASE!
np, just write an onCollide event with circle spawning and set onCollide := e.this.onCollide in new circle for replication...
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: HELP! PLEASE!
I don't know how to do object spawning. Please give me the exact script.
- crytek
- Posts: 355
- Joined: Mon Aug 31, 2009 9:55 pm
Re: HELP! PLEASE!
scene.addcircle({pos := [0,0]; radius := 1; color := [1,1,1,1]})
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: HELP! PLEASE!
Kilinich wrote:scene.addcircle({pos := [0,0]; radius := 1; color := [1,1,1,1]})
Thanks! But it doesn't really clone the object. It just makes another circle. I want a script that can clone any object on collide.
- crytek
- Posts: 355
- Joined: Mon Aug 31, 2009 9:55 pm
Re: HELP! PLEASE!
({controllerAcc == 11}) ? {
e.this.radius := 0;
controllerAcc = 10.9;
app.step;
app.undo
} : {
Scene.addCircle ({
collideSet := collideSet
opaqueBorders := opaqueBorders;
textureMatrix := textureMatrix;
drawCake := drawCake
density := density
pos := pos;
radius := radius;
color := color;
drawBorder := drawBorder;
angle := angle
})
}
I hope you get the idea. There are other things that you can copy to your clone, but I don't need to put them all. Just add the ones in that you need (if you see the pattern). Also, this spawns your clone on top of you original. If you want it somewhere else, just change pos := pos to pos := [x,y]
e.this.radius := 0;
controllerAcc = 10.9;
app.step;
app.undo
} : {
Scene.addCircle ({
collideSet := collideSet
opaqueBorders := opaqueBorders;
textureMatrix := textureMatrix;
drawCake := drawCake
density := density
pos := pos;
radius := radius;
color := color;
drawBorder := drawBorder;
angle := angle
})
}
I hope you get the idea. There are other things that you can copy to your clone, but I don't need to put them all. Just add the ones in that you need (if you see the pattern). Also, this spawns your clone on top of you original. If you want it somewhere else, just change pos := pos to pos := [x,y]

-

Paradigm 29 - Posts: 284
- Joined: Tue Sep 01, 2009 12:06 am
- Location: Houston, Tx
Re: HELP! PLEASE!
the script doesn't even work... When I put the script into the onCollide menu, it turns red. And yes I placed it between the parenthesis.
- crytek
- Posts: 355
- Joined: Mon Aug 31, 2009 9:55 pm
Re: HELP! PLEASE!
{controllerAcc == 11} ? {
e.this.radius := 0;
controllerAcc = 10.9;
app.step;
app.undo
} : {
Scene.addCircle({
collideSet := collideSet;
opaqueBorders := opaqueBorders;
textureMatrix := textureMatrix;
drawCake := drawCake;
density := density;
pos := pos;
radius := radius;
color := color;
drawBorder := drawBorder;
angle := angle
})
}
e.this.radius := 0;
controllerAcc = 10.9;
app.step;
app.undo
} : {
Scene.addCircle({
collideSet := collideSet;
opaqueBorders := opaqueBorders;
textureMatrix := textureMatrix;
drawCake := drawCake;
density := density;
pos := pos;
radius := radius;
color := color;
drawBorder := drawBorder;
angle := angle
})
}

-

Paradigm 29 - Posts: 284
- Joined: Tue Sep 01, 2009 12:06 am
- Location: Houston, Tx
Re: HELP! PLEASE!
crytek wrote:the script doesn't even work... When I put the script into the onCollide menu, it turns red. And yes I placed it between the parenthesis.
Well, there's a good reason for that (you can probably quite easily see yourself if you look).
If not, it was the semicolons, missing e.this.* and e.* (depending on whether you want the circles to be in the same place or not, it may be e.this.pos or e.pos (respectively) instead of e.pos), nonetheless, you should very easily be able to understand what's going on there (why App.step; App.undo happens you may not be clear on, but the rest you should) and the missing redeclaration of the e.this.angle identifier.
- Code: Select all
(e)=>{
({controllerAcc == 11}) ? {
e.this.radius := 0;
e.this.angle := 0;
controllerAcc = 10.9;
app.step;
app.undo
} : {
Scene.addCircle({
collideSet := e.this.collideSet;
opaqueBorders := e.this.opaqueBorders;
textureMatrix := e.this.textureMatrix;
drawCake := e.this.drawCake;
density := e.this.density;
pos := e.pos;
radius := e.this.radius;
color := e.this.color;
drawBorder := e.this.drawBorder;
angle := e.this.angle
})
}
}
If you don't understand how it works, you can go to [Thyme] New Method to see.
While I was writing this, Paradigm posted, his code still has a few errors, so this one should be better, also, I'd heard someone say New Method didn't work anymore, but it seems that it does, that's good news
- gradyfitz
- Posts: 174
- Joined: Tue Sep 01, 2009 8:33 am
- Location: Victoria, Australia
10 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 8 guests



