Best way to Spawn 100 objects in a Game Scene size 50,000 x 50,000

luke2125luke2125 Member, PRO Posts: 225

Hi,

What is the best method to spawn 100 objects in randomly x,y positions in a game scene of 50,000 x 50,000 ( width ), ( height ). I currently have a spawner that is set to spawn 100 objects, but it's not spawning them, please see below:

Every 0.2 Seconds Run to Completetion ( Checked )

Change Attribute : game.bubblekidsrandom To random (1,2 )

When All Attritube: game.bubblekidsrandomcounter < 100

Change Attritube: game.bubblekidsrandomcounter To game.bubblekidsrandomcounter + 1

When All Attribute: game.bubblekidsrandom = 1

Spawn Actor: bubblekid1 Layer: in front of actor
Direction 0 Relative to Scene
Position random (82, 49889 ) random ( 75,49907 ) Relative to Scene

When All Attribute: game.bubblekidsrandom = 2

Spawn Actor: bubblekid2 Layer: in front of actor
Direction 0 Relative to Scene
Position random (82, 49889 ) random ( 75,49907 ) Relative to Scene

Is there a limit of spawning depending on screen size? Any help would be greatly appreciated it....Thanks and God Bless...

Sincerely,

Sunday

Comments

  • RabidParrotRabidParrot Formally RabidParrot. Member Posts: 956

    Can you upload a screenshot?

  • luke2125luke2125 Member, PRO Posts: 225

    Hi RabidParrot,

    Please notice I have set for less < 10, but in actually, I'm looking to spawn 100 objects.....God Bless...

    Sincerely,

    Sunday

  • SocksSocks London, UK.Member Posts: 12,822

  • luke2125luke2125 Member, PRO Posts: 225

    Hi Socks,

    Will try that solution, and see if it works........Do you think, it may have to do with screen size and spawning random ( 82, 49899 ) ( min , max ). Maybe it's too much to process and place a random object between 82 - 49899? God Bless...

    Sincerely,

    Sunday

  • luke2125luke2125 Member, PRO Posts: 225

    Hi,

    Still cannot get to spawn 100 Objects, the thing is that I'm doing via Global Variable Spawn Actor, that I've placed on the scene, but not viewable, and still nothing. It's really somewhat annoying.....God Bless...

    Sincerely,

    Sunday

  • SocksSocks London, UK.Member Posts: 12,822

    @luke2125 said:
    Hi,

    Still cannot get to spawn 100 Objects, the thing is that I'm doing via Global Variable Spawn Actor, that I've placed on the scene, but not viewable, and still nothing. It's really somewhat annoying.....God Bless...

    Sincerely,

    Sunday

    I don't really know what 'via Global Variable Spawn Actor' means, but did you try my above suggestion ?

  • luke2125luke2125 Member, PRO Posts: 225

    Hi Socks,

    Thanks for responding....Yes, I've tried it, but it doesn't spawn. The way I have set it up is I have spawn actor code on the screen, that's supposed to spawn 100 enemies throughout a scene size of 50,000 x 50,000. I did it with a global variables, but it started spawning but then it just doesn't finish. Therefore I tried your method above, using self inside the spawn actor code ( variables = Count ( Integer ), X ( Integer ), but it just doesn't spawn. What do you think could be the issue? God Bless....

    Sincerely,

    Sunday

  • zweg25zweg25 Member Posts: 738

    Use socks code but don't use a timer use a loop. While self.count < 100 loop through (and remove the timer)

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @luke2125 Can you post a screenshot of the rule you're using that would be identical to @Socks'? And make sure it's not inside any other rule.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • luke2125luke2125 Member, PRO Posts: 225

    Hi Zweg25 and Tatiang,

    I think the issue lies within the spawn behavior, since I have in Position Set to Random ( 92, 50000 ) for X Position, and for Y Position = Random ( 74, 50000 ). However, if I changed the Max positions to 2048, it begins to spawn. Is this a bug in GameSalad? God Bless...

    Sincerely,

    Sunday

  • luke2125luke2125 Member, PRO Posts: 225

    Hi Tatiang,

    Please see below:

  • luke2125luke2125 Member, PRO Posts: 225

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    But that's totally different than what @Socks posted. Have you tried his exact rule?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • luke2125luke2125 Member, PRO Posts: 225

    Hi Tatiang,

    Yes, I've already tried the rule Socks posted........God Bless....

    Sincerely,

    Sunday

  • zweg25zweg25 Member Posts: 738

    You can't have if bubble kid == 2 in your rule of bubble kid == 1

    It will never be called

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2015

    Yes, I've tried it, but it doesn't spawn.

    Then you must have made a mistake when copying the code, it should work just fine.

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2015

    @tatiang said:
    Can you post a screenshot of the rule you're using that would be identical to Socks'?

    @luke2125 said:
    Please see below:

    Your code is completely different to mine, for example you have the timer as your first rule, so even if it successfully did its job and spawned 100 actors it would still be working away in the background of your game, unnecessarily draining processor resources - in the version I suggested the timer only triggers when it needs to.

    @luke2125 said:
    . . . it started spawning but then it just doesn't finish . . .

    Well it's hard to tell from your screenshot what is going on in your code as you've decided to keep most things hidden from view !? . . . . I make my attribute names short, (a single letter usually), when making screenshots for people, this takes a couple of seconds to do, otherwise with the end of an attribute name cut off you can't tell the difference between (for example) 'self.herofinalposition' and 'self.herofinalscore' and 'self.herofinishedlevel' . . . as they all will appear to say something like 'self.herofin...' and 'self.herofin...' and 'self.herofin...' - which makes it very difficult for people trying to help out.

    So, although I can't really tell what's going on, I'll make a couple of guesses . . . you have a rule that says when game.bubblekids (that's a guess it could say 'game.bubblekidsCount' for all I know) is less that 100 then do the following rules, you are also reseting game.bubblekids (again another guess at the attribute name) every half a second to a value of either 1 or 2, so game.bubblekids will never reach 100, in fact it will never get passed 2, so this code will spawn actors forever ("it just doesn't finish").

    You also have a rule that says when game.bubblekids = 1 then do the following rules, within that rule there is another rule that (again I'm guessing as you've kept this rule hidden) checks to see if game.bubblekids = 2, but the condition for running this rule, the one that checks whether game.bubblekids = 2 is that game.bubblekids must equal 1, so obviously the rule will never run.

  • luke2125luke2125 Member, PRO Posts: 225

    Hi Socks and Tatiang and others,

    Thanks for the insights, already fixed what Tatiang and zweg25, below is another screenshot:

    Moreover, yes the bubblekidsrandom = 1, is for the bubblekidsrandom attritube to choose between 2 Spawn Actors......change attritube bubblekidsrandom to random (1,2). Then of course the bubblekidsrandomcounter + 1. Socks, in your code what position do you have for spawning the actors ( x, y ) ? God Bless...

    Sincerely,

    Sunday

  • luke2125luke2125 Member, PRO Posts: 225

    Hi,

    Bump.....God Bless....

    Sincerely,

    Sunday

  • luke2125luke2125 Member, PRO Posts: 225

    Hi,

    I tried and place on the Spawning Position Y = random ( 82, 2048 ) and it spawns, however, I'm looking to spawn the objects randomly between 82 and 50,000 since 50,000 is my scene size. This is for a 2D Top Down game I'm creating.....Is this a bug with gamesalad, that it doesn't spawn objects beyond 2048? God Bless...

    Sincerely,

    Sunday

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Is this a bug with gamesalad, that it doesn't spawn objects beyond 2048?

    No. See attached demo.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • luke2125luke2125 Member, PRO Posts: 225

    Hi Tatiang,

    Thanks, will download and see if there's any difference from my code....God Bless...

    Sincerely,

    Sunday

  • noihcranoihcra Member, PRO Posts: 3

    Hi, I have a somehow similar problem. Mine is that actors stop being rendered on android, when they are placed far beyond 2911 pixels on Y axis. Actors are correctly spawn wherever, but are not drawn on screen when their own origin is beyond 2911 pixels on Y axis, or 1746 pixels on X axis. You can move actor during game far these limits. Once you get back into those limits, actor starts being rendered again. That limits me to a scene size of 1746 x 2911 pixels, a weird combination far away from any power of two.

  • FrantoFranto Member Posts: 779

    Is the actor spawner on a non-scrollable layer?

Sign In or Register to comment.