Array-based Inventory Items and their Effects

0 favourites
  • 3 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • Heyo,

    Needing some guidance here. Again, I feel like I'm overlooking a very simple way of doing this...

    So, first off, I have an inventory stored in an array which counts items picked up, dropped, amount, etc...

    First query: however, I'm trying to understand how to apply an 'as long as item is in inventory' effect (example: player has Boots of Speed - add 50 to speed variable on the player) but I can't figure it out.

    I'm currently comparing a value in the array, checking if it's true and then, on true, doing the 'add 50 to speed'. This constantly adds every tick though.

    How would I get this to just be a once-off effect?

    As well, how would I get this effect to be removed when the item is removed from the inventory? Would this apply to items 'stacking' onto the same variable (so two different items altering the speed of the player)?

    Thanks in advances, everybody. :)

  • I think your logic is wrong. Instead of constantly checking if an object is in your array and apply its effects, you should only update your game state when you add/remove something from your inventory. On Pick Up boots > add to inventory and add 50 speed. On Drop boots > remove item from inventory and sub 50 speed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • if true - trigger once - add speed

    if false - speed is startingspeed+50 - trigger once - subtract speed

    If you are able to check if it's true you are also able to chance this value to false I presume. So set the value to false when not in inventory. And th

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