How do I select the last object created? [SOLVED]

0 favourites
  • 4 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • For example, say I have a block and I have a System event that creates a new block. How can I select only this newest created block and move its location without moving the last one created? I can elaborate more if needed.

  • When objects are created, they are immediately picked by default, so any actions you have affecting this object only affects the newly created instance within the same event.

    A more advanced topic would be if you wanted to specify only the last created instance of an object in an expression - you can do this with the IID - Sprite(-1).Expression, where the -1 represents the last created instance of this object. https://www.scirra.com/manual/78/expressions

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:2d2iu0vo] A more advanced topic would be if you wanted to specify only the last created instance of an object in an expression - you can do this with the IID - Sprite(-1).Expression, where the -1 represents the last created instance of this object. https://www.scirra.com/manual/78/expressions

    This worked beautifully. Thank you!

  • Already solved, but may I suggest UID instead of IID? UID is more reliable, and never changes unlike IID.

    Have a global variable, and set it's value to the following, right after you spawn a new object (when you tell the game to):

    int(ObjectName.UID)

    Then in conditions that require to be instance specific (such as lifting a pot in Zelda), you set a pick UID condition, except set it to the global variable name.

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