How do I link inventory objects with new player abilities

0 favourites
  • 5 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • Hey all. This seems simple but I can't get it to work. How do I give the player access to a ability when they collide with a specific item. So I created a simple pause and inventory. You pause, black overlay comes up and it shows you the items/abilities collected, if any. I'm using a single sprite object with multiple animations as the ability sprites I place on the layouts. The sprite has an instance variable called itemName. Each animation is a single frame with art of individual items and item names (power gloves for example).

    I can't seem to "link" the player obtaining a specific item and then "giving" player the access and the ability to perform the specific new ability. In this case, the ability is a passive power glove upgrade. The player can move heavy objects once the player "obtains" the power glove item. Once you collide with an important item, shows up in your inventory. Seems straightforward enough to me. I'm not linking the inventory/pause menu with the abilites in any way really. Once the player collides with an item, the instance variable that says whether a ability is on or off switches to 1, turning the ability on. So in this case, the powerGloves instance variable on the player sets to 1 activating the "Power Glove Push System" group. The pushable box has platform and solid behaviors. For some reason, when I collect the power gloves item, the powerGlove instance variable doesn't switch to 1.

    I'm looking at previous my events and the "syntax" for this stuff looks correct. Here's the code. If I disable the 4 lines above the "power glove push system", the push ability works. Since all the game upgrades/items are animations on a single sprite, I used "pick Unique ID" so the game knows what specific object sprite is the power glove animation sprite. I couldn't figure out any other way to do it. I hope I've given enough context and information about my problem. Let know know if you want to look at a capx. Thanks! Second pic is inventory events just in case.

    Inventory/Pause events just in case.

  • Steps to try:

    Change the Add 1 to powerGlove action to activate the group directly. Does this work? If not, you have a problem with your conditions. If it does work, then something is wrong with your variable. Make sure it is an integer and not a string perhaps?

    To confirm, try enabling the powerglove push system group with a simple keypress or mouse input and see if that works properly (remembering to disable the powerGlove=1 condition).

    Edit: Sorry just read more carefully and noticed you did say that your variable never gets updated. So it is most likely the Pick instance by UID condition that is not triggering. Can you elaborate on this logic why you chose to do it this way?

    Just hazarding a guess that the UID number is incorrect. Wouldn't it make more sense to check the animation frame of the object to see if it is displaying the powerglove item?

  • oosyrag Hey! Thanks for the comment. The UID was correct but it wasn't working. Maybe that specific set of events don't work somehow. Thanks for the tip on checking for the animation though. I actually wanted to do it that way. The reason why I'm picking the UID is because I couldn't figure out the logic to specify individual animation frames. I took another look and found the condition "Is playing". So, I changed the "pick instance UID" and now it's working! Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You would use it as an expression in the System - compare two values. First you would have to pick the powerup (I'm guessing by colliding), then you would system compare two values Powerup.AnimationFrame = x?

    The condition Isplaying is a little bit not quite right for your situation, so I recommend optimizing it a bit more even if it works as you have it right now. Just in case to prevent future issues.

  • I don' think I can use AnimationFrame because I'm not using any "animation frames" as the game items, I'm using the actual "animations. I think I fixed it using the logic your suggesting though. obj_gameItem has an instance variable called itemName so I set system to compare

    obj_gameItem.itemName = "powerGloves" and it works. Would that be acceptable? I also tried obj_gameItem.AnimationName = "powerGloves" but that was glitchy. I could only push for a few seconds, then had to back off before I could push again. Thanks for pointing that out oosyrag!

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