public override void Init() { base.Init(); if (randomWaypoint == null) { randomWaypoint = new vFisherYatesRandom(); } if (randomPatrolPoint == null) { randomPatrolPoint = new vFisherYatesRandom(); } currentWaypoint = -1; currentPatrolPoint = -1; fwd = transform.forward; destination = transform.position; agent = GetComponent <NavMeshAgent>(); agentPath = new NavMeshPath(); sphereSensor = GetComponentInChildren <v_AISphereSensor>(); if (sphereSensor) { sphereSensor.SetColliderRadius(maxDetectDistance); sphereSensor.tagsToDetect = tagsToDetect; sphereSensor.passiveToDamage = passiveToDamage; } animator = GetComponent <Animator>(); meleeManager = GetComponent <vMeleeManager>(); canAttack = true; attackCount = 0; sideMovement = GetRandonSide(); destination = transform.position; _rigidbody = GetComponent <Rigidbody>(); _rigidbody.useGravity = true; _rigidbody.constraints = RigidbodyConstraints.None | RigidbodyConstraints.FreezeRotation; agent.updatePosition = false; agent.updateRotation = false; agent.enabled = false; _capsuleCollider = GetComponent <CapsuleCollider>(); // avoid collision detection with inside colliders Collider[] AllColliders = this.GetComponentsInChildren <Collider>(); Collider thisCollider = GetComponent <Collider>(); for (int i = 0; i < AllColliders.Length; i++) { Physics.IgnoreCollision(thisCollider, AllColliders[i]); } healthSlider = GetComponentInChildren <v_SpriteHealth>(); head = animator.GetBoneTransform(HumanBodyBones.Head); oldPosition = transform.position; currentHealth = maxHealth; startPosition = transform.position; }
public void Init() { if (randomWaypoint == null) { randomWaypoint = new vFisherYatesRandom(); } if (randomPatrolPoint == null) { randomPatrolPoint = new vFisherYatesRandom(); } currentWaypoint = -1; currentPatrolPoint = -1; fwd = transform.forward; destination = transform.position; agent = GetComponent <UnityEngine.AI.NavMeshAgent>(); agent.updateRotation = false; agentPath = new UnityEngine.AI.NavMeshPath(); sphereSensor = GetComponentInChildren <v_AISphereSensor>(); if (sphereSensor) { sphereSensor.SetColliderRadius(maxDetectDistance); } animator = GetComponent <Animator>(); meleeManager = GetComponent <vMeleeManager>(); canAttack = true; attackCount = 0; sideMovement = GetRandonSide(); destination = transform.position; _rigidbody = GetComponent <Rigidbody>(); _rigidbody.useGravity = false; _rigidbody.isKinematic = false; _rigidbody.constraints = RigidbodyConstraints.None | RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ; _capsuleCollider = GetComponent <CapsuleCollider>(); healthSlider = GetComponentInChildren <v_SpriteHealth>(); head = animator.GetBoneTransform(HumanBodyBones.Head); oldPosition = transform.position; currentHealth = maxHealth; method = OffMeshLinkMoveMethod.Grounded; // set up Actions jumpOverLayer = UnityEngine.AI.NavMesh.GetAreaFromName("JumpOver"); stepUpLayer = UnityEngine.AI.NavMesh.GetAreaFromName("StepUp"); climbUpLayer = UnityEngine.AI.NavMesh.GetAreaFromName("ClimbUp"); useJumpOver = ActionIsEnabled(AIActions.JumpOver); useStepUp = ActionIsEnabled(AIActions.StepUp); useClimbUp = ActionIsEnabled(AIActions.ClimbUp); startPosition = transform.position; }