How do I pick up only one item at once?

0 favourites
  • 6 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.
  • So yeah I want to be able to only carry one item at once.

    I want it that when I press z it will drop an item if its carrying something. Only after that if I press Z it will pick up an item.

    Also I want to be be able to have a different set of animation when carrying the item. And less jump power.

    https://drive.google.com/file/d/0B6czatIgBi7lT2luUEN0dnpYSXc/view?usp=sharing[/code:2vwz43zh]
  • Keep track of the current item's UID, so you can exclude it, as needed.

  • blackhornettechnologies.com/Construct2Stuff/helpmepickuponlyone_BHT.capx

    Keep track of the current item's UID, so you can exclude it, as needed.

    Can you explain the code? I'm glad to see it work, but I want to be able to learn it so maybe next time I can do something similar myself.

    How does this code work if I had two different object types at the same time when I'm trying to pick up something?

    Also, how can I add onto this an make a system to have a "carrying something" state for the player. I'm hoping to add custom animations and custom movements (mainly just slower, and weaker jump)

  • By adding an instance variable to keep track of the currently picked item, you can always reference it in the future individually.

    Ev17: On Z and overlapping Sprite2

    -> Ev18: Tests to see if you are holding an item.

    --> Ev19: Pickall Sprite2s again, in case the held item is not overlapping (which it will be in this case, but maybe a future item doesn't), and then pick just the held item

    ### Set that item as not picked up

    -->Ev 20: Of the overlapping items, pick those that are NOT the held item AND then pick a random one

    ### Set the new item's pickup=True, and store that UID in the Player

    -->Ev 21: ELSE (there were no other items to pick up, so) reset the stored UID so we know we aren't holding anything.

    To deal with different types, you could use Families, or you have to deal with the combinations yourself.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you so much!

  • I am not sure, but would it work better on z pressed drop all/disable wait 0.3 enable/pickup..

    again I don't know much about coding. Just understand the basic concepts of how it would work.

    Have Fun and Enjoy. JC

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