path.BlockUntilCalculated() really block?

As show in picture, the robot run in the non-walkable area.
In the code, I use path.BlockUntilCalculated() to stop it from moving before path calculation finished. Any idea?

 if (_target == null)
                        {
                            // 1. If unit cannot attack, move to enemy in Radar range
                            // 2. if radar range empty,
                            // 2a. player unit: do nothing
                            // 2b. enemy unit: move to closet player unit (very long radar checking range and non robot unit highest priority)

                            // root robot cannot move
                            if (enemyOnRadar.Count != 0 && !robotAI.traitBuff.root)
                            {
                                // Pick an enemy from Radar list
                                // move to the tile based on max attack range
                                // or no weapon ready, end this unit turn
                                if (currentAttackRangeMax != 0 && moveAllowThisTurn)
                                {
                                    Vector3 destination = TileManagement.GetTileNearTarget(transform, enemyOnRadar[0], currentAttackRangeMax);
                                    finalTile = TileManagement.GetTile(destination);

                                    path = _rbSeeker.StartPath(transform.position, destination);
                                    path.BlockUntilCalculated();
                                    moveStepCounter = 0;
                                    moveStartTile = TileManagement.GetTile(transform.position);
                                    if (moveStartTile == null)
                                        Debug.Log("error at combatAI start moving");

                                    moveAllowThisTurn = false;
                                    robotAI.Move(destination);


                                }
                                else
                                {
                                    // no target and cannot move
                                    robotAI.AstarScanMask.SetActive(true);
                                    start = false;
                                    moveAllowThisTurn = true;
                                    Data.unitsInAction.Remove(transform);
                                }
                            }
                            else
                            {
                                // no target and cannot move
                                robotAI.AstarScanMask.SetActive(true);
                                start = false;
                                moveAllowThisTurn = true;
                                Data.unitsInAction.Remove(transform);
                            }                            
                        }

I think I have solved the problem after putting Astar.scan() everywhere.

1 Like