private void SpawnFood(Message message) { using (DarkRiftReader reader = message.GetReader()) { if (reader.Length % 17 != 0) { Debug.LogWarning("Received malformed food spawn packet."); return; } while (reader.Position < reader.Length) { ushort id = reader.ReadUInt16(); Vector3 position = new Vector3(reader.ReadSingle(), reader.ReadSingle()); float radius = reader.ReadSingle(); Color32 color = new Color32( reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), 255 ); GameObject obj; obj = Instantiate(this.foodPrefab, position, Quaternion.identity) as GameObject; AgarObject agarObj = obj.GetComponent <AgarObject>(); agarObj.SetRadius(radius); agarObj.SetColor(color); agarObj.SetMovePosition(position); this.Add(id, agarObj); } } }
void Update() { Vector3 mousePoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); mousePoint.z = 0; agarObject.SetMovePosition(mousePoint); }