|Topic was automatically imported from the old Question2Answer platform.
I am making a multiplayer first-person game and am trying to figure out how to make it so other players can see your body, but you can only see your hands. Does anybody know how to make the mesh instance hidden for you, but not anybody else?
Thankyou for everybody’s help. I finally figured out a straightforward solution.
First, make a parent to all the meshes you want hidden by putting them under a spatial node. Next, make a variable for this.
onready var mesh = $PlayerMesh Next, under your
func _ready, add something that says
mesh.visible = !is_network_master() This will make it so if you clarify that you were the network master, your mesh will be hidden for only you.
strangerturtle | 2022-09-17 21:08
Keep in mind that this stuff is not replicated on its own. So if you hide a body in one instance, it won’t be hidden in the other instances, unless you explicitly send an rpc. So whenever you spawn the player’s own character, you can just hide the body and this change will be local to the players client. When you then spawn characters for other players, e.g. in
_player_connected(id), you just hide the arms instead of the body.
You could also use entirely different scenes for the local player and other connected players and do the positional updates outside of those scenes.
I was going to suggest to use different render layers for that, but that probably won’t scale.
Doing the arms is easy because all you need to do is not send the arms to the server. What I can’t figure out is how to make the mesh hidden to only you, but to have it broadcast to the server. What would the lines be to do it?
strangerturtle | 2022-07-25 22:49
What exactly do you want to broadcast to the server? Can you explain your scene setup a bit?
omggomb | 2022-07-26 08:50
It’s a kinematic body with a cgmesh combiner (this has all the meshes that I want to hide) the body also has a 3d spatial called head (this contains the two cameras, hud, and all the stuff that I am content with), the body also has two collisions (a bean and cylinder), and a ground check ray cast. It is a modified version of the player from garbaj tutorials.
strangerturtle | 2022-07-28 01:01