I have a problem picking an object after creating it (by name)

0 favourites
  • 4 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Hi! I have a problem when picking an object after using "create object by name"... I'll describe the project a bit:

    I made a merge game where a "generator" creates icons and send them to a grid every time I click it. So far so good, I create the icons by name and use "Pick last icons_family(family) created".

    Now I made an enemy that can create Icons on a battlefield when it dies, but doesn't immediately send the icon to the grid. Those are the same icons on the same family, but it applies some changes (size, variables, etc) and wait for a click before sending them to the grid.

    This is how the function that creates the battlefield icons looks:

    At first it was working fine, but the game is fast-paced so I click the "generator" like crazy to get more grid icons. At some point, when a battlefield icon is created and I'm clicking the "generator", the grid icon gets in the middle of the code. I mean, the function creates a battlefield icon, but picks the last grid icon instead of the battlefield one, thus changing its size, position, etc.

    So my question is, there's a faster or more direct way of picking the newly created object (by name) than using "pick last created" ?

    I know if I create an object the regular way, I can immediately assign values and properties because it stays picked on creation. But when creating by name is not the case?

    Thanks in advance!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I mean, in order to sum up, it's working but when the game gets fast-paced it creates that bug. How do I make sure the "pick last created" is picking the right item, avoiding another one getting in the way?

  • I mean, the function creates a battlefield icon, but picks the last grid icon instead of the battlefield one, thus changing its size, position, etc.

    I doubt this is the case. If "Pick last created" condition goes immediately after "Create" action, then it should pick that created instance.

    Perhaps the function is called with an invalid objectName? In this case the Create action will not create anything, and "Pick last created" will indeed pick some previously created icon.

  • dop2000, you are indeed a genius. Again you pointed me to the right direction.

    What actually happened is I had a typo on an instanceVariable. Instead of typing "stick1" y wrote "stick12" and that object doesn't exist on the game.

    Thanks a million, I owe you a beer!

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