[ad_1]
as of now I am utilizing an merchandise detector to examine if I cross by objects in sure teams if I do, and I press the choose up keybind, it can choose no matter merchandise there. I managed to make it work with crossbow, spears, swords, shields and swords utilizing most important hand and offhand bone attachments.
however twin wielding swords is an issue
elif physique.is_in_group("Weapon3"):
if Enter.is_action_pressed("E"):
var newWeapon3 = weapon3.occasion() as Node
if !attachment.has_node(newWeapon3.title):
if attachment.get_child_count() > 0:
droppedWeapon = attachment.get_child(0)
droppedWeapon.queue_free()
spawnDroppedWeapon(droppedWeapon.global_transform.origin) # Spawn the dropped weapon on the ground
attachment.add_child(newWeapon3) # Down until this level the earlier code spawned the sword within the participant's hand
participant.has_Spear = false
participant.has_Rcrossbow = false
participant.has_Sword = true
physique.queue_free()
if participant.has_Sword:
participant.has_Sword_Off = true # This units the Secondary sword as true, and a mirrored script for the offhand bone attachment cases one other sword within the offhand.
print("Participant has a sword")
So when iI choose up a single sword, it immediately cases a sword each in the principle hand and the offhand….which doubles the objects, which is not good.
For the protect it isn’t an issue
func _on_ItemDetector_body_entered(physique):
if physique.is_in_group("Defend"):
if Enter.is_action_pressed("E"):
var newWeapon1 = weapon1.occasion() as Node
if !attachment.has_node(newWeapon1.title):
if attachment.get_child_count() > 0:
droppedWeapon = attachment.get_child(0)
droppedWeapon.queue_free()
spawnDroppedWeapon(droppedWeapon.global_transform.origin) # Spawn the dropped weapon on the ground
attachment.add_child(newWeapon1)
participant.has_Sword_Off = false
participant.has_Shield = true
physique.queue_free()
print("participant has protect")
Additionally utilizing buttons or keybinds to instace one sword after which one other works, it is simply the merchandise detector one which confuses me.
[ad_2]