- Home /
change the color of different players
hi, im making a multiplayer game and i want to make it so in the minimap each player see's him self as a different color than the other player (or atleast sees only himself in the minimap). i have attached to the player prefab an arrow that only the minimap camera can see, and to this arrow i attached the following script:
using UnityEngine;
using UnityEngine.Networking;
public class arrow : NetworkBehaviour {
void Update()
{
if (isLocalPlayer)
{
Material material = new Material(Shader.Find("Standard"));
}
}
}
the script doesnt work and when there are multiple players connected each player sees all the arrows in his minimap in the same color. please help me and let me know what i did wrong, keep in mind that my english and programming arent very good so if you could change the script yourself and give me a working version itll be great, altho every help will be appreciated, thanks.
Answer by nj4242 · Sep 21, 2016 at 07:12 AM
Try using :
public GameObject player;
if (isLocalPlayer)
{
player.GetComponent<Renderer>().material.color = red;
//choose whatever color you need.
}
Answer by mitchmeyer1 · Sep 19, 2016 at 06:19 PM
If all the players are using the same material, editing one players material will in turn edit all of them (because they are using the same instance of a material). You need to edit the sprite renderer color or whatever you are using instead. Or i guess give them all a different material but thats sketchy. Capisce?
Your answer
Follow this Question
Related Questions
Cant drag player into Network transform child 1 Answer
Death handling peculiarly 0 Answers
UNET Matchmaking Filter Issues 1 Answer
Unet/Mirror. Spawn different prefab in local and server/rest of clients 0 Answers
Unity 5.2 SyncVar hook only gets called on host. VS debugger dosent debug it fully. 0 Answers