Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PLAYER MOVEMENT SCRIPT
- public void CallNamesTagsRPC(string nickName, string tag, Vector3 playerColor)
- {
- /*=====> If the PhotonView is ours, as in the local player. <=====*/
- if (PhotonView.IsMine)
- {
- /*=====> Set our properties AND tell everyone what our properties are. <=====*/
- PhotonView.RPC("RPC_SetNamesAndTags", RpcTarget.All, nickName, tag, playerColor);
- }
- }
- [PunRPC]
- void RPC_SetNamesAndTags(string nickName, string tag, Vector3 playerColor)
- {
- /*=====> NickName <=====*/
- PhotonNetwork.NickName = nickName;
- /*=====> The local player's GameObject name. You can see this in the Hierarchy. <=====*/
- gameObject.name = nickName;
- /*=====> Player tag. <=====*/
- transform.tag = tag;
- transform.GetComponentInChildren<Renderer>().material.SetColor("_Color", new Color(playerColor.x, playerColor.y, playerColor.z));
- }
- PLAYER SPAWN SCRIPT
- if (players[i].IsMasterClient)
- {
- /*=====> Spawn over the network the Prefab located in - Assets\Resources\Avatar\PlayerAvatar.prefab - and pass (i) to the spawnPosition list and use its position and rotation. <=====*/
- GameObject player = PhotonNetwork.Instantiate(Path.Combine("Avatar", "PlayerAvatar"), spawnPosition[i].position, spawnPosition[i].rotation, 0);
- /*=====> To go over the network, use this example. Check bottom of PlayerMovement script. <=====*/
- player.GetComponent<PlayerMovement>().CallNamesTagsRPC("Admin", "Player2", new Vector3(255, 0, 0)); // Set color to red.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement