How to hide objects/nodes on authority but not hidden for other players

Godot version: Godot 4.1

Hi guys, I just have a quick question regarding how can I make it so that my player (the one who has the authority) see something while others don’t and vise versa.

For example what I’m trying to do is hide all other players except myself. But I’m not sure how I can even start.

Thanks :smiley:

1 Like

Does each individual player have their own camera or are all players on screen at the same time?

Every player has their own camera. If you mean like a split screen look when you said on screen at the same time then no :slight_smile:

You can use is_multiplayer_authority() to get if the node is currently the authority, that true/false value can be applied to many things. Here’s a sample from my own network multiplayer game.

func _ready() -> void:
	var player_controlled := is_multiplayer_authority()

	set_physics_process(player_controlled)
	set_process_unhandled_input(player_controlled)

	camera.current = player_controlled
	hud.visible = player_controlled
1 Like

You can condition your camera’s cull masks by node on authority, and set those other player nodes to the appropriate cull mask and visual instance 3D masks so that their cameras can see the objects and the node on authority cannot or vise versa.

1 Like

Thanks, after a while I finally got it working.

I just made it so that I loop over all the meshes inside the skeleton and set their layers to 2 in my case, and the camera cull mask to 2 as well on authority only which worked :slight_smile:

Here is a sample code if anyone needs it

camera.cull_mask = 2
		
for mesh in meshes.get_children():
    if mesh is MeshInstance3D:
	mesh.layers = 2
1 Like

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