How do I pick last object created?

0 favourites
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.
  • nimos100

    Thanks again man. Now I could finally understand what you mean. But the thing I can't see is how I would store de UID or retrieve it when I need it. I mean, until now i'm using the system condition "compare two values" when I need the game to know some global value. I'm still crawling around the expressions. I would guess that that's how you do it? Which the expressions?

    I don't know even the basics of logical programming... That must be the reason it gets so hard for me to communicate with you.

    Aaand is there anyway I could give you guys some prestige? Like an upvote or something.

    Sure no problem.

    You can store the UID in a global variable, "Pressing V" while not in an event and you just name this "Last_created_UID = 0" this can then be used to store any number you want.

    Since its global it means that its available to you from anywhere in the project. So when you need it you just do like this:

    Pick Object.UID = Last_created_UID
    "Compare two values" doesn't make the system know anything, its simply compares two values and you can use the result to trigger whatever you need to. But maybe that was what you meant? But more important which is a normal mistake new users make is that they think that compare two value picks something, so it results in bugs, normally in the sense that suddenly more objects do things, where they thought it was only the one they "Picked". But "Compare two values" simply compares two value nothing more. So you have to pick the correct objects to compare before hand or it will cause problems.  For instant:
    Compare Object.UID = Last_created_UID
    ----> Object.destroy
    This would destroy all Object and not only one.  So therefore you need to pick the correct Object first:
    Pick Object.UID = Last_created_UID
    Compare Object.type = "Rabbit"
    ----> Object.destroy
    Here you first Pick the object which UID is equal to the global variable "Last_created_UID" and if that Object have a type which is "Rabbit" it will be destroyed. 
    The reason I changed the compare to "Type" is because it doesn't really make sense to compare UID using "Compare two values" as it doesn't pick anything and because if "Pick Object.UID = Last_created_UID" is true you already know that they have the same value and you have already picked it. So when you pick something you are at the same time performing a comparison automatically.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • nimos100

    I think I'm getting to undestand this... Now I just need to practice more.

    There is still stuff that I dont quite get but I figured that I only need to work more. Just complaining and listening to you won't teach me all that I need to know.

    Thanks again nimos100. Now we can let this topic close by itself I guess...

    I wish someday I can help people like you and Asmodean help'd me. Or even help you and him on the next years.

    See you around

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