Godot RPG: Creating a New Item (Weapon)


Weapons are created independent of the Player, so that they can also be used by enemies and other entities.

Creating the Scene Tree

An enemy extends item, so you’ll need to have the basic scene tree required by the Item Class. Names not in quotes should not be changed.

  • “Name” is type Item
    • [optional] AnimationPlayer is type AnimationPlayer

    • Sprite is type Sprite

    • Hitbox is type Area2D
      • CollisionShape2D is type CollisionShape2D


Again, these are inherited from the Item Class.

    • The amount the item harms an entity of a different type

    • The maximum number of the item that a single entity can have spawned at a time

  • delete_on_hit
    • Signals whether the item should be deleted when it hits an entity of a different type


Most of the function of the item will need to be written individually for each item, but a basic outline of what might be expected is below.


If the item has an animation (like a sword swing) then you’ll want to set_physics_process(false) so that the animation can finish before moving on. Alternatively, if it is waiting for the input to be released (like a bow) then we’ll want physics process on.


This is a required function and is called by Entity.use_item(). In general, this should start the animation, connect signals, play sounds, and set the entity state. An example from sword is below. Again, this will serve a slightly different function for something like a bow. We may even just pass it.

func start():
    anim.connect("animation_finished", self, "destroy")
    anim.play(str("swing", get_parent().spritedir))
    if get_parent().has_method("state_swing"):
        get_parent().state = "swing"


This is an optional function that can be attached to the animation_finished signal. It sets the expected behavior of the item after the animation has completed (i.e. arrows moving off in the direction they were fired). This is also where set_physics_process(true) would be set in a situation like a sword.


Mostly physics process will be checking to see if the input has been released. In the case of something like the sword, we’ll destroy the item. For something like a bow, we’ll run the animation and then continue to move the arrow until it is deleted or goes off screen.