private void Patrol() { Vector3 movement = Vector3.MoveTowards(transform.position, patrolPath.currentNode.position, speed * Time.deltaTime); if (player != null) { // Debug.Log(movement - transform.position); player.gameObject.transform.position += movement - transform.position; } transform.position = movement; if (patrolPath.CheckCloseEnough(transform.position)) { if (patrolPath.IsAtEndOfRoute || patrolPath.IsAtBeginningOfRoute) { currentState = PlatformStates.Wait; StartCoroutine(Delay()); } else { patrolPath.IncrimentPatrolNode(); } } }
// Update is called once per frame void Update() { if (patrol.CheckCloseEnough(pawn.transform.position)) { patrol.IncrimentPatrolNode(); } if (patrol.currentNode.position.x - pawn.transform.position.x > 0) { pawn.Move(1); } else { pawn.Move(-1); } }