What's wrong with my script?
3 posts • Page 1 of 1
What's wrong with my script?
Hello. I'm trying to make a random xPos spawner. It should spawn circles at different positions within a range between [1.0, y] and [5.0, y]. I can't find what's wrong. Maybe I'm just tired and it's obvious. But anyway I'd really appriciate if I got this solved.
Thank you.
Thank you.
- Code: Select all
(e)=>{
sim.time - e.geom.controllerAcc >= 0.3 ? {
Artillery = scene.addCircle({radius := 0.5});
randomPos = (Artillery.color(0) * ((5) - (1)) + (1));
Artillery.pos = [randomPos, 1.0];
e.geom.controllerAcc = sim.time
} : {}
}
-

Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: What's wrong with my script?
You can't change pos of already spawned geom.
Use something like that (I didn't test it but you got the idea).
Use something like that (I didn't test it but you got the idea).
- Code: Select all
(e)=>{
sim.time - e.geom.controllerAcc >= 0.3 ? {
randomPos := 1 + ((sim.time * 7) % 1) * 4;
scene.addCircle({
radius := 0.5;
pos = [randomPos, 1.0]
});
e.geom.controllerAcc = sim.time
} : {}
}
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: What's wrong with my script?
looks good. I'll try it when I get back home. I'm going out of town now.
Does it spawn a ball at a random position between 1 and 5?
Does it spawn a ball at a random position between 1 and 5?
-

Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests




