/// <summary> /// Manage all Off Mesh Links /// </summary> protected virtual void CheckOffMeshLinks() { if (Agent.isOnOffMeshLink) { OffMeshLinkData CurrentOffmeshLink_Data = Agent.currentOffMeshLinkData; OffMeshLink CurrentOffMeshLink = CurrentOffmeshLink_Data.offMeshLink; //Check if the OffMeshLink is a Custom Off Mesh Link ActionZone OffMeshZone = null; if (CurrentOffMeshLink) //Checking if the OffMeshLink is an Action Zone { OffMeshZone = CurrentOffMeshLink.GetComponentInChildren <ActionZone>(); if (!OffMeshZone) { OffMeshZone = CurrentOffMeshLink.GetComponentInParent <ActionZone>(); } } if (OffMeshZone) { if (!StartingAction) //If the Target is an Action Zone Start the Action { StartingAction = true; animal.Action = true; //Activate the Action on the Animal return; } } if (CurrentOffmeshLink_Data.linkType == OffMeshLinkType.LinkTypeManual) { Transform NearTransform = CurrentOffMeshLink.startTransform; if (CurrentOffMeshLink.endTransform.position == CurrentOffmeshLink_Data.startPos) //Verify the start point of the OffMeshLink { NearTransform = CurrentOffMeshLink.endTransform; } StartCoroutine(MalbersTools.AlignTransformsC(transform, NearTransform, 0.5f, false, true)); //Aling the Animal to the Link if (CurrentOffMeshLink.area == 2) //if the OffMesh Link is a Jump type { animal.SetJump(); } } } }
/// <summary> /// Manage all Off Mesh Links /// </summary> protected virtual void CheckOffMeshLinks() { if (isFlying) { return; } if (Agent.isOnOffMeshLink) { OffMeshLinkData CurrentOffmeshLink_Data = Agent.currentOffMeshLinkData; OffMeshLink CurrentOffMeshLink = CurrentOffmeshLink_Data.offMeshLink; //Check if the OffMeshLink is a Custom Off Mesh Link ActionZone OffMeshZone = null; if (CurrentOffMeshLink) //Checking if the OffMeshLink is an Action Zone { OffMeshZone = CurrentOffMeshLink.GetComponentInChildren <ActionZone>(); if (!OffMeshZone) { OffMeshZone = CurrentOffMeshLink.GetComponentInParent <ActionZone>(); } } if (OffMeshZone) { if (!StartingAction) //If the Target is an Action Zone Start the Action { StartingAction = true; animal.Action = true; //Activate the Action on the Animal return; } } if (CurrentOffmeshLink_Data.linkType == OffMeshLinkType.LinkTypeManual) //Means that it has a OffMesh Link component { Transform NearTransform = CurrentOffMeshLink.startTransform; if (CurrentOffMeshLink.endTransform.position == CurrentOffmeshLink_Data.startPos) //Verify the start point of the OffMeshLink { NearTransform = CurrentOffMeshLink.endTransform; } StartCoroutine(MalbersTools.AlignTransformsC(transform, NearTransform, 0.5f, false, true)); //Aling the Animal to the Link try { if (CurrentOffMeshLink.CompareTag("Fly")) { animal.SetFly(true); isFlying = true; StartCoroutine(FlyTowardsTarget(CurrentOffMeshLink.endTransform)); return; } } catch { /*Debug.LogWarning("There's no Fly Tag");*/ } if (CurrentOffMeshLink.area == 2) //if the OffMesh Link is a Jump type { animal.SetJump(); } } } }