How to RPC knows which Nodes is puppet?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Roket

I have a game world that is made up of cells. I create him by mask, looks like:

0 - is floor
1 - is wall
2 - is enemy


Floor and wall just is image in TileMap, but enemy is Node

First, I create an instance of all the enemies on the server, and when (at a random moment) the client connects, I send him a map and again create an instance of all the enemies, but now on client side.

Next if I call enemy.rpc("kill") thenkill() will be called by the respective enemies, those who are in the same position(same cell).

But I can’t understand, how RPC understands that this node is correct?

I want to know it, because sometimes I get error Failed to get path from RPC and I think it’s somehow connected

:bust_in_silhouette: Reply From: tastyshrimp

Your question error has nothing to do with being a master or puppet and i believe that for the rpc call as you are doing it does not even matter. What rpc does is execute a method on everyone, local and remote, server and remote in your case, and it does that by using the NodePath. So if the NodePath is different, does not exist or different id, in one of the clients the call fails.

For more details check the docs or this old question that gives a pretty good overview.

I just missed the point that I can change the name of the path somehow like that node.set_name(str(id)) :slight_smile:

Roket | 2020-01-09 21:27