ãUnity9ãUNETã§ã¾ã³ãçææã«ã¦ãã¼ã¯ãªIDãä»ããï¼ãUNET13ã
Unity5.1.1p3 Personal(2015å¹´7æ)
前回の続きã§ãã
ä»åã¯ã¾ã³ã1ä½ãã¤ã«ã¦ãã¼ã¯ãªIDãä»ãã¾ãã
ãã¬ã¤ã¤ã¼ãã¾ã³ãããæ»æãåããæããã¬ã¤ã¤ã¼ãã¾ã³ããçæããæã«ããã¡ã¼ã¸æ å ±ãIDã¨ç´ä»ãã¦ãµã¼ãã¼ã¸éããå ¨ã¯ã©ã¤ã¢ã³ãã¨ãã¼ã¿ã¨åæãããã¨ãã£ãæçã«ä½¿ããã¾ãã
UNET Part 13 - Zombie Identity - YouTube
ãç®æ¨ãã¾ã³ãçææã«ã¦ãã¼ã¯ãªIDãä»ãã
â Zombie_IDã¹ã¯ãªãããæ°è¦ä½æ
ã¾ãã¯ã¾ã³ãã«IDãä»ããZombie_IDã¹ã¯ãªãããä½æãã¾ãã以ä¸ã½ã¼ã¹ã§ãã
using UnityEngine; using System.Collections; using UnityEngine.Networking; public class Zombie_ID : NetworkBehaviour { [SyncVar] public string zombieID; private Transform myTransform; // Use this for initialization void Start () { myTransform = transform; } // Update is called once per frame void Update () { SetIdentity(); } void SetIdentity () { if (myTransform.name == "" || myTransform.name == "Zombie(Clone)") { //zombieIDã¯ãGameManager_ZombieSpawnerã¯ã©ã¹ã«ã¦è¨å®ããã myTransform.name =zombieID; } } }
Zombie_ID.cs
SetIdentityã¡ã½ããã«ã¦ãååããã©ã³ã¯ããZombie(Clone)ãã®æã«zombieIDã¨ããååãä»ãã¦ããã ãã§ãã
ã¾ã³ããçæãããæã«ãååãä»ããå¿
è¦ãããã¾ãã®ã§ãååä½æããGameManager_ZombieSpawnerã¹ã¯ãªããã«å çãã¦ããã¾ãã
using UnityEngine; using System.Collections; using UnityEngine.Networking; public class GameManager_ZombieSpawner : NetworkBehaviour { [SerializeField] GameObject zombiePrefab; [SerializeField] GameObject zombieSpawn; private int counter; private int numberOfZombie = 10; public override void OnStartServer () { for (int i = 0; i < numberOfZombie; i++) { SpawnZombies(); } } void SpawnZombies() { //********** éå§ **********// counter++; //********** çµäº **********// GameObject go = GameObject.Instantiate(zombiePrefab, zombieSpawn.transform.position, Quaternion.identity) as GameObject; NetworkServer.Spawn(go); //********** éå§ **********// //Zombieã«IDãã¤ãã¦ãã go.GetComponent<Zombie_ID>().zombieID = "Zombie " + counter; //********** çµäº **********// } // Use this for initialization void Start () { } // Update is called once per frame void Update () { } }
GameManager_ZombieSpawner.cs
SpawnZombiesã¡ã½ããã«ã¦ã«ã¦ã³ã¿ã¼ãåãã¦ãããZombie_IDã¹ã¯ãªããã®zombieIDã«ãZombieã + ã«ã¦ã³ã¿ã¼æ°ã§ååãã¤ãã¦ãã¾ãã
ä»åã¯ããã ãã§ãã
â¡çµæ
ããã§ã¯ã²ã¼ã ãå®è¡ãã¦ã¿ã¦ä¸ããã
Zombie 1ãZombie10çæ
ç¡äºIDãã¤ãããã¨ãã§ãã¾ããã
ä»åã¯ããã¾ã§ã§ãã
ãããã¨ããããã¾ããã
ãUnity9ãUNETã§ãã«ããã¬ã¤ã¤ã¼ãªãªã³ã©ã¤ã³ã²ã¼ã éçºãUNET1ã
ãUnity9ãUNETã§ãã¬ã¤ã¤ã¼ã®åããè£éãããªããããªåããå®ç¾ãããUNET1-2ã
ãUnity9ãUNETã§ãããã¯ã¼ã¯è¶ãã«å¾ã(Rotation)ãåæããããUNET2ã
ãUnity9ãUNETã§ãªã³ã©ã¤ã³éå§æã®ãã¬ã¤ã¤ã¼çæä½ç½®ãå¤æ´ãããUNET2-2ã
ãUnity9ãUNETã®ãããã¯ã¼ã¯ãã©ãã£ãã¯ã軽æ¸ããå¹çåãããUNET3ã
ãUnity9ãUNETã®latency(é
延æé)ãæ¹åãããUNET4ã
ãUnity9ãUNETã®latency(é
延æé)ã表示ãã¦ãã¡ãã£ã¨ã ãæ¹åãããUNET4-2ã
ãUnity9ãUNETã®SyncVarã®hookã®ä½¿ç¨ä¾ã¨ãåæ代ã®åææ¹æ³ãUNET5ã
ãUnity9ãUNETã使ã£ã¦RotationãåæããããUNET6ã
ãUnity9ãUNETã§åãã¬ã¤ã¤ã¼ã«PlayerIDãè¨å®ãããUNET7ã
ãUnity9ãUNETã§æµãã¬ã¤ã¤ã¼ã«ãã¡ã¼ã¸ãä¸ããï¼ãUNET8ã
ãUnity9ãUNETã§HPãç»é¢ã«è¡¨ç¤ºããPlayerã¸ãã¡ã¼ã¸ãä¸ãããUNET9ã
ãUnity9ãUNETã§HPã0以ä¸ã«ãªã£ãæãPlayerãç ´å£ããï¼ãUNET10ã
ãUnity9ãUNETã§æ»ãã Playerãçãè¿ãããï¼ãUNET11ã
ãUnity9ãUNETã§ã¾ã³ãAIãåºç¾ãããï¼ãUNET12ã
ãUnity9ãUNETã§ã¾ã³ãçææã«ã¦ãã¼ã¯ãªIDãä»ããï¼ãUNET13ã
ãUnity9ãUNETã§ã¾ã³ããæã¤ï¼ãUNET14ã
ãUnity9ãUNETã§ã¾ã³ãã«æ»æãããï¼ãUNET15ã
ãUnity9ãUNETã§ã¾ã³ãã®åããã¹ã ã¼ãºã«ã·ã³ã¯ããããï¼ãUNET16ã
ãUnity9ãUNETã§ã¾ã³ãçºçå°ç¹ãå¢ãããUNET17ã
ãUnity9ãUNETã§çºçãããã°ãåãé¤ããUNET18ã
ãUnity9ãUnity MultiPlayerã使ã£ã¦ãããã¯ã¼ã¯è¶ãã«ãããã¡ã¤ãã³ã°ï¼ãUNET19ã
ãUnity9ãGUIãæ¹åãã¦ãNetwork Managerãè¦ãããããï¼ãUNET20ã
ãUnity9ã表示ããGUI(Network Manager)ãæ©è½ãããï¼ãUNET20-2ã
ãUnity9ãUNETã§Animationãåæãããï¼ãUNET21ã