public override void OnInspectorGUI() { m_target = (ClimbTarget)target; m_target.AssignPositions(); m_target.ShowTargets = true; DrawDefaultInspector(); }
private void StartRootRoutie(ClimbTarget newTarget) { switch (m_rootStyle) { case TransitionStyle.LINEAR: StartCoroutine(LinearInterpolation(m_animatedRoot, m_root.position, newTarget.RootTarget.position, m_rootTransitionSpeed)); break; case TransitionStyle.SMOOTH: StartCoroutine(SmootStepInterpolation(m_animatedRoot, m_root.position, newTarget.RootTarget.position, m_rootTransitionSpeed)); break; case TransitionStyle.SPRING: StartCoroutine(SpringInterpolation(m_animatedRoot, m_root.position, newTarget.RootTarget.position, m_rootTransitionSpeed, m_rootSpringTension)); break; case TransitionStyle.OVERSHOOT: StartCoroutine(OvershootInterpolation(m_animatedRoot, m_root.position, newTarget.RootTarget.position, m_rootTransitionSpeed, m_rootOvershootFactor)); break; case TransitionStyle.UPWARDCURVE: StartCoroutine(UpwardCurveInterpolation(m_animatedRoot, m_root.position, newTarget.RootTarget.position, m_rootTransitionSpeed, m_rootArcHeigh1, m_rootArcHeigh2, m_rootArcSample1, m_rootArcSample2)); break; default: break; } StartCoroutine(SmootStepInterpolation(m_animatedRoot, m_root.rotation, newTarget.RootTarget.rotation, m_rootTransitionSpeed)); }
public void SetFirstLeftNeighbour(ClimbTarget neighbour) { if (m_targets.Count > 0) { m_targets[0].LeftNeigbour = neighbour; } }
public void SetLastRightNeighbour(ClimbTarget neighbour) { if (m_targets.Count > 0) { m_targets[m_targets.Count - 1].RightNeigbour = neighbour; } }
public bool CreateClimbTarget() { GameObject instance = Instantiate(Resources.Load("ClimbTargetMid", typeof(GameObject))) as GameObject; instance.transform.parent = transform; instance.transform.position = transform.position; instance.transform.rotation = transform.rotation; if (instance != null) { instance.name = "ClimbTarget " + (m_targets.Count + 1); ClimbTarget target = instance.GetComponent <ClimbTarget>(); if (m_targets.Count > 0) { m_targets[m_targets.Count - 1].RightNeigbour = target; target.LeftNeigbour = m_targets[m_targets.Count - 1]; } else { LedgeEdge previousEdge = null; if ((previousEdge = VertexClosestToOrigin.EdgeClosestToOrigin) != null) { if (previousEdge.m_targets.Count > 0) { target.LeftNeigbour = previousEdge.m_targets[previousEdge.m_targets.Count - 1]; previousEdge.m_targets[previousEdge.m_targets.Count - 1].RightNeigbour = target; } } } m_targets.Add(target); return(true); } return(false); }
IEnumerator Move(ClimbTarget newTarget, int direction) { m_inTransition = true; // Start animation if (direction == 1) { //transform.position = transform.position + (newTarget.RootTarget.transform.position - transform.position).normalized *0.5f; yield return(m_climbingIK.MoveRightAnimation(newTarget)); } else if (direction == -1) { yield return(m_climbingIK.MoveLeftAnimation(newTarget)); } // Wait for animation to finish while (m_inTransition) { yield return(null); } // Animation is done, updates to new target m_currentClimbTarget = newTarget; transform.parent = newTarget.transform; print("Done"); }
// Go from wall climbing to ledge climbing private void SwitchToLedgeClimb(ClimbTarget initialTarget) { //print("SWITCH"); m_currentState = ClimbingState.LedgeClimbing; m_controllerWallClimbing.enabled = false; m_controllerLedgeClimbing.enabled = true; m_controllerLedgeClimbing.InitiateClimb(initialTarget); }
// Go into ledge climbing mode public void ActivateLedgeClimbing(ClimbTarget initialTarget) { m_currentState = ClimbingState.LedgeClimbing; transform.parent = initialTarget.transform; m_controllerLedgeClimbing.enabled = true; m_controllerLedgeClimbing.InitiateClimb(initialTarget); m_controllerPlayer.ActivateClimbing(); }
public void InitiateClimb(ClimbTarget initialTarget) { if (initialTarget != null) { m_currentClimbTarget = initialTarget; transform.parent = m_currentClimbTarget.transform; // Set IK Positions m_climbingIK.SetAllClimbTargets(m_currentClimbTarget); m_climbingIK.IK_Active = true; } }
public void UpdateMovement() { // Find input direction int moveDirection = 0; if (Input.GetKey(KeyCode.D)) { moveDirection += 1; } if (Input.GetKey(KeyCode.A)) { moveDirection -= 1; } // Move in direction if ((moveDirection != 0) && !m_inTransition) { ClimbTarget newTarget = null; if (moveDirection == 1) { if ((newTarget = m_currentClimbTarget.RightNeigbour) != null) { StartCoroutine(Move(newTarget, moveDirection)); } } else { if ((newTarget = m_currentClimbTarget.LeftNeigbour) != null) { StartCoroutine(Move(newTarget, moveDirection)); } } } // Drop if (Input.GetKey(KeyCode.S) && !m_inTransition) { m_climbingIK.IK_Active = false; // NOTE: Assumes climbTarget roots are only rotated in x transform.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0); m_controllerClimbing.DeactivateLedgeClimbing(); } // Vault if (Input.GetKeyDown(KeyCode.Space) && !m_inTransition) { if (CanVault()) { Vault(); } } }
// Used when succesfully reaced to a new climb target public void SetAllClimbTargets(ClimbTarget newTarget) { m_rightHandTarget = newTarget.RightHandTarget; m_leftHandTarget = newTarget.LeftHandTarget; m_rightFootTarget = newTarget.RightFootTarget; m_leftFootTarget = newTarget.LeftFootTarget; m_rightArmHint = newTarget.RightArmHint; m_leftArmHint = newTarget.LeftArmHint; m_rightLegHint = newTarget.RightLegHint; m_leftLegHint = newTarget.LeftLegHint; m_root = newTarget.RootTarget; SetAnimationTransforms(); }
public IEnumerator MoveRightAnimation(ClimbTarget newTarget) { SetAnimationTransforms(); StartLeadingRightRoutines(newTarget); yield return(new WaitForSeconds(m_beforeRootFollows)); StartRootRoutie(newTarget); yield return(new WaitForSeconds(m_beforeFollowingSideFollows)); StartFollowingRightRoutines(newTarget); while (m_activeRoutines > 0) /* Wait for animation to finish */ yield { return(null); } SetAllClimbTargets(newTarget); GetComponentInParent <ControllerLedgeClimbing>().InTransition = false; }
public void SetFurthestOutNeighbours() { if (m_targets.Count > 0) { LedgeVertex furthestOutVert = null; LedgeEdge forwardNeigbourEdge = null; if ((furthestOutVert = VertexFurthestFromOrigin) != null) { if ((forwardNeigbourEdge = furthestOutVert.EdgeFurthestFromOrigin) != null) { ClimbTarget furthestInOnNeighbourEdge; if ((furthestInOnNeighbourEdge = forwardNeigbourEdge.FirstTarget) != null) { ClimbTarget furthestOutTarget = LastTarget; furthestOutTarget.RightNeigbour = furthestInOnNeighbourEdge; furthestInOnNeighbourEdge.LeftNeigbour = furthestOutTarget; } } } } }
private void StartFollowingRightRoutines(ClimbTarget newTarget) { switch (m_followingHandStyle) { case TransitionStyle.LINEAR: StartCoroutine(LinearInterpolation(m_animatedLeftHand, m_leftHandTarget.position, newTarget.LeftHandTarget.position, m_followingHandTransitionSpeed)); StartCoroutine(LinearInterpolation(m_animatedLeftArmHint, m_leftArmHint.position, newTarget.LeftArmHint.position, m_followingHandTransitionSpeed)); break; case TransitionStyle.SMOOTH: StartCoroutine(SmootStepInterpolation(m_animatedLeftHand, m_leftHandTarget.position, newTarget.LeftHandTarget.position, m_followingHandTransitionSpeed)); StartCoroutine(SmootStepInterpolation(m_animatedLeftArmHint, m_leftArmHint.position, newTarget.LeftArmHint.position, m_followingHandTransitionSpeed)); break; case TransitionStyle.SPRING: StartCoroutine(SpringInterpolation(m_animatedLeftHand, m_leftHandTarget.position, newTarget.LeftHandTarget.position, m_followingHandTransitionSpeed, m_handSpringTension)); StartCoroutine(SpringInterpolation(m_animatedLeftArmHint, m_leftArmHint.position, newTarget.LeftArmHint.position, m_followingHandTransitionSpeed, m_handSpringTension)); break; case TransitionStyle.OVERSHOOT: StartCoroutine(OvershootInterpolation(m_animatedLeftHand, m_leftHandTarget.position, newTarget.LeftHandTarget.position, m_followingHandTransitionSpeed, m_handOvershootFactor)); StartCoroutine(OvershootInterpolation(m_animatedLeftArmHint, m_leftArmHint.position, newTarget.LeftArmHint.position, m_followingHandTransitionSpeed, m_handOvershootFactor)); break; case TransitionStyle.UPWARDCURVE: StartCoroutine(UpwardCurveInterpolation(m_animatedLeftHand, m_leftHandTarget.position, newTarget.LeftHandTarget.position, m_followingHandTransitionSpeed, m_handArcHeigh1, m_handArcHeigh2, m_handArcSample1, m_handArcSample2)); StartCoroutine(UpwardCurveInterpolation(m_animatedLeftArmHint, m_leftArmHint.position, newTarget.LeftArmHint.position, m_followingHandTransitionSpeed, m_handArcHeigh1, m_handArcHeigh2, m_handArcSample1, m_handArcSample2)); break; default: break; } StartCoroutine(SmootStepInterpolation(m_animatedLeftHand, m_leftHandTarget.rotation, newTarget.LeftHandTarget.rotation, m_followingHandTransitionSpeed)); StartCoroutine(SmootStepInterpolation(m_animatedLeftArmHint, m_leftArmHint.rotation, newTarget.LeftArmHint.rotation, m_followingHandTransitionSpeed)); switch (m_followingFootStyle) { case TransitionStyle.LINEAR: StartCoroutine(LinearInterpolation(m_animatedLeftFoot, m_leftFootTarget.position, newTarget.LeftFootTarget.position, m_followingFootTransitionSpeed)); StartCoroutine(LinearInterpolation(m_animatedLeftLegHint, m_leftLegHint.position, newTarget.LeftLegHint.position, m_followingFootTransitionSpeed)); break; case TransitionStyle.SMOOTH: StartCoroutine(SmootStepInterpolation(m_animatedLeftFoot, m_leftFootTarget.position, newTarget.LeftFootTarget.position, m_followingFootTransitionSpeed)); StartCoroutine(SmootStepInterpolation(m_animatedLeftLegHint, m_leftLegHint.position, newTarget.LeftLegHint.position, m_followingFootTransitionSpeed)); break; case TransitionStyle.SPRING: StartCoroutine(SpringInterpolation(m_animatedLeftFoot, m_leftFootTarget.position, newTarget.LeftFootTarget.position, m_followingFootTransitionSpeed, m_footSpringTension)); StartCoroutine(SpringInterpolation(m_animatedLeftLegHint, m_leftLegHint.position, newTarget.LeftLegHint.position, m_followingFootTransitionSpeed, m_footSpringTension)); break; case TransitionStyle.OVERSHOOT: StartCoroutine(OvershootInterpolation(m_animatedLeftFoot, m_leftFootTarget.position, newTarget.LeftFootTarget.position, m_followingFootTransitionSpeed, m_footOvershootFactor)); StartCoroutine(OvershootInterpolation(m_animatedLeftLegHint, m_leftLegHint.position, newTarget.LeftLegHint.position, m_followingFootTransitionSpeed, m_footOvershootFactor)); break; case TransitionStyle.UPWARDCURVE: StartCoroutine(UpwardCurveInterpolation(m_animatedLeftFoot, m_leftFootTarget.position, newTarget.LeftFootTarget.position, m_followingFootTransitionSpeed, m_footArcHeigh1, m_footArcHeigh2, m_footArcSample1, m_footArcSample2)); StartCoroutine(UpwardCurveInterpolation(m_animatedLeftLegHint, m_leftLegHint.position, newTarget.LeftLegHint.position, m_followingFootTransitionSpeed, m_footArcHeigh1, m_footArcHeigh2, m_footArcSample1, m_footArcSample2)); break; default: break; } StartCoroutine(SmootStepInterpolation(m_animatedLeftFoot, m_leftFootTarget.rotation, newTarget.LeftFootTarget.rotation, m_followingFootTransitionSpeed)); StartCoroutine(SmootStepInterpolation(m_animatedLeftLegHint, m_leftLegHint.rotation, newTarget.LeftLegHint.rotation, m_followingFootTransitionSpeed)); }