示例#1
0
    /// <summary>Checks if the target midpoint is a valid midpoint.</summary>
    /// <param name="testColRef">Reference to the TestCollider script.</param>
    /// <param name="startPos">Start position to move from.</param>
    /// <param name="targetMidPoint">Midpoint to check for validity.</param>
    /// <param name="targetPos">Target position to move to.</param>
    /// <returns></returns>
    private bool CheckMidpointClear(TestCollider testColRef, Vector3 startPos, Vector3 targetMidPoint, Vector3 targetPos)
    {
        bool isClear = !testColRef.CheckIfLineWillHitWall(startPos, targetMidPoint);

        if (isClear)
        {
            isClear = !testColRef.CheckIfLineWillHitWall(targetMidPoint, targetPos);
        }
        return(isClear);
    }
示例#2
0
 /// <summary>Constructs a WallInWayDecision.
 /// Checks right away if there is a wall in the way and if there is, generates a midpoint
 /// such that traversing start -> mid -> target is clear.</summary>
 /// <param name="testColRef">Reference to the TestCollider script.</param>
 /// <param name="startPos">Start position to move from.</param>
 /// <param name="targetPos">Target position to move to.</param>
 public WallInWayDecision(TestCollider testColRef, Vector3 startPos, Vector3 targetPos)
 {
     // Do a physics cast to see if we can go directly to the target point
     wasWallInWay = testColRef.CheckIfLineWillHitWall(startPos, targetPos);
     if (wasWallInWay)
     {
         // If a wall was in the way, get the midpoin that would make movement valid
         midpoint = CreateMidpoint(testColRef, startPos, targetPos);
     }
 }