How do I make equipabble power ups?

1 favourites
  • 8 posts
From the Asset Store
75 power-up sound effects; bonus and notification sounds, fanfares, harp glissandi, stabs, clock ticks, etc.
  • So essentially I have a total of 16 power ups available, with 3 slots available to the player to equip them, so the player can have 3 power-ups equipped at one time.

    Issues:

    1) the power-up images that the player interacts with (drag and drop into equipped section) needs to then correlate to the power-up events themselves (this seems rather straight forward; just have it set a variable to true when it is slotted; if said variable is slotted then allow player to activate/deactivate the power ups when _ button pressed.)

    2)the power-up images need to be able to be dragged and dropped into the "equipped" slots, when one is slotted it needs to set the previously equipped to "unslotted/unequipped" allowing the player to swap power-ups in and out

    I have shot in the dark on this one and approached from a few angles in my head;

    my first thought was to have variables that trigger on and off when the player selects a power-up, though i am having trouble imagining how to get this to work; my thought was to have three variables represent the 3 different slots, when a power-up is dragged and dropped into slot2 it sets slot2 on that power-up to true and slot2 to false on all other power-ups, theoretically i think this would work but am not sure if this is the best way to approach this.

    another thought i had was using an array, i am not exactly sure how i would use an array to accomplish this though. (to that extent i have very little experience using arrays other than the tutorial videos i have found online). I understand that I could store each power-up in the array but am unsure how to get the array to coincide with the power ups being equipped and furthermore activated.

    truthfully i am just having trouble imagining what the code would be on this one and would greatly appreciate some help, thank you for you time and patience.

  • Normally I would say use an array but for a simple inventory system like this then the variables could be enough. You drop a powerup onto one of 3 slot objects, the slot instance variable takes the name of the power up, you could then use this name however you want : set the animation of the slot to show the powerup, when you use it refer to the name in events.

  • ok so have slot1, slot2, and slot3, then make it so when power-up1 is dropped into slot1 set slot1 animation to correlate to power-up1, right?

    then just have instance variables on each slot totaling 16, correlating to the 16 power-ups, so whichever power-up is dropped into slot1 it sets that power-up instance variable to true and others to false on that slot?

    that makes sense to me i just wanna make sure i'm getting what you're saying

  • What I mean is have slot1.powerup as an instance variable.

    The powerup object you are dragging has its own instance variable powerup.name.

    Then when you drop powerup onto the slot, on dropped you can set slot1.powerup to powerup.name.

    There is no need to list 16 powerup variables on the slot, just have an equipped powerup which is a name of the thing that was dropped.

  • oh cool ok this eradicates the need to set the others to false then, thanks yet again

  • hey so i tried to implement this and am having trouble figuring out how to set slot's instance variable to power up instance variable, I set them both to numbers,string and boolean but the number is the only one that seems to have the set slotvariable = ____ function, however i am not seeing powerup instance variable in the drop down list and it doesn't seem to recognize it if i type it in. does it not recognize other instance variables? and if so how does one make it set slotvariable to = power up variable?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The powerup object has a text variable powerup.name, there you give it a name.

    The code is powerup on dropped, is overlapping slot, set slot.equipped (which is a text variable) to ""&powerup.name

  • oooh my bad, that makes sense, thanks

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