How do I make my player character switch between two or more weapons?

I’m working on another project again to furtherly understand more about GDevelop. The project is a 2D shooting game, so can anyone show me how to make my player character switching weapons? I also try to use the Inventory condition and action as well, but it’s not working yet.

Well, here’s an example:
Condition : f is pressed
Action : change animation name of Weapon to “Shotgun”.

1 Like

Thanks, but, what if my events looks like this?

Isn’t that pretty much the same question you have asked here? How do I replace weapons from my player character’s hand if the character already has a weapon in it’s hand?

Did you try the solution suggested by @MrMen?


I did, but, it didn’t work. What I got is that two of my weapons begin to act strange( whenever I shoot, the two mentioned weapons shoot as well while not in my character’s hand). This time no more weapons rotate by the mouse position.

Also this one is about switching between two weapons by pressing a key after pick another up, not by pick one up and throw away the other.

Ah, but it did work. You’re now asking for more functionality, which we call scope creep.

The weapons solution I gave will work with firing. It’ll be that you’ve coded it incorrectly. You can always start a new thread and ask for help to work out why that is happening. That’s what these forums are for.

Yeah, sorry for the inconvenience.

It’s not an inconvenience. It’s just a shame you didn’t continue with your original idea of mouse directed firing.