Locally disabling GameObjects with network transform components attached.
I've been working on a networked first-person project for school, and I was trying to find a way to locally disable some gameobjects which are children of the player game object. These gameobjects hold the meshes of the avatar the local player uses. The problem is, when i attempt to disable them, (and i believe this is because of the network transform component attached to the parent (which is necessary)) it affects all clients' views of the player. Thus, when i attempt to only locally disable every player's respective meshes, every client just sees nothing, as though there are no players. As in, let's say player 2 of 4 would locally disable his avatar's mesh so he doesnt see it yet everyone else can, and the same for every other player. But the network transform (i believe) forces everything to sync, so it shows up on everyone's window. Is there any way around this?
Answer by Ginxx009 · Dec 22, 2017 at 03:59 AM
Hmmm i belive you can do it something like this . This code is not yet tested but it will help you i am sure.
public GameObject onChild;
public GameObject DisableObjectOnChild(){
onChild.GetComponent<MeshRendere>().enabled = false;
}
// or you can do it something like this
/ Use this for initialization
void Start () {
transform.Find("Child").GetComponent<MeshRenderer>().enabled = false;
}
hope it will help you :)
Thank you :) I didn't think to actually disable the skinned mesh renderer components, but it worked. Thanks!
Your answer
Follow this Question
Related Questions
UNET Clients Laggy 0 Answers
How to find local player gameobject? c# 3 Answers
Error when using NetworkList "Don't know how to serialize List`1 " 0 Answers
local scale network 0 Answers
Local Multiplayer Basic shooting 1 Answer