- Home /
Question by
AXORTH · Mar 24, 2019 at 08:39 AM ·
networkingprefabobjectnetworkview
PROBLEM FOR SEE AN OBJECT
I am currently working on a project on UNET. My problem is this: I have a prefab that contains two different skins models. In my code I disable one and activate the other to change skin. The problem is that when I'm in an online game, the other player constantly keeps the base skin on my sight while he has changed it on his side ... Here is the code placed on the prefab:
using UnityEngine; using UnityEngine.Networking;
public class SetPlayer : NetworkBehaviour { public bool Trapper = false; public Transform targetNormal; public Transform targetTrapper;
// Create
void Start()
{
if (isLocalPlayer)
{
targetNormal.gameObject.SetActive(false);
targetTrapper.gameObject.SetActive(true);
}
}
// Step
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Trapper = !Trapper;
}
// Activate player
if (!Trapper)
{
targetNormal.gameObject.SetActive(true);
targetTrapper.gameObject.SetActive(false);
}
else
{
targetNormal.gameObject.SetActive(false);
targetTrapper.gameObject.SetActive(true);
}
}
else
{
// Activate player
if (!Trapper)
{
targetNormal.gameObject.SetActive(true);
targetTrapper.gameObject.SetActive(false);
}
else
{
targetNormal.gameObject.SetActive(false);
targetTrapper.gameObject.SetActive(true);
}
}
}
}
Comment
Your answer
