private void FixedUpdate() { CmdSetPathMatrix(); if (GameObject.FindGameObjectWithTag("Player") != null) { Vector3 currentPosition = Round(gameObject.transform.position); Vector3 endPosition = Round(GameObject.FindGameObjectWithTag("Player").transform.position); List <Vector3> path = AStar.CmdFindPath(pathMatrix, currentPosition, endPosition); if (path != null && path.Count > 0) { this.step = path.ToArray()[1] - currentPosition; } else { this.RandomStep(); } } else { this.RandomStep(); } if (this.canMove) { this.CmdMove(); } }