Sefi_k
Sefi_k

Reputation: 107

Godot multiplayer: rpc message isn't received

I'm new to Godot so I hope this isn't too silly of a question. In the multiplayer game I'm working on a player needs to report his change in status ("is_infected") to all other players.

inside the game node I have a characters node that players are created in as an instance to a scene called Character3D. Inside that node I have a node called "infectionManager" that handles the infection logic. To summarise: Game > Characters > Character3D > InfectionManger.

I've tried to emit a signal from InfectionManger to Character3D and then broadcast a rpc call from there. It looks as follows:

func _on_InfectionManager_is_infected(is_infected) -> void:
rpc("set_infected_list", get_name(), is_infected)

remote func set_infected_list(player_id, a_player_is_infected):
    print(get_name(), " got the RPC message! ***")

However, it seems other players never do get the rpc message and I'm not sure why that is.

Upvotes: 0

Views: 1500

Answers (1)

Floxicek
Floxicek

Reputation: 26

I think you need same structure on server and client.

When you send rpc, rpc is finding same node path and if it finds the path it will try to run the function.

Try making singleton on both (clint and server) and add this script to it.

Structure for dedicated server is explained here

Upvotes: 1

Related Questions