Changin Weapon with using RPC

Godot Version

4.2.2

Question

` Hey everyone, I am trying to change player weapons and sync it. I have a Player scene and that scene has child Camera3D → Weapon Handler → Weapon1 and Weapon 2.

I have this script in Weapon Handler ;

extends Node3D

@export var weapon_1 = Node3D
@export var weapon_2 = Node3D

func _ready() -> void:
	equip.rpc(weapon_1)
	

func _unhandled_input(event: InputEvent) -> void:
	if not is_multiplayer_authority(): return
	if event.is_action_pressed("Equip Primary"):
		equip.rpc(weapon_1)
	elif event.is_action_pressed("Equip Secondary"):
		equip.rpc(weapon_2)
		
@rpc("any_peer", "call_local", "reliable")	
func equip(active_weapon: Node3D) -> void:
	if not is_multiplayer_authority(): return
	for child in get_children():
		if child == active_weapon:
			child.visible = true
			child.set_process(true)
		else:
			child.visible = false
			child.set_process(false)

But i get this errors ;

`

When using rpc calls, the node names must match exactly. Including the tree path.

1 Like

Thank you so much.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.