Spawning a large number of actors in a pattern

BagzliBagzli Member, PRO Posts: 48
edited August 2015 in Working with GS (PC)

Hello,

I am trying to spawn a large number of actors in a pattern that would allow an object to move in between the spawned actors without colliding. Here are my thoughts.

Look at the image below, there are 9 tracks, Each track is a star. An object is going to spawn on each track and move all the way to the right and then destroy itself. I have tried to show that with the bracket and dashes. X means it gets destroyed there.

Now each track will have these mobs spawning every 1 second. Now Imagine an invisible objects starts at the top most star and starts moving down to the last start and then back up and back down, etc... it never stops. The condition is if the star is touching the object then it will not spawn any actors. This way a path gets generated that would allow the user to cross to the left side.

This is an idea that I had how to make random paths because that object that is going up and down will be moving an uknown number of spaces up and down (random basically).


| * () -----------------------x |
| * () -----------------------x |
| * () -----------------------x |
| * () -----------------------x |
| * () -----------------------x |
| * () -----------------------x |
| * () -----------------------x |
| * () -----------------------x |

| * () -----------------------x |

With me so far? I really hope so...

The problem that I am facing is that I have about 6-7 stars spawning actors every 1 second and then the last 2-3 stars never do. They are run by exactly the same code, they have exactly the same variables. I am not using a timer, I am using a function such as this:

If 0.05 > (self.time - 1) % 1 ---For more details on how this works look at the "Timers are for chumps" thread on gamesalad, but essentially it will occur every 1 second.

My question is does anyone has any idea why only few stars would spawn or do you maybe have a better idea of how I can accomplish my task?

Comments

  • ArmellineArmelline Member, PRO Posts: 5,351

    Trying to spawn lots of anything at once will always result in problems. When you have 10 actors all say to spawn an actor every, for example, 1 second, when that 1 second comes around each actor will be doing the spawn one after the other. They'll do them very quickly one after the other, but there will still be a delay from one to the next. Between two actors that display will not be very noticeable, but between the first and the 10th, it'll be much more prominent.

    You can partly avoid this by doing all the spawning in one actor. I've found an actor can comfortably spawn about 10 things at once without a very noticeable delay in the time between the first spawning and the 10th spawning. You can easily turn spawns on or off without needing to resort to another actor too.

    If I've understood you correctly, this demo does roughly what you're asking? I just used a timer to save time but you can substitute the more accurate method you mention.

  • BagzliBagzli Member, PRO Posts: 48

    Thank you,

    the problem with spawning all from a single actor is that generating a path is much more difficult, do you have any ideas on that?

  • ArmellineArmelline Member, PRO Posts: 5,351

    What kind of path do you want? Anything you can do with an actor moving up or down you can do moving a number up or down.

  • BagzliBagzli Member, PRO Posts: 48

    honestly I'm looking to generate a random path, The actor moving up and down was just an idea I had and it works. If you have a better way of accomplishing this I would love to hear it.

  • ArmellineArmelline Member, PRO Posts: 5,351

    The example I provided has the option of a random path. In what way did you want it different?

  • BagzliBagzli Member, PRO Posts: 48

    Hey,

    I didn't get a chance to review your example till today. I see that by default there is a path in your example, however when I turn the "Up and Down" method on the path disappears.

    I'm trying to understand what "Up and Down" does, but having a bit of a brain freeze, could you explain?

  • ArmellineArmelline Member, PRO Posts: 5,351

    There are two behaviours - "Random one up one down" and "Up and down". Turn on one or the other to see the two types of path. "Random one up one down" does what you've said so far, but if you want something different you'll need to explain quite how.

  • BagzliBagzli Member, PRO Posts: 48
    edited August 2015

    @Armelline you have the right idea, I just tested both ways and yes you have it right how I want it. The only change I need to make is that I need to make sure that it will travel at the most up line at least once every lets say 15 seconds and that it will hit the most bottom one at least once every 30 seconds..

    Think of top as the entry point and bottom as the exit point. I got to allow the user to come in and out without wait for too long.\

    That is with the random pattern, if not then I need to use the linear pattern (less fun in my opinion)

  • BagzliBagzli Member, PRO Posts: 48

    @Armelline

    I just ran this on my phone, I ran your demo and my own version based of your demo, both version tend to lagg on the phone. Basically whenever a wave is about to spawn, there is a very short pause making it look very glitchy, any way to get around this?

  • ArmellineArmelline Member, PRO Posts: 5,351
    edited August 2015

    @Bagzli said:
    Armelline

    I just ran this on my phone, I ran your demo and my own version based of your demo, both version tend to lagg on the phone. Basically whenever a wave is about to spawn, there is a very short pause making it look very glitchy, any way to get around this?

    I don't think so. As I said, spawning 10 actors at once is really not recommended.

    You'd be better off pre-placing the actors and then hiding/showing enabling/disabling them on demand, rather than trying to constantly spawn them.

  • BagzliBagzli Member, PRO Posts: 48

    I was just testing and about 3 actors at a time seems to work ok. I was going to try and spawn them in 3 waves and then when 3 waves are spawned make them visible and start moving them. See if that can work.

  • BagzliBagzli Member, PRO Posts: 48

    so I ended up putting actors on the map and then instead of creating/destroying I am teleporting them to start point. This seems to work the best. The only issues with this is because I have so many actors, gamesalad crashes every 10 minutes which is quite annoying.

Sign In or Register to comment.