Hello, I am new to game developing as a whole but I have been trying to learn Godot in the past few months. I have two different sets of animation to be used one while the player has not obtained the weapon (no weapon on back) and one set to replace the first one when the weapon is collected. There is no inventory system and I don’t plan on adding one, so when the weapon is “collected” it just “$Sprite2D.queue_free()”. I wanted to ask if it was possible and how to switch between these two sets of animation when the weapon is “collected”. The change is solely visual but it would be a nice touch to show the weapon on the back of the player.
This is my code on the AnimatedSprite2D player animation input sequence. I think I need to find a way to make all of those animations be in an “if” statement and only activate if the weapon has not been collected yet while otherwise play the animation with the weapon on the back or the do the opposite.
Since your are using an animatedsprite2d you can just replace the SpriteFrames-resource.
Make sure to create one resource without the sword and one with the sword. then save them in your file-system and load them in your player. As soon as the sword is picked up you can set the sprite_frames of the animatedsprite to the sword-resource.
This should work flawlessly if you name the animations the same in both resources
I have made two spriteframe resource one with weapon and one without but now I am stuck at the point of changing them when the weapon is collected or disappears to be exact. I was thinking of adding an area2D to the player only able to collided with the area2D of the weapon and using the signal on_area_entered it would set the other spriteframe resource (with the weapon). I just lack the syntax necessary really.