Hi, so i am trying to make a multiplayer fps game, but I ran into a small issue.
when I test and connect with two instances the arms move on the other player if I move them on my player. I have tried fixing it but nothing is working
Also here is the video link:
Could you post the player script? I believe your camera control is not based on multiplayer authority. Maybe it’s an _input override that needs a matching set_process_input(is_multiplayer_authority())?
Hi, I believe it has to do with mutliplayer authority, which decides which instance can control what
When a player is added to the scene, you should set its authority with set_multiplayer_authority(x) where x is an int.
A solution I have seen multiple times is to set the player’s name to the client id when it is added to the scene:
var player = player_scene.instantiate()
player.name = str(id)
players.add_child(player)
(players in this case is the node containing all my players)
Then set the player’s authority in the ready or enter_tree function like so set_multiplayer_authority(name.to_int())
Then you can check if the character should be controlled or not with if is_multiplayer_authority(): ...
Cool! So looks like the camera.current and fire() is controlled by is_multiplayer_authority but none of the inputs are!
Instead of putting if is_multiplayer_authority(): above each function I would recommend disabling the _input and _physics_process functions entirely. This _ready sample does just that.
Can you post a screenshot of the multiplayer synchronizer? I believe the second part of my post should fix that by adding the camera’s rotation property to the synchronizer.
Does the head/neck contain the arms and weapon? I suppose it’s up to the scene tree, post that if you have any more issues. If the camera has no visible children then I am wrong, make sure to synchronize the visible parts
Looking at your video again the weapons do move side-to-side (with the $Neck) and up-and-down (with the $Neck/Camera) so they must be children of camera.
If the arms only synchronize up/down then add the $Neck rotation to the synchronizer. if the arms do not move at all then it is a synchronizer issue, maybe the multiplayer authority isn’t being assigned correctly? I highly doubt it’s a synchronizer issue as it worked in the first video.