/// <summary> /// Adds a new tail to this snake. /// </summary> public void AddTail() { snakeLength++; TailingObject tail = SnakeHead.AddTail(); tail.transform.SetParent(transform); }
/// <summary> /// Recursively adds a tail to this or one of the next tails, /// dependat on which tail needs a next tail. /// </summary> public TailingObject AddTail() { if (NextTail) { return(NextTail.AddTail()); } PoolObjects _pooledObject = PoolManager.Instance.GetObjectFromPool("Tail"); //Enabling item from the pool GameObject tail = PoolManager.Instance.EnableObjectFromPool(_pooledObject, transform.position, Quaternion.identity, playerBehaviour.gameObject); _nextTail = tail.GetComponent <TailingObject>(); _nextTail.GetComponent <BoxCollider>().enabled = false; return(_nextTail); }