private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Enemy") || collision.gameObject.name == "Floor") { return; } if (collision.gameObject.name == "Map border") { UnityEngine.Debug.Log(gameObject.name + " map border collision calling RemoveFirstPoint()"); movementScript.RemoveFirstPoint(); } // Debug.Log("Collided with " + collision.gameObject.name); // If collided with the cover that the agent was supposed to hide behind. if (nextCover != null) { if (collision.gameObject == nextCover || Vector3.Distance(nextCover.transform.position, transform.position) < 5) { UnityEngine.Debug.Log(gameObject.name + " collision calling RemoveFirstPoint()"); movementScript.RemoveFirstPoint(); currentCover = nextCover; nextCover = null; if (visitedCovers.Contains(currentCover) == false) { visitedCovers.Add(currentCover); } decisionMaking.moveToCover = false; agentScript.ChangeActionText("Reached cover"); return; } } }
public void JumpOnObject(GameObject objectToJumpOn) { agentScript.ChangeActionText("Jumping on object"); Vector3 desiredPos = new Vector3(currentPos.x, currentPos.y + objectToJumpOn.GetComponent <BoxCollider>().bounds.size.y + 2, currentPos.z); transform.position = Vector3.Lerp(currentPos, desiredPos, 1); movePathList.Insert(0, transform.position + new Vector3(3, 0, 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)); } }