ioxu / key

Key, a game made with the Godot Engine 4.
MIT License
6 stars 1 forks source link

equip weapon pickup #38

Closed ioxu closed 2 years ago

ioxu commented 2 years ago

Once weapon is in inventory, sort out what to do to equip a weapon.

ioxu commented 2 years ago

functionally to equip a weapon it needs to be

  1. re-parented under player/MeshInstance/weapon_mount
  2. signals need to be connected current_weapon.connect("fire", player, "_on_weapon_fire") and weapon.connect("magazine_count_changed", dui_root, "_on_magazine_count_changed")
ioxu commented 2 years ago

Three nodes need to know about an equipped weapon:

  1. player
  2. dui_root
  3. controller
ioxu commented 2 years ago

update player.gd _ready()

    # connect to weapon
    # TODO: replace with player function for switching weapon
    if $MeshInstance/weapon_mount.get_child_count() > 0:
        current_weapon = $MeshInstance/weapon_mount.get_child(0)

    if current_weapon:
        current_weapon.connect("fire", self, "_on_weapon_fire")