How to spawn an object from another object that spawns?

0 favourites
  • 10 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • The alldisks are created every random (1, 2) secs above and below the viewport and move at 90 or 180 degrees. . As you can see from the image, a starblue is spawned for every alldisk that is created. All that works correctly.

    For each starblue that is destroyed 1 is added to a globalvariable named StarBluecount.

    I'm trying to get it so that when random(50, 100) starblue is destroyed, it, or an a alldisks spawns a single stargold.

    I've tried using variations of event/actions to get the starblue or the alldisks to spawn the object, but no luck. The starblue will either not spawn anything or spawn a stargold for each starblue that is created. And the alldisks will either spawn all blue or gold.

    Been working on this for about 6 hours now, and the posts/ tutorials aren't close to what i need to do. If anyone can school me, it would be greatly appreciated.

  • Not real clear on what's happening, or how you are going about it. Are you jumping to a function, which loses which starblue is picked?

    Or you don't spawn until after the event, which also loses the picked Starblue?

  • How about you try separate event instead of the sub-event ?

  • kaveljo Paradox Thanks for the replies. Let me try to explain a bit better.

    I have 6 disks in the AllDisks Family --

    Small, Medium, Large that have bullet behavior and move with - bullet angle of motion 90 degrees. They are created out of sight just above the viewport every random(1,2)secs and move from top to bottom, where they are destroyed outside of layout.

    Small, Medium, Large that have bullet behavior and move with - bullet angle of motion 180 degrees. They are created out of sight just below the viewport every random(1,2)secs and move from bottom to top, where they are destroyed outside of layout.

    Each separate disk has its own event/action, since they each move at their own random speed, and are created at different intervals, as seen in the example image.

    For each AllDisks that is created, it spawns a single StarBlue.

    The user has to roll a ball around over the disks without falling off the edges and collect as many of the StarBlue as they can. On collision with the ball, each StarBlue is destroyed and counted.

    I'm trying to make it so that when the user has collected/destroyed a random number of StarBlue, a single StarGold is created/spawned on just 1 random AllDisks.

    For example: StarCount is equal/ greater than 100 > System choose(a random disk from the AllDisk family) - spawn 1 StarGold -- StarGold pin to the AllDisk that was created at image point 0.

    Or something like that. So, basically i need 1 StarGold to be created when the user has collected between 50-100 StarBlue. And have that StarGold be pinned to a random disk.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi jeffige!

    Maybe you should try using the Pick nth instance condition from System, with expression random. Something like :

    [quote:1dq95p3i]StarCount is equal/ greater than 100 AND Pick AllDisks instance (random(0, AllDisks.Count -1)) --> Spawn StarGold on AllDisks; Pin; etc...

  • Thanks for the reply

    I have no experience with the Nth instance expression, but i'll check it out.

    Again, thanks for the reply.

  • You're welcome, tell me if it worked out!

  • thanks for the help, but i decided that adding the Gold star was a bit too much and detracted from the gameplay.

  • No problem! Looking forward to see the game.

  • Can't see the image of the issue, it seems to be down for now, or has been removed, nonetheless from the description it could be an issue with

    [quote:1ifxryrr]Understand the picking of newly created/spawn instances since R101 - LINK

    The same delay applies to destroying instances as well, and picking a newly created instance in a sub-event just does not allow to pick it as the instance does not exists at the moment of the execution of the sub-event.

    A solution is to have the system action "Wait 0 second" that will skip a frame and execute the next action. And the next action should be a call to a function that picks the UID of the newly created instance (this UID exists in the current event) and actually the function is made of the actions of the sub-event.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)