How do I choose last created object?

0 favourites
  • 11 posts
From the Asset Store
Show your master of martial arts by killing all flies empty handedly!!!
  • This code doesn't work! The idea is as simple as possible: transfer data from personal variables to a new created object. I tried to do this through families, but apparently the application doesn't give a shit who I mean - and inside the family it simply refuses to see the newly created object.

    What to do? Smoked the entire forum, in the only example I need https://www.construct.net/en/forum/construct-2/how-do-i-18/create-new-instance-transfer-136136 - the link to the example does not work

  • construct.net/en/forum/construct-3/how-do-i-8/object-gets-spawned-object-160035 this also similar, but i cant figure out the Function thing.

  • Can you change the screenshot from russian? Although I can make a guess, you cannot pick created instances until the next tick. Because this all happens in sub events the instance may not exist yet, so you can wait for the next tick with system wait for previous actions or use separate events etc.

  • I did as requested in the next topic, but for some reason, objects are sometimes assigned a black color (0,0,0), which is the default for this sprite. I can’t figure out what it’s connected with and where the error is in this code.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How fast are cells spawning? You can use browser logging to determine the UID of the picked Cell and see if it's the correct one and also log the parameters being sent through to locate the error.

    edit : I see you used a text object for the params so you must know they are correct then check if the picked Cell is correct. You could use something better than last created which is to send the Cell's UID through as a parameter since you spawn it before and then pick Cell based on this UID within the function.

  • How fast are cells spawning? You can use browser logging to determine the UID of the picked Cell and see if it's the correct one and also log the parameters being sent through to locate the error.

    edit : I see you used a text object for the params so you must know they are correct then check if the picked Cell is correct. You could use something better than last created which is to send the Cell's UID through as a parameter since you spawn it before and then pick Cell based on this UID within the function.

    I don't quite understand you, I have no use for UIDs now - only a function. Other methods don't work, this one at least works 90% of the time. Cells spawn very quickly and independently of each other, and to be honest, I'm not sure how the function works and whether it can be executed multiple times at the same time.

    https://drive.google.com/file/d/11_nax6RJXo0rXkwuOmfr8bz_ZWsajG3b/view?usp=sharing - here is project

  • Problem is fixed by deleting original sprite from layout.

  • Basically with the function you're passing parameters through but could be assigning them to a different Cell than the one you spawned if you are spawning them fast. Since the Cell is already picked at the point of spawning you can set its value in the event above, no need for a function or second event at all, unless like I said you guarantee it is the correct one by picking by UID.

  • You can pick the last created item by picking the sprite with the highest IID value. Pick highest/lowest sprite.iid

    The most recently created sprite should have the highest iid value

  • I am very new, but I think maybe if you add a Wait 0 Seconds action after the Spawn action and before the Call Function action, it may be fixed.

  • Instead of calling a function, you can create a trigger event on "Cell" - Created, that way you don't need to know the UUI, waits, etc. it will always trigger when you create a cell.

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