Change player appearance when a powerup is active

Hey guys,

First of all I want to admit im loving the software and the community.

I need a bit of advice going about a thing I wanna do.

Lets say a platformer player picks up a “hat” powerup. I want the whole appearance of the player to wear a hat (i have the animations for it) only while that powerup is active, or while item “hat” ia in inventory.

Any ideas? Any are appriciated. Maybe is way less complicated that I think but I am not able to focus outside the box haha.

Thanks guys. Really appriciate it.

I would use a variable for this. If the hat is able to be in inventory throughout multiple scenes, I’d use a global variable. Otherwise you could use a scene variable, or a variable of the Player.

Condition: when Player is in collision with hat (or whatever happens to pick up hat)
Action: set the variable Hat to “true”

Condition: hat is no longer in inventory
Action: set the variable of Hat to “false”

Condition: variable Hat is “true”
Action: set animation of Player to “hat”

Condition: variable Hat is “false”
Action: set animation of Player to normal/non-hat

2 Likes

This could work but using a variable is redundant in that case, you could directly do

Condition: when Player is in collision with hat (or whatever happens to pick up hat)
Action: set animation of Player to “hat”

Condition: hat is no longer in inventory
Action: set animation of Player to normal/non-hat

But I wouldn’t recommend using an animation, as it would unnecessarily multiply the complexity of the animations. The best solution would be to have a separate hat object:

Condition: when Player is in collision with cool hat && Trigger Once
Action: set animation of hat to “CoolHat” && show hat object

Condition: when Player is in collision with small hat && Trigger Once
Action: set animation of hat to “SmallHat” && show hat object

Condition: when Player is in collision with hat remover && Trigger Once
Action: hide hat object

Condition:
Action: Set position of hat to Player.PointX(“Head”), Player.PointY(“Head”)

Of course adapt the conditions to switch the hat to your case :wink:

2 Likes

Great insight, @arthuro555! I suggested a variable in case it needed to be carried over from scene to scene. And I suggested changing the animation since he indicated he already had the animations for it. It’s great that GDevelop allows many different ways to accomplish the same thing based on your needs and skill level.

2 Likes

Both great answers, thank you very much. I was thinking of doing variables but didnt work since the player changes to basic walk animation when it moves.

Thanks again guys, gonna fiddle arouns and let you know.

For the variable to work you’d need a second version of all your animations (walk, idle, etc.) that had a hat on the Player. Then do something like:

Condition: Player is moving
Action: set animation of Player to “walk”
Sub-Condition: variable Hat is “true”
Action: set animation of Player to “walk-hat”

Otherwise, attaching a separate hat sprite to the Player with X/Y location as outlined above is your best bet (though, you could also attach/unattach the hat via a variable if you wanted to).

1 Like

Worked like a charm. Thanks a lot! I had to fiddle around with the Player Points but got it done.

Its amazing how easy it actually was, but then again so is every other thing in Gdevelop.

I started 3 days ago, and in bout a week I will release my first game!

Also thanks @beanmatt for your pitch aswell.

Have a nice day and #staysafe

1 Like