BehaviorReturnCode WaitSomeTimeExec() { charDriver.StopMoving(); cooldown.Start(charDriver.GetMonoBehavior()); return BehaviorReturnCode.Success; }
// Update is called once per frame void Update() { if (waitSomeTimeDelay.IsWaiting) { return; } // Check if arrived at the current destination. if (IsArrivedAtDestnConditional.IsArrivedAtDestination(currDestn, transform.position, 0.1f, isVertical)) { // Set the next destination. currDestn = (currDestn == pointA.position) ? pointB.position : pointA.position; // Wait some time before moving to the next position. waitSomeTimeDelay.Start(this); return; } // Calculate the movement to be added. Vector2 mvmtToAdd; if (isVertical) { mvmtToAdd = new Vector2(0, speed * Time.fixedDeltaTime * ((currDestn.y > transform.position.y) ? 1 : -1)); } else { mvmtToAdd = new Vector2(speed * Time.fixedDeltaTime * ((currDestn.x > transform.position.x) ? 1 : -1), 0); } UpdatePassengersPos(mvmtToAdd); }