Exemple #1
0
 public void MoveToCover()
 {
     agentScript.ChangeActionText("Moving to cover");
     //coverFinder.movingToCover = true;
     // If there are no more covers seperating the agent from the player
     if (coverFinder.GetClosestCoverToHide() != null)
     {
         movementScript.AddPointToList(coverFinder.GetClosestCoverToHide().transform.position - coverOffset);
     }
     else
     if (agentScript.playerVisible == false)
     {
         movementScript.AddPointToList(gameObject.transform.position + new Vector3(5, 0, 0));
     }
 }
    private void Update()
    {
        if (nextCover != null)
        {
            // In some cases the point could be removed from the path list. Adding it back in
            if (movementScript.movePathList.Count == 0)
            {
                movementScript.AddPointToList(nextCover.transform.position);
            }
        }

        if (currentCover != null)
        {
            if (Vector3.Distance(gameObject.transform.position, currentCover.transform.position) < 3)
            {
                nearCover = true;
            }
        }
        else
        {
            nearCover = false;
        }
    }