/// <summary> /// 오프메시링크 관련 상태 : 벽 오르기(Wall), 뛰어내리기(Cliff) /// **서버에 어떻게 주지? /// </summary> public void OffLinkStateCheck() { if (offLink == null && nav.isOnOffMeshLink) { CAIPacket _aiPacket = networkAITransmitor.GetAIPacket(); offLink = nav.currentOffMeshLinkData.offMeshLink; if (offLink.CompareTag("Wall")) { state = AIState.CLIMB; networkAITransmitor.SetCurAIAction(AiAction.Climb); } else if (offLink.CompareTag("Cliff")) { state = AIState.LAND; networkAITransmitor.SetCurAIAction(AiAction.Land); _aiPacket.SetAIAngleR(transform.rotation.eulerAngles.y); } _aiPacket.SetAIAction(networkAITransmitor.GetCurAIAction()); _aiPacket.SetAIPosition(transform.position); AIChangeState(state); } // **여기서 전송 }
/// <summary> /// Manage all Off Mesh Links /// </summary> protected virtual void CheckOffMeshLinks() { if (isFlying) { return; } if (Agent.isOnOffMeshLink && !EnterOFFMESH) //Check if the Agent is on a OFF MESH LINK { EnterOFFMESH = true; //Just to avoid entering here again while we are on a OFF MESH LINK OffMeshLinkData OMLData = Agent.currentOffMeshLinkData; if (OMLData.linkType == OffMeshLinkType.LinkTypeManual) //Means that it has a OffMesh Link component { OffMeshLink CurrentOML = OMLData.offMeshLink; //Check if the OffMeshLink is a Custom Off Mesh Link ActionZone OffMeshZone = CurrentOML.GetComponentInParent <ActionZone>(); if (OffMeshZone && !OnAction) //if the OffmeshLink is a zone and is not making an action { animal.Action = OnAction = true; //Activate the Action on the Animal return; } var DistanceEnd = (transform.position - CurrentOML.endTransform.position).sqrMagnitude; var DistanceStart = (transform.position - CurrentOML.startTransform.position).sqrMagnitude; var NearTransform = DistanceEnd < DistanceStart ? CurrentOML.endTransform : CurrentOML.startTransform; StartCoroutine(MalbersTools.AlignTransformsC(transform, NearTransform, 0.15f, false, true)); //Aling the Animal to the Link Position if (CurrentOML.area == 2) { animal.SetJump(); //if the OffMesh Link is a Jump type } try { if (CurrentOML.CompareTag("Fly")) { animal.SetFly(true); isFlying = true; StartCoroutine(FlyTowardsTarget(CurrentOML.endTransform)); return; } } catch {} } else if (OMLData.linkType == OffMeshLinkType.LinkTypeJumpAcross) //Means that it has a OffMesh Link component { animal.SetJump(); } } }
protected virtual void CheckOffMeshLinks() { if (Agent.isOnOffMeshLink && !EnterOFFMESH) //Check if the Agent is on a OFF MESH LINK { EnterOFFMESH = true; //Just to avoid entering here again while we are on a OFF MESH LINK OffMeshLinkData OMLData = Agent.currentOffMeshLinkData; if (OMLData.linkType == OffMeshLinkType.LinkTypeManual) //Means that it has a OffMesh Link component { OffMeshLink CurrentOML = OMLData.offMeshLink; //Check if the OffMeshLink is a Manually placed Link Zone IsOffMeshZone = CurrentOML.GetComponentInParent <Zone>(); //Search if the OFFMESH IS An ACTION ZONE (EXAMPLE CRAWL) if (IsOffMeshZone) //if the OffmeshLink is a zone and is not making an action { IsOffMeshZone.ActivateZone(true); //Activate the Zone return; } var DistanceEnd = (transform.position - CurrentOML.endTransform.position).sqrMagnitude; var DistanceStart = (transform.position - CurrentOML.startTransform.position).sqrMagnitude; //Debug.Log("OMMESH FLY"); if (CurrentOML.CompareTag("Fly")) { var FarTransform = DistanceEnd > DistanceStart ? CurrentOML.endTransform : CurrentOML.startTransform; //Debug.Log("OMMESH FLY"); FlyOffMesh(FarTransform); } else if (CurrentOML.area == 2) //2 is Off mesh Jump { var NearTransform = DistanceEnd < DistanceStart ? CurrentOML.endTransform : CurrentOML.startTransform; StartCoroutine(MalbersTools.AlignTransform_Rotation(transform, NearTransform.rotation, 0.15f)); //Aling the Animal to the Link Position animal.State_Activate(StateEnum.Jump); //2 is Jump State //if the OffMesh Link is a Jump type } } else if (OMLData.linkType == OffMeshLinkType.LinkTypeJumpAcross) //Means that it has a OffMesh Link component { animal.State_Activate(StateEnum.Jump); //2 is Jump State } } }
/// <summary> /// Manage all Off Mesh Links /// </summary> protected virtual void CheckOffMeshLinks() { if (Agent.isOnOffMeshLink && !EnterOFFMESH) //Check if the Agent is on a OFF MESH LINK { EnterOFFMESH = true; //Just to avoid entering here again while we are on a OFF MESH LINK OffMeshLinkData OMLData = Agent.currentOffMeshLinkData; if (OMLData.linkType == OffMeshLinkType.LinkTypeManual) //Means that it has a OffMesh Link component { OffMeshLink CurrentOML = OMLData.offMeshLink; //Check if the OffMeshLink is a Manually placed Link ActionZone Is_a_OffMeshZone = CurrentOML.GetComponentInParent <ActionZone>(); //Search if the OFFMESH IS An ACTION ZONE (EXAMPLE CRAWL) if (Is_a_OffMeshZone && !DoingAnAction) //if the OffmeshLink is a zone and is not making an action { animal.Action = DoingAnAction = true; //Activate the Action on the Animal return; } var DistanceEnd = (transform.position - CurrentOML.endTransform.position).sqrMagnitude; var DistanceStart = (transform.position - CurrentOML.startTransform.position).sqrMagnitude; var NearTransform = DistanceEnd < DistanceStart ? CurrentOML.endTransform : CurrentOML.startTransform; var FarTransform = DistanceEnd > DistanceStart ? CurrentOML.endTransform : CurrentOML.startTransform; StartCoroutine(MalbersTools.AlignTransform_Rotation(transform, NearTransform.rotation, 0.15f)); //Aling the Animal to the Link Position if (animal.canFly && CurrentOML.CompareTag("Fly")) { Debuging(name + ": Fly OffMesh"); StartCoroutine(CFlyOffMesh(FarTransform)); } else if (CurrentOML.area == 2) { animal.SetJump(); //if the OffMesh Link is a Jump type } } else if (OMLData.linkType == OffMeshLinkType.LinkTypeJumpAcross) //Means that it has a OffMesh Link component { animal.SetJump(); } } }
public override void GuestAction() { base.GuestAction(); Collider[] _colLink = Physics.OverlapSphere(transform.position, 0.5f); for (int i = 0; i < _colLink.Length; i++) { try { offLink = _colLink[i].transform.parent.GetComponent <OffMeshLink>(); if (offLink != null && offLink.CompareTag("Cliff")) { Debug.Log("컴포넌트:" + _colLink[i].transform.parent.name); Debug.Log(offLink.startTransform.position + "," + offLink.endTransform.position); nav.autoTraverseOffMeshLink = false; nav.enabled = false; isAction = true; StartCoroutine(Cliffing()); break; } } catch { }; } }
/// <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(); } } } }