public void MoveToOldPosition(int x, int y, GridItem item) { parentItem.RemoveEnemy(); parentItem = item; this.transform.LookAt(parentItem.transform); currentGridPos = new Vector3(x, y, 1.0f); // this.transform.LookAt (parentItem.GetItemPosition (),Vector3.up); Vector3 diff = parentItem.transform.position - this.transform.position; float angle = Vector3.Angle(Vector3.up, diff); this.transform.rotation = Quaternion.identity; this.transform.Rotate(Vector3.forward, angle); gameObject.transform.position = parentItem.GetItemPosition(); parentItem.AddEnemy(); enemyMoves.RemoveAt(enemyMoves.Count - 1); }
public void MoveToNewPosition(int x, int y, GridItem item) { parentItem.RemoveEnemy(); parentItem = item; currentGridPos = new Vector3(x, y, 1.0f); // this.transform.LookAt (new Vector3(parentItem.GetItemPosition ().x,0,0)); Vector3 diff = parentItem.transform.position - this.transform.position; float angle = Vector3.Angle(Vector3.up, diff); this.transform.rotation = Quaternion.identity; this.transform.Rotate(Vector3.forward, angle); LeanTween.scale(gameObject, Vector3.zero, 0.05f).setOnComplete(() => { gameObject.transform.position = parentItem.GetItemPosition(); parentItem.AddEnemy(); enemyMoves.Add(item); LeanTween.scale(gameObject, Vector3.one, 0.03f); }); }