void GoToCover() { if (inCover == true) { return; } Transform cover = null; if (enem_target != null) { cover = AIHelpers.ReturnValidCover(combat.coverTags, enem_target.transform, senses.eyes, senses.visualRange, debugSettings.showCoverDetectors); } if (cover != null) { inCover = (Vector3.Distance(transform.position, cover.position) <= agent.stoppingDistance) ? true : false; if (inCover == false) { AIHelpers.MoveToTarget(cover.position, transform); } if (debugSettings.showSelectedCover == true) { debugSettings.coverPosition = cover.position; } currentCover = cover; } }
void GoToTarget() { float distance = (combat.type == CombatType.Shooter) ? combat.shotDistance : combat.meleeDistance; if (Vector3.Distance(transform.position, lastSeenLocation) > distance) { Vector3 target_point = lastSeenLocation; AIHelpers.MoveToTarget(target_point, this.transform); } }
void UpdateGroundedState() { if (ignoreGroundCheck == true) { return; } if (AIHelpers.RaycastHitting(transform, groundRaycast, Vector3.down, 0.4f)) { anim.SetBool("grounded", true); } else { anim.SetBool("grounded", false); } }
void ValidCoverCheck() { if (enem_target == null) { inCover = true; } else if (currentCover == null) { inCover = false; } else if (AIHelpers.InOffSetRaycast(enem_target.transform, currentCover.transform, 0.5f, senses.visualRange, this.transform, debugSettings.showDetections)) { inCover = false; } }
void StandDetect() { if (AIHelpers.RaycastHitting(transform, senses.eyes, transform.forward, senses.coverDetectDistance) || AIHelpers.RaycastHitting(transform, senses.eyes, -transform.forward, senses.coverDetectDistance)) { inStandingCover = true; // RaycastHit wall = AIHelpers.ReturnRaycast(transform, senses.eyes, -transform.forward, senses.coverDetectDistance); // Quaternion newRot = Quaternion.FromToRotation(transform.up, wall.normal); // transform.rotation = newRot * transform.rotation; // agent.destination = transform.position; } else { inStandingCover = false; } }
void CrouchDetect() { if (AIHelpers.RaycastHitting(transform, senses.crouch, transform.forward, senses.coverDetectDistance) || AIHelpers.RaycastHitting(transform, senses.crouch, -transform.forward, senses.coverDetectDistance)) { inCrouchCover = true; RaycastHit wall = AIHelpers.ReturnRaycast(transform, senses.crouch, -transform.forward, senses.coverDetectDistance); vault_height = wall.transform.lossyScale.y; // Quaternion newRot = Quaternion.FromToRotation(transform.up, wall.normal); // transform.rotation = newRot * transform.rotation; } else { inCrouchCover = false; } }
void CheckForClimb() { if (AIHelpers.RaycastHitting(transform, senses.eyes, transform.forward, senses.coverDetectDistance, (1 << LayerMask.NameToLayer(movement.climbLayer)))) { if (ladder == null) { RaycastHit hit = AIHelpers.ReturnRaycast(transform, senses.crouch, Vector3.forward, 4); ladder = hit.transform.root.transform; } climbing = (inStandingCover == true) ? true : false; } else { climbing = false; } }
void Patrol() { if (enem_target == null && waypoint_target != null) { AIHelpers.lookAtTarget(waypoint_target.transform.position, this.transform, movement.walkTurningSpeed); ChangeLookTarget(waypoint_target.transform); } if (agent.pathStatus == NavMeshPathStatus.PathComplete && agent.remainingDistance == 0) { waypoint_target = FindNextWaypoint(); if (waypoint_target != null) { AIHelpers.MoveToTarget(waypoint_target.transform.position, this.transform); } } }
void UpdateGroundedState() { if (anim.GetBool("climbing") == true) { anim.SetBool("grounded", true); } else { if (AIHelpers.RaycastHitting(transform, groundRaycast, Vector3.down, 0.4f)) { anim.SetBool("grounded", true); } else { anim.SetBool("grounded", false); } } }
bool CanSeeEnemy() { foreach (GameObject enemy in enemies) { if (AIHelpers.CanSeeObject(enemy, senses.eyes, senses.fieldOfView, senses.visualRange, debugSettings.showDetections)) { isSearching = false; enem_target = enemy; lastSeenLocation = enem_target.transform.position; bool value = (enemy.transform.root.tag == "Player"); LockLookToPlayer(value); return(true); } else { enem_target = null; } } return(false); }
void LookAtTarget(Vector3 overrideTarget = default(Vector3)) { Vector3 target_point = (overrideTarget == default(Vector3)) ? lastSeenLocation : overrideTarget; AIHelpers.lookAtTarget(target_point, this.transform); }