Power-ups levels and powers

Hi guys. I have a question/request I would like to try to make sure that when I take a power-up of the same type 2 times from level 1 it goes to level 2 with the same power which however at level 2 varies its abilities.
EX: If I take the explosive powerup 2 times it goes up to level 2 and the blast radius is wider and the damage increases. And so on if I take 3 and go to level 3 the blast radius is wider and the damage increases.
How can I do it?

There are quite a few ways to do this.
I would probably recommend using objects as the powerups.

You can have an actor that acts as a pickup for the powerups instead of having that logic on the individual powerups. Whenever picking up a powerup, you check whether that already exists. If it does, increment. If it doesn’t, create it and add it to the map (which is just a powerup class to powerup object map)

The levelup function itself can simply be an increment node:
image

You can then just get the individual damage by using a get function:


You’ll probably want to make it pure:
image

and then you can simply use that function instead of a direct variable (this exact explosion function wouldn’t be in the parent powerup class- the parent powerup class should only have functions that every single powerup uses):

To create different powerups, simply create children of this powerup.


image

You can then override any method you need in those children classes- such as a OnPowerupUsed function. This way you can use a powerup without knowing what it specifically is.
image

1 Like

Ok, but in the first image how did you do the first step with the purple link with a function?

Because in general, it is clear to me how to make the second level of the power-up. It is not clear to me how to make that if the player takes the power-up 2 times the logic signals that you have 2 power-ups of the same type and when it is taken 2 times it goes directly to level 2 of the power-up

I’m not sure what you mean by this. There are no delay nodes or anything, so you can just implement this into a function with no changes. The class of new powerup should be a variable you take from the pickup you just picked up.

It doesn’t strictly signal you have two powerups of the same type.
That’s the purpose of this section:


If you already have the powerup, you level it up (ie from level 1 to 2 or 2 to 3 using the levelup function).



Let’s take the example “you pick up three speed powerups”.
Each time you pick up a speed powerup, the section in the first image will play, so let’s go through it one pickup at a time.

  1. For the first pickup, we get to the branch node and realize that we don’t already have a speed powerup. Because of this, we go out false on that branch. False leads us to create/record a new powerup object.

  2. For the second pickup, we get to the branch node and notice we DO already have a speed powerup. This leads to true on the branch. We want our speed powerup to be level 2 now. The true pin on the branch leads to a node that levels up our original powerup. Our speed powerup is now level 2.

  3. The same thing happens with the third pickup as the second. The powerup exists, so we level it up- resulting in a powerup that’s now level 3.

Whenever you use the powerup, you simply remove it from the map, and the cycle repeats whenever you pick up another powerup.