How do I Pick up ONLY one item

0 favourites
  • 9 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.
  • G'day Ya'll,

    I'm making a side scroller platform game, and my Player has to pick up and move a few items. When his is on contact with the item, and the player presses "Space," He can pick up each item independently, carry it above his head, and drop it where he needs to. The problem is IF there are two items stacked on top of each other already -- say a basket and a log -- The character picks up both at once, and holds both above his head.

    I'm trying to get it to choose between them, i dont care which is first. I've got the rough idea of families, but can't execute it properly. I've seen another tutorial and picking nearest using "Touch," but my game isn't a touch game, and i can't seem to wrap my mind around how i would compare those ideas. Any Ideas?

  • In your "Space is pressed" to pick up event add a condition "Family : pick top instance" or "Pick random instance" making sure you are checking if the player is overlapping or near the specific instances.

    At worst, post/attach your capx, it will make it easier to help you.

  • Wow... was not expecting a reply so fast. thanks.

    I think i've backed myself into a circle and I cant see where I can get out of it. I was trying to do the Pick up objects independently, destroying them and respawning them where I wanted (as a different Tut) had explained.

    then just upgraded. and tried to mess with some Instance Variables... but cant quite do it.

    I get the feeling i'm going to have to recode the stuff which is fine. any help is good help

  • See attached capx.

  • <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> Thank you very much... Legend. I think i would have been going around in circle and never gotten it.

    I'm not familiar with function / UID features and will read up on it.

    I'm sure you're hugely busy being a champion and all.. but if you have any opportunity to explain anything you did/your thought process/any other tutorials you've done that explain it.

    I want to make sure I understand it and not just rely on the generosity of others.

    All good if not <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    For anyone else that might have this same issue, right now i'm looking at:

    https://www.scirra.com/tutorials/361/un ... moke-trail

    https://www.scirra.com/tutorials/556/un ... o-families

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The idea there was to "refactor" a bit what you did.

    What you want is to have a single event that handles the fact that you are picking up an object from the family that contains all the object types.

    You then pick only the instance that has the highest priority (the instance variable you used).

    This is kind of an "input event". The player presses space, overlaps at least a "carryable" object and is not carrying an object at the time. So the intent is to carry the object.

    You send the UID (unique identifier) of the picked instance to the function, and the function deals with destroying/spawning the correct type of object.

    To do so, I added another family instance variable "type" that allows you to specify what object type is actually picked/passed to the function through the UID.

    Notice also that when you are picking an object, after you set the bear boolean "logcarry" or "basketcarry", you also do set "carry" to true, so that it will render the "input event" false and won't execute it again since the bear is carrying an object.

    That's about the "only" modification I made, just cleaning and grouping the events so that it makes hopefully sense.

    For UID you can read about it in the manual (search UID keyword) and check out the discussions noted down in the "How do I FAQ" in the section "Picking/selecting instance(s)" section.

  • Sweet! Helps me wrap my mind around it... Thanks again for the help!

  • I have a similar issue. Only the object all share the same Sprite. Would this example work the same or do I need to do something else. What I mean by sharing the same sprite is. Itz the same sprite for all the objects, just a different animation frame. I can try and share the .capx if need be.

  • I would also like to know how to modify the code to work with multiple instances of the same sprite. I want to pick up an item and put it down. Only one item can be carried at once.

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