Spawn without overlaps
Rumi
Member, PRO Posts: 343
Allright, here's my problem. I have my game set up where an actor spawns other actors. However, there is a weird glitch where two actors are spawned on top of each other, which I have tried to fix for the last day or so. However, I see a workaround. Is there anyway for the two spawned actor to become one. ie, there is a recognition that they are spawned on top of each other, one is destroyed so only one is left. I tried setting up a timer saying that after random(0.1,0) seconds, destroy itself if its overlapping or colliding with another actor of itself. I thought than one random number should be higher than the other, so one actor will destroy itself first and the other actor's timer will end. That just made both actors destroy themselves, which didn't work (I did not have run to completion checked). So do you guys have any ideas? I could do with the help.
BTW, I used gamesalad for two apps, a few years ago, and now I'm back and I have to say, GameSalad is even better and its really nice to see its progress.
BTW, I used gamesalad for two apps, a few years ago, and now I'm back and I have to say, GameSalad is even better and its really nice to see its progress.
Best Answer
-
grimmagelol Posts: 18I think i can answer this maybe its what u need.
Make a Integer Attribute called spawn column. Then make a timer.
Timer every .5 sec
Change attribute Game.spawn column to random (1, 5)
-this should take care of the picking of the column
Make 5 rules
In each rules add one attribute =.
Example of what it should look like
attribute Spawn column = 1
-Do section : Spawn actor block at X 100 Y 500
attribute Spawn column = 2
-Do section : Spawn actor block at X 150 Y 500
attribute Spawn column = 3
-Do section : Spawn actor block at X 200 Y 500
attribute Spawn column = 4
-Do section : Spawn actor block at X 250 Y 500
attribute Spawn column = 5
-Do section : Spawn actor block at X 300 Y 500
This works. they will not over lapse since only 1 block spawns at ever half second and each block falls in a different location on the x axis.
I tested it and its works smoothly. hope it helps
Answers
Hi @Rumi, one way is along the following lines: to have two real attributes for the spawned actor to put in its x and y location. Then if the next spawned is exactly the same location, random its location again. Hope I've explained that clearly enough.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
If overlap or collide with actor self, than change integer "spawn" to random(1,0)
If 1, destroy self and spawn self.
If 0, destroy self.
This way, there is a 25% chance that if there is a duplicate, they'll both self destruct, and a 75% chance that they'll spawn into oblivion until one self-destructs and spawns and the other destructs without spawning, leaving only one actor.
Damn! You are the latest victim of the answer=deletion forum bug . . . . and I wanted to take a look at your project too (the 'recursive spawner ' version) could you repost it ?.
. . . . . .
cut . . . . paste
@CodeWizard
@Codemonkey
@dgackey
There is an issue with the forum whereby a post accepted/marked as the 'answer' has its attachments deleted. Someone asks a question, it's often replied to in the form of a demo project, if the person asking the question accepts this response as the answer, the forum then dutifully deletes the attachment !
Of course the person asking the question got their answer, but the thread then becomes a little less useful to those in the future looking for answers to similar questions and the person taking the time to make the demo has their efforts erased and we end up with lots of . . . "Cheers for the demo, that solved the problem" and "Thanks, that's a much faster way of doing it" . . . but no actual file for people to look at, just a few orphaned clues . . . which kinda' defeats the point of attachments.
This has been going on for months now, there are workarounds (only posting the typed out code, using external file hosting sites) but the problem is that people always aren't aware of the issue, so just use the built in attachment link not knowing their efforts are often doomed , I know you've got a lot of your plate, but it'd be cool if there was an easy fix for this at some stage.
@Socks, I'll re-post them when I get home.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Here are two solutions: one that is a bit slower and uses a table and one that is very fast and uses a recursive spawner.
[Please do not click Yes to mark this post as answering the question.]
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Cheers, I'll take a look when I'm entirely sober (unlikely until 3-5 January 2014).
Love the "" in your tables titles, it makes things much easier to track (visually).
>-
Shift+option+k for the apple symbol.
Both files are pretty simplistic. It won't take you but a minute to see how they work.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User