Its my first time creating a multiplayer game so i decided to make a simple card game when i tried to make a system to make you be able to place on a placeholder the cards it only showed the card to the player that placed it i tried using RPC to solve that but it still didn’t work maybe its because i dont know how to use it i tried reading the docs but i just got even more confused
heres the code on the main game script:
func _on_area_2d_mouse_entered():
for Card in $Cards.get_children():
if Card.state == InMouse:
Card.pos = 2
#detects when the card is inside the place holder and can be placed
func _on_area_2d_mouse_exited():
for Card in $Cards.get_children():
if Card.state == InMouse:
Card.pos = 1
#detects when the card left the place holder area
func _physics_process(_delta):
for Card in $Cards.get_children():
if Card.pos == 2:
rpc("show_card")
@rpc("any_peer", "call_local", "reliable")
func show_card():
for Card in $Cards.get_children():
if Card.pos == 2:
$CardBase.change(Card.CardImg)
Card.queue_free()
The problem is the mouse entered/exited do not happen on the peers. You will need to synchronize the card state Card.pos = 2 via a rpc or a MultiplayerSynchronizer on the card itself.
That way when the rpc is called it can find the card with the value of 2.
If you want to learn a little more about the multiplayer nodes. Check this blog post out
Can you verify on the peer that the value changed? (You can use the remote tree to look at object values). Are there any errors? Are you by chance manipulating authority?
Im starting to think that maybe it could be the way i make the multiplayer work because i made a simple system just for now since i didn’t even how How i would do the rest of the game
I need to mention something the pos in the code is not position its a variable that i made to detect when the card can be placed maybe i should have Said it earlier but yeah
and on the sever i changed it to call the function:
func _on_area_2d_mouse_entered():
for Card in $Cards.get_children():
if Card.state == InMouse:
Card.set_pos.rpc(2)
#detects when the card is inside the place holder and can be placed
func _on_area_2d_mouse_exited():
for Card in $Cards.get_children():
if Card.state == InMouse:
Card.set_pos.rpc(1)
#detects when the card left the place holder area
but now 5 errors appeared
get_node: Node not found: “Playspace/Cards/CardBase” (relative to “/root”);
process_simplify_path: Parameter “node” is null;
get_node: Node not found: “Playspace/Cards/CardBase” (relative to “/root”);
_process_get_node: Failed to get path from RPC: Playspace/Cards/CardBase;
process_rpc: Invalid packet received. Requested node was not found.
ngl im thinking about just making another system but since im not every experienced on programing i dont know how i will do that this one is just too buggy