- Home /
Question by
lqvinh2 · May 22, 2018 at 11:28 PM ·
networkingnetwork.instantiatenetworkplayernetwork instantiate
[Unity Unet ] When spawn Enemy on Server, next thing is how i can change color of this enemy by using OnMouseEnter(), i only run OK on host game, all client can not change color of enemy. Please see code below.
// Spawn
GameObject enemy = Instantiate(enemy_prefab, pos, rotation);
NetworkServer.Spawn(enemy);
// ===================Function of enemy need to change color on client.
void OnMouseEnter()
{
if (hasAuthority)
{
rend.material.color = Color.red;
}
}
void OnMouseExit()
{
if (hasAuthority)
{
rend.material.color = Color.white;
}
}
Comment