/// <summary> /// executes on match target start /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> public override void onMatchTargetStart(TPCharacter character, IKHelper limbsIK) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null!" + " < " + this.ToString() + ">"); #endif return; } if (limbsIK) { limbsIK.LHandIKEnabled = true; limbsIK.LHWeightTime = 0.0f; limbsIK.RHandIKEnabled = true; limbsIK.RHWeightTime = 0.0f; limbsIK.LFootIKEnabled = false; limbsIK.RFootIKEnabled = false; limbsIK.setIKDirection(true); } m_TriggerInfo.doRotationToTarget = true; m_TriggerInfo.rot_time = 0.0f; base.onMatchTargetStart(character, limbsIK); }
/// <summary> /// end trigger animations /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> public override void end(TPCharacter character, IKHelper limbsIK) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null!" + " < " + this.ToString() + ">"); #endif return; } if (!Target) { #if DEBUG_INFO Debug.LogWarning("trigger target not assigned!" + " < " + this.ToString() + ">"); #endif return; } if (limbsIK && enableCatchIK) { limbsIK.setIKDirection(false); limbsIK.OnReachZeroRH = () => { limbsIK.RHandIKEnabled = false; limbsIK.OnReachZeroRH = null; }; } character.triggerRootMotion = false; character.disableMove = false; character.enablePhysics(); character.animator.SetBool(HashIDs.JumpOnBool, false); }
/// <summary> /// check if there is wall in front of character /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbIK">ik helper class</param> /// <param name="inpos">input position</param> /// <param name="target">target transform</param> /// <param name="moveright">move right or left</param> /// <returns>returns true if wall is in front otherwise false</returns> private bool _checkIsWallUnderTarget(TPCharacter character, IKHelper limbIK, Vector3 inpos, Transform target, bool moveright = true) { Vector3 offset = new Vector3(0.0f, character.capsule.height * 0.5f, 0.25f); offset = target.rotation * offset; Vector3 pos = inpos - offset; float ledgeLength = (character.ledge.rightPoint - character.ledge.leftPoint).magnitude; Vector3 ledgeDir = character.getLedgeDirection(); float dirOffset = Mathf.Min(ledgeLength, character.capsule.radius); if (moveright) { pos -= ledgeDir * dirOffset; } else { pos += ledgeDir * dirOffset; } Ray ray = new Ray(pos, target.forward); RaycastHit hit; int mask = character.layers; float radius = character.capsule.radius * 0.38f; float dist = limbIK.hangCheckDistance + 0.25f; if (Physics.SphereCast(ray, radius, out hit, dist, mask)) { return(true); } return(false); }
/// <summary> /// start trigger interaction /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> /// <param name="use">use flag</param> /// <param name="jump">jump flag</param> /// <param name="v">vertical value</param> /// <param name="h">horizontal value</param> /// <returns>all succeded</returns> public override bool start(TPCharacter character, IKHelper limbsIK, bool use, bool secondaryUse, bool jump, float v, float h) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null!" + " < " + this.ToString() + ">"); #endif return(false); } if (!Target) { #if DEBUG_INFO Debug.LogWarning("trigger target not assigned!" + " < " + this.ToString() + ">"); #endif return(false); } if (!use) { return(false); } Vector3 pt1, pt2; float scalez = Target.localScale.z * 0.5f; Utils.CalculateLinePoints(Target, out pt1, out pt2, -scalez, switchTargetDirection); Vector3 checkpos = character.transform.position; Vector3 closest = MathUtils.GetClosestPoint2Line(pt1, pt2, ref checkpos); m_TriggerInfo.avatarTarget = catchTarget; m_TriggerInfo.transform = Target; m_TriggerInfo.pos_offset = closest - Target.position; m_TriggerInfo.stateName = "Base Layer.TRIGGERS.JumpForward"; character.disableMove = true; character.rigidBody.velocity = Vector3.zero; m_TriggerInfo.doMatchTarget = true; character.OnLerpEnd = () => { character.animator.SetBool(/*"pJumpForward"*/ HashIDs.JumpForwardBool, true); m_TriggerInfo.targetRotation = character.transform.rotation; m_TriggerInfo.startRotation = character.transform.rotation; character.triggerRootMotion = true; character.OnLerpEnd = null; }; Quaternion rotation = transform.rotation; Vector3 euler = rotation.eulerAngles; euler.z = 0.0f; euler.x = 0.0f; Quaternion fromEuler = Quaternion.Euler(euler); if (switchTargetDirection) { fromEuler *= Quaternion.AngleAxis(180, character.transform.up); } float forwAmt = Mathf.Min(character.forwardAmount, 0.5f); character.lerpToTransform(null, fromEuler, 0f, 0.2f, forwAmt, false, false); return(true); }
/// <summary> /// end trigger animations /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> public override void end(TPCharacter character, IKHelper limbsIK) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null!" + " < " + this.ToString() + ">"); #endif return; } if (!Target) { #if DEBUG_INFO Debug.LogWarning("trigger target not assigned!" + " < " + this.ToString() + ">"); #endif return; } character.triggerRootMotion = false; character.disableMove = false; character.setMoveMode(TPCharacter.MovingMode.Ledge); OrbitCameraController oc = character.GetComponentInChildren <OrbitCameraController>(); if (oc) { oc.additiveRotation = true; } character.disableCapsuleScale = true; character.animator.SetBool(/*"pGrabLedgeUp"*/ HashIDs.GrabLedgeUpBool, false); character.animator.SetBool(/*"pOnLedge"*/ HashIDs.OnLedgeBool, true); character.animatorDampTime = 0.0f; character.ledgeMove = true; character.disableLedgeConstraint = false; character.fullStop(); character.jumpAllowed = true; if (limbsIK) { limbsIK.RHandIKEnabled = true; limbsIK.LFootIKEnabled = true; limbsIK.RFootIKEnabled = true; limbsIK.LHandIKEnabled = true; limbsIK.LFWeightTime = 0.0f; limbsIK.RFWeightTime = 0.0f; limbsIK.startLedgeAdjust(m_TriggerInfo.targetRotation); limbsIK.checkHang = true; } if (character.animator.GetBool(/*"pLedgeHang"*/ HashIDs.LedgeHangBool)) { character.restoreCapsuleSize(); } else { character.scaleCapsuleToHalf(); } }
/// <summary> /// end trigger animations /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> public override void end(TPCharacter character, IKHelper limbsIK) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null!" + " < " + this.ToString() + ">"); #endif return; } if (!Target) { #if DEBUG_INFO Debug.LogWarning("trigger target not assigned!" + " < " + this.ToString() + ">"); #endif return; } // reset steps audio clips to character character.audioManager.ladderClips = null; character.triggerRootMotion = false; character.disableMove = false; character.enablePhysics(); if (GoingUp) { character.animator.SetBool(/*"pLadderUp"*/ HashIDs.LadderUpBool, false); } else { character.animator.SetBool(/*"pLadderDown"*/ HashIDs.LadderDownBool, false); } Vector3 right = character.transform.right; character.transform.up = Vector3.up; character.transform.right = right; if (limbsIK) { limbsIK.handIKMode = IKMode.Default; limbsIK.feetIKMode = IKMode.Default; limbsIK.setIKDirection(false); limbsIK.OnReachZeroLH = () => { limbsIK.LHandIKEnabled = false; limbsIK.OnReachZeroLH = null; }; limbsIK.OnReachZeroRH = () => { limbsIK.RHandIKEnabled = false; limbsIK.OnReachZeroRH = null; }; limbsIK.LFootIKEnabled = false; limbsIK.RFootIKEnabled = false; } }
/// <summary> /// executes on match target start /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> public override void onMatchTargetStart(TPCharacter character, IKHelper limbsIK) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null!" +" < " + this.ToString() + ">"); #endif return; } character.disablePhysics(true, false, false); m_TriggerInfo.doRotationToTarget = false; m_TriggerInfo.rot_time = 0.0f; base.onMatchTargetStart(character, limbsIK); }
bool _createIKHelper() { IKHelper ikh = character.GetComponent <IKHelper>(); if (!ikh) { ikh = Undo.AddComponent <IKHelper>(character); } ikh.footOffset = 0.1f; ikh.hangCheckDistance = 0.3f; ikh.ledgeRelativePosition = new Vector3(0.0f, -1.1f, -0.4f); ikh.ledgeRelativePositionHang = new Vector3(0.0f, -2.15f, -0.1f); return(true); }
/// <summary> /// start trigger interaction /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> /// <param name="use">use flag</param> /// <param name="jump">jump flag</param> /// <param name="v">vertical value</param> /// <param name="h">horizontal value</param> /// <returns>all succeded</returns> public override bool start(TPCharacter character, IKHelper limbsIK, bool use, bool secondaryUse, bool jump, float v, float h) { if (use) { IGameCharacter icharacter = character.GetComponent <IGameCharacter>(); if (icharacter != null) { icharacter.setNewItem(item); } } if (secondaryUse) { IGameCharacter icharacter = character.GetComponent <IGameCharacter>(); if (icharacter != null) { icharacter.setSecondaryItem(item); } } return(false); }
/// <summary> /// executes on match target start /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> public virtual void onMatchTargetStart(TPCharacter character, IKHelper limbsIK) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null. " + " < " + this.ToString() + ">"); #endif return; } #if DEBUG_INFO if (!character.audioManager) { Debug.LogError("object cannot be null. " + " < " + this.ToString() + ">"); return; } #endif character.audioManager.playJumpSound(); m_TriggerInfo.rot_time = 0.0f; m_TriggerInfo.doMatchTarget = true; m_TriggerInfo.startRotation = character.transform.rotation; }
/// <summary> /// initilaize component /// </summary> public void initialize() { if (m_initialized) { return; } m_Character = GetComponent <TPCharacter>(); if (!m_Character) { Debug.LogError("cannot find 'TPCharacter' component. " + " < " + this.ToString() + ">"); return; } m_Character.initialize(); m_Player = GetComponent <Player>(); if (!m_Player) { Debug.LogError("Cannot find 'Player' component. " + " < " + this.ToString() + ">"); return; } IKHelper ls = GetComponent <IKHelper>(); if (ls) { if (ls.enabled) { m_IKHelper = ls; } } if (!m_TriggerUI) { Debug.LogError("Trigger UI not assigned! " + " < " + this.ToString() + ">"); return; } m_TriggerUI.text = ""; m_initialized = true; }
/// <summary> /// end trigger animations /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> public override void end(TPCharacter character, IKHelper limbsIK) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null!" +" < " + this.ToString() + ">"); #endif return; } if (!Target) { #if DEBUG_INFO Debug.LogWarning("trigger target not assigned!" +" < " + this.ToString() + ">"); #endif return; } character.triggerRootMotion = false; character.disableMove = false; character.enablePhysics(); character.animator.SetBool(/*"pJumpDown"*/HashIDs.JumpDownBool, false); }
/// <summary> /// start trigger interaction /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> /// <param name="use">use flag</param> /// <param name="jump">jump flag</param> /// <param name="v">vertical value</param> /// <param name="h">horizontal value</param> /// <returns>all succeded</returns> public override bool start(TPCharacter character, IKHelper limbsIK, bool use, bool secondaryUse, bool jump, float v, float h) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null!" + " < " + this.ToString() + ">"); #endif return(false); } if (!Target) { #if DEBUG_INFO Debug.LogWarning("trigger target not assigned!" + " < " + this.ToString() + ">"); #endif return(false); } if (!use) { return(false); } float scalez = Target.localScale.z * 0.5f; character.setLedge(Target, false, -scalez); Vector3 checkpos = character.transform.position; Vector3 closest = MathUtils.GetClosestPoint2Line(character.ledge.leftPoint, character.ledge.rightPoint, ref checkpos); bool moveright = true; m_TriggerInfo.avatarTarget = AvatarTarget.RightHand; if (closest == character.ledge.leftPoint) { m_TriggerInfo.avatarTarget = AvatarTarget.LeftHand; moveright = false; } m_TriggerInfo.transform = Target; m_TriggerInfo.pos_offset = closest - Target.position; m_TriggerInfo.CatchPosition = closest; character.disableLedgeConstraint = true; // disable ledge constraining or character may be stuck if outside ledge bounds character.disableMove = true; character.rigidBody.velocity = Vector3.zero; if (limbsIK) { limbsIK.LHandIKEnabled = false; limbsIK.RHandIKEnabled = false; limbsIK.LFootIKEnabled = false; limbsIK.RFootIKEnabled = false; limbsIK.checkHang = false; limbsIK.handIKMode = IKMode.ToLine; limbsIK.LeftHandPtA = character.ledge.leftPoint; limbsIK.LeftHandPtB = character.ledge.rightPoint; limbsIK.RightHandPtA = character.ledge.leftPoint; limbsIK.RightHandPtB = character.ledge.rightPoint; Vector3 pos = character.transform.position; closest = MathUtils.GetClosestPoint2Line(character.ledge.leftPoint, character.ledge.rightPoint, ref pos); bool checkUnder = _checkIsWallUnderTarget(character, limbsIK, closest, Target, moveright); if (checkUnder) { character.animator.SetBool(/*"pLedgeHang"*/ HashIDs.LedgeHangBool, false); m_TriggerInfo.stateName = "Base Layer.LEDGE.JumpToLedgeState"; limbsIK.currentRelLedgePosition = limbsIK.ledgeRelativePosition; } else { character.animator.SetBool(/*"pLedgeHang"*/ HashIDs.LedgeHangBool, true); m_TriggerInfo.stateName = "Base Layer.LEDGE.Jump2Ledge_Hang"; limbsIK.currentRelLedgePosition = limbsIK.ledgeRelativePositionHang; } } else { character.animator.SetBool(/*"pLedgeHang"*/ HashIDs.LedgeHangBool, true); m_TriggerInfo.stateName = "Base Layer.LEDGE.Jump2Ledge_Hang"; } m_TriggerInfo.doMatchTarget = true; character.OnLerpEnd = () => { character.disableMove = true; character.disablePhysics(true, true); character.animator.SetBool(/*"pGrabLedgeUp"*/ HashIDs.GrabLedgeUpBool, true); character.jumpAllowed = false; Quaternion targetRot = Target.rotation; Vector3 targetEuler = targetRot.eulerAngles; targetEuler.z = 0.0f; targetEuler.x = 0.0f; if (switchTargetDirection) { targetRot *= Quaternion.AngleAxis(180, character.transform.up); } Quaternion fromTargetEuler = Quaternion.Euler(targetEuler); m_TriggerInfo.targetRotation = fromTargetEuler; m_TriggerInfo.startRotation = character.transform.rotation; character.triggerRootMotion = true; character.OnLerpEnd = null; }; Quaternion rotation = transform.rotation; Vector3 euler = rotation.eulerAngles; euler.z = 0.0f; euler.x = 0.0f; Quaternion fromEuler = Quaternion.Euler(euler); character.lerpToTransform(null, fromEuler, 0f, 0.2f); return(true); }
/// <summary> /// start trigger interaction /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> /// <param name="use">use flag</param> /// <param name="jump">jump flag</param> /// <param name="v">vertical value</param> /// <param name="h">horizontal value</param> /// <returns>all succeded</returns> public abstract bool start(TPCharacter character, IKHelper limbsIK, bool use, bool secondaryUse, bool jump, float v, float h);
/// <summary> /// executes on match target end /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> public virtual void onMatchTargetEnd(TPCharacter character, IKHelper limbsIK) { }
/// <summary> /// end trigger animations /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> public abstract void end(TPCharacter character, IKHelper limbsIK);
/// <summary> /// end trigger animations /// NOTE: Does nothing on ItemTrigger /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> public override void end(TPCharacter character, IKHelper limbsIK) { }
/// <summary> /// start trigger interaction /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> /// <param name="use">use flag</param> /// <param name="jump">jump flag</param> /// <param name="v">vertical value</param> /// <param name="h">horizontal value</param> /// <returns>all succeded</returns> public override bool start(TPCharacter character, IKHelper limbsIK, bool use, bool secondaryUse, bool jump, float v, float h) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null!" + " < " + this.ToString() + ">"); #endif return(false); } if (!Target) { #if DEBUG_INFO Debug.LogWarning("trigger target not assigned!" + " < " + this.ToString() + ">"); #endif return(false); } if (!use) { return(false); } // example of IK if (limbsIK && enableCatchIK) { limbsIK.RHandIKEnabled = true; limbsIK.RHWeightTime = 0.0f; limbsIK.setIKDirection(true); limbsIK.handIKMode = IKMode.Default; Transform rightHandT = character.animator.GetBoneTransform(HumanBodyBones.RightHand); Vector3? closest2RH = closestPoint(rightHandT.position); limbsIK.RHPosition = closest2RH.Value; } if (turnToLedge) { Vector3?closestMid = closestPoint(character.transform.position); Vector3 direction = (closestMid.Value - character.transform.position); direction.y = 0.0f; direction.Normalize(); Vector3 pt1, pt2; float scalez = Target.localScale.z * 0.5f; bool face = Vector3.Dot(Target.forward, direction) < 0; Utils.CalculateLinePoints(Target, out pt1, out pt2, -scalez, face); Vector3 checkpos = character.transform.position; Vector3 closest = MathUtils.GetClosestPoint2Line(pt1, pt2, ref checkpos); m_TriggerInfo.avatarTarget = AvatarTarget.RightFoot; m_TriggerInfo.transform = Target; m_TriggerInfo.pos_offset = closest - Target.position; m_TriggerInfo.stateName = "Base Layer.TRIGGERS.JumpOn"; character.disableMove = true; character.rigidBody.velocity = Vector3.zero; m_TriggerInfo.doMatchTarget = true; character.OnLerpEnd = () => { character.animator.SetBool(HashIDs.JumpOnBool, true); Quaternion targetRot = Quaternion.LookRotation(direction); m_TriggerInfo.targetRotation = targetRot; m_TriggerInfo.startRotation = character.transform.rotation; character.triggerRootMotion = true; character.OnLerpEnd = null; }; Quaternion rotation = Quaternion.LookRotation(direction); float forwAmt = Mathf.Min(character.forwardAmount, 0.5f); character.lerpToTransform(null, rotation, 0f, 0.2f, forwAmt, false, false); } else { Vector3 pt1, pt2; float scalez = Target.localScale.z * 0.5f; Utils.CalculateLinePoints(Target, out pt1, out pt2, -scalez, switchTargetDirection); Vector3 checkpos = character.transform.position; Vector3 closest = MathUtils.GetClosestPoint2Line(pt1, pt2, ref checkpos); m_TriggerInfo.avatarTarget = AvatarTarget.RightFoot; //RightHand; m_TriggerInfo.transform = Target; m_TriggerInfo.pos_offset = closest - Target.position; m_TriggerInfo.stateName = "Base Layer.TRIGGERS.JumpOn"; character.disableMove = true; character.rigidBody.velocity = Vector3.zero; m_TriggerInfo.doMatchTarget = true; character.OnLerpEnd = () => { character.animator.SetBool(HashIDs.JumpOnBool, true); Quaternion targetRot = Target.rotation; Vector3 targetEuler = targetRot.eulerAngles; targetEuler.z = 0.0f; targetEuler.x = 0.0f; if (switchTargetDirection) { targetEuler.y += 180.0f; } Quaternion fromTargetEuler = Quaternion.Euler(targetEuler); m_TriggerInfo.targetRotation = fromTargetEuler; m_TriggerInfo.startRotation = character.transform.rotation; character.triggerRootMotion = true; character.OnLerpEnd = null; }; Quaternion rotation = transform.rotation; Vector3 euler = rotation.eulerAngles; euler.z = 0.0f; euler.x = 0.0f; Quaternion fromEuler = Quaternion.Euler(euler); float forwAmt = Mathf.Min(character.forwardAmount, 0.5f); character.lerpToTransform(null, fromEuler, 0f, 0.2f, forwAmt, false, false); } return(true); }
/// <summary> /// start trigger interaction /// </summary> /// <param name="character">character interacting with trigger</param> /// <param name="limbsIK">ik helper</param> /// <param name="use">use flag</param> /// <param name="jump">jump flag</param> /// <param name="v">vertical value</param> /// <param name="h">horizontal value</param> /// <returns>all succeded</returns> public override bool start(TPCharacter character, IKHelper limbsIK, bool use, bool secondaryUse, bool jump, float v, float h) { if (!character) { #if DEBUG_INFO Debug.LogError("object cannot be null!" + " < " + this.ToString() + ">"); #endif return(false); } if (!Target) { #if DEBUG_INFO Debug.LogWarning("trigger target not assigned!" + " < " + this.ToString() + ">"); #endif return(false); } if (!use) { return(false); } //if (!m_TriggerInfo) m_TriggerInfo = new TriggerInfo(); m_TriggerInfo.doMatchTarget = false; m_TriggerInfo.doRotationToTarget = false; Vector3 direction = GoingUp ? Target.forward : -Target.forward; float distanceFromTarget = (character.transform.position - Target.position).magnitude; float angle = Vector3.Angle(character.transform.forward, direction) * 0.002f; float pos_rot_time = distanceFromTarget + angle; if (pos_rot_time < 0.1f) { if (limbsIK) { limbsIK.handIKMode = IKMode.ToLine; limbsIK.setIKDirection(true); if (LeftHandHold) { limbsIK.LeftHandPtA = LeftHandHold.position - LeftHandHold.up * 100.0f; limbsIK.LeftHandPtB = LeftHandHold.position + LeftHandHold.up * 100.0f; limbsIK.LHandIKEnabled = true; limbsIK.LHWeightTime = 0.0f; } else { limbsIK.LHandIKEnabled = false; } if (RightHandHold) { limbsIK.RightHandPtA = RightHandHold.position - RightHandHold.up * 100.0f; limbsIK.RightHandPtB = RightHandHold.position + RightHandHold.up * 100.0f; limbsIK.RHandIKEnabled = true; limbsIK.RHWeightTime = 0.0f; } else { limbsIK.RHandIKEnabled = false; } limbsIK.feetIKMode = IKMode.ToPlane; if (LeftFootHold) { Vector3 lpt1 = LeftFootHold.position; Vector3 lpt2 = lpt1 + LeftFootHold.up; Vector3 lpt3 = lpt1 + LeftFootHold.forward; limbsIK.LeftFootPlane.Set3Points(lpt1, lpt2, lpt3); limbsIK.LFootIKEnabled = true; } else { limbsIK.LFootIKEnabled = false; } if (RightFootHold) { Vector3 rpt1 = RightFootHold.position; Vector3 rpt2 = rpt1 + RightFootHold.up; Vector3 rpt3 = rpt1 + RightFootHold.forward; limbsIK.RightFootPlane.Set3Points(rpt1, rpt2, rpt3); limbsIK.RFootIKEnabled = true; } else { limbsIK.RFootIKEnabled = false; } } character.disablePhysics(false, true); character.OnSetTransform = () => { //set steps audio clips to character character.audioManager.ladderClips = ladderSounds; character.disablePhysics(false, true); if (GoingUp) { character.animator.SetBool(/*"pLadderUp"*/ HashIDs.LadderUpBool, true); } else { character.animator.SetBool(/*"pLadderDown"*/ HashIDs.LadderDownBool, true); } character.animator.SetInteger(/*"pLadderSize"*/ HashIDs.LadderSizeInt, (int)LadderSize); character.OnSetTransform = null; }; Quaternion targetRot = Target.rotation; if (switchTargetDirection) { targetRot *= Quaternion.AngleAxis(180, character.transform.up); } if (!GoingUp) { targetRot *= Quaternion.AngleAxis(180, character.transform.up); } character.setTransform(Target.position, targetRot, true); character.triggerRootMotion = true; } else { float forw = 0.5f; bool crouch = false; character.OnLerpEnd = () => { if (limbsIK) { limbsIK.handIKMode = IKMode.ToLine; limbsIK.setIKDirection(true); if (LeftHandHold) { limbsIK.LeftHandPtA = LeftHandHold.position - LeftHandHold.up * 100.0f; limbsIK.LeftHandPtB = LeftHandHold.position + LeftHandHold.up * 100.0f; limbsIK.LHandIKEnabled = true; limbsIK.LHWeightTime = 0.0f; } else { limbsIK.LHandIKEnabled = false; } if (RightHandHold) { limbsIK.RightHandPtA = RightHandHold.position - RightHandHold.up * 100.0f; limbsIK.RightHandPtB = RightHandHold.position + RightHandHold.up * 100.0f; limbsIK.RHandIKEnabled = true; limbsIK.RHWeightTime = 0.0f; } else { limbsIK.RHandIKEnabled = false; } limbsIK.feetIKMode = IKMode.ToPlane; if (LeftFootHold) { Vector3 lpt1 = LeftFootHold.position; Vector3 lpt2 = lpt1 + LeftFootHold.up; Vector3 lpt3 = lpt1 + LeftFootHold.forward; limbsIK.LeftFootPlane.Set3Points(lpt1, lpt2, lpt3); limbsIK.LFootIKEnabled = true; } else { limbsIK.LFootIKEnabled = false; } if (RightFootHold) { Vector3 rpt1 = RightFootHold.position; Vector3 rpt2 = rpt1 + RightFootHold.up; Vector3 rpt3 = rpt1 + RightFootHold.forward; limbsIK.RightFootPlane.Set3Points(rpt1, rpt2, rpt3); limbsIK.RFootIKEnabled = true; } else { limbsIK.RFootIKEnabled = false; } } //set steps audio clips to character character.audioManager.ladderClips = ladderSounds; character.disablePhysics(false, true); if (GoingUp) { character.animator.SetBool(/*"pLadderUp"*/ HashIDs.LadderUpBool, true); } else { character.animator.SetBool(/*"pLadderDown"*/ HashIDs.LadderDownBool, true); } character.animator.SetInteger(/*"pLadderSize"*/ HashIDs.LadderSizeInt, (int)LadderSize); character.transform.position = Target.position; character.triggerRootMotion = true; character.OnLerpEnd = null; }; character.disableMove = true; Quaternion targetRot = Target.rotation; if (switchTargetDirection) { targetRot *= Quaternion.AngleAxis(180, character.transform.up); } if (!GoingUp) { targetRot *= Quaternion.AngleAxis(180, character.transform.up); } character.lerpToTransform( Target.position, targetRot, pos_rot_time, pos_rot_time, forw, crouch ); } return(true); }