mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-23 10:54:24 -05:00
Grapple Finally Feels Satisfactory
This commit is contained in:
@@ -10,8 +10,9 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
float distanceBeneathHook;
|
||||
float distanceAfterHook;
|
||||
Vector3 desiredPosition;
|
||||
Vector3 playerOffset;
|
||||
Vector3 lastPos;
|
||||
Vector3 tempForceDir;
|
||||
Vector3 updatedYHookPoint;
|
||||
|
||||
|
||||
bool pointReached;
|
||||
bool handReached = false;
|
||||
@@ -22,27 +23,17 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
public override void EnterState(dAerialStateManager aSM, dAerialBaseState previousState){
|
||||
|
||||
|
||||
distanceBeneathHook = -2f;
|
||||
distanceBeneathHook = -10f;
|
||||
distanceAfterHook = 8f;
|
||||
pointReached = false;
|
||||
initialForcePower = 100;
|
||||
initialForcePower = 120;
|
||||
|
||||
//refresh jump number
|
||||
aSM.curJumpNum = 0;
|
||||
aSM.release = false;
|
||||
|
||||
Vector3 updatedYHookPoint = new Vector3(aSM.hookPoint.transform.position.x, aSM.hookPoint.transform.position.y - distanceBeneathHook, aSM.hookPoint.transform.position.z);
|
||||
Vector3 updatedXHookPointDirection = (new Vector3(aSM.transform.position.x, 0, aSM.transform.position.z) - new Vector3(aSM.hookPoint.transform.position.x, 0, aSM.hookPoint.transform.position.z)).normalized;
|
||||
|
||||
desiredPosition = updatedYHookPoint + (updatedXHookPointDirection * -distanceAfterHook);
|
||||
//rope length limit
|
||||
initialForceDirection = desiredPosition - aSM.transform.position;
|
||||
initialForceDirection = initialForceDirection.normalized;
|
||||
|
||||
aSM.postForceDirection = new Vector3(initialForceDirection.x, 0, initialForceDirection.z).normalized;
|
||||
updatedYHookPoint = new Vector3(aSM.hookPoint.transform.position.x, aSM.hookPoint.transform.position.y - distanceBeneathHook, aSM.hookPoint.transform.position.z);
|
||||
aSM.currentForcePower = initialForcePower;
|
||||
|
||||
lastPos = aSM.transform.position;
|
||||
handReached = false;
|
||||
|
||||
}
|
||||
@@ -81,21 +72,11 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(dAerialStateManager aSM){
|
||||
playerOffset = aSM.transform.position - lastPos;
|
||||
lastPos = aSM.transform.position;
|
||||
|
||||
////////ADD A LINE RENDERER WHEN WE GET THE HAND MODEL
|
||||
//Draw Line between player and hookpoint for debug purposes
|
||||
Debug.DrawRay(aSM.transform.position, initialForceDirection); //Visual of line
|
||||
|
||||
Vector3 tempForceDir = desiredPosition - aSM.transform.position;
|
||||
tempForceDir = tempForceDir.normalized;
|
||||
tempForceDir = new Vector3(tempForceDir.x,0,tempForceDir.z).normalized;
|
||||
|
||||
if((aSM.postForceDirection - tempForceDir).magnitude >= .1f && !pointReached){
|
||||
pointReached = true;
|
||||
}
|
||||
|
||||
//Apply default gravity
|
||||
if(!handReached){
|
||||
ThrowStickyHand(aSM);
|
||||
@@ -106,6 +87,14 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
aSM.moveController.Move(initialForceDirection * initialForcePower * Time.deltaTime);
|
||||
aSM.GravityCalculation(0);
|
||||
aSM.pStats.GravVel = 0;
|
||||
|
||||
tempForceDir = desiredPosition - aSM.transform.position;
|
||||
tempForceDir = tempForceDir.normalized;
|
||||
tempForceDir = new Vector3(tempForceDir.x,0,tempForceDir.z).normalized;
|
||||
|
||||
if((aSM.postForceDirection - tempForceDir).magnitude >= .1f && !pointReached){
|
||||
pointReached = true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
//currentForcePower;
|
||||
@@ -131,8 +120,17 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
|
||||
Vector3 throwDir = (aSM.hookPoint.transform.position - aSM.stickyHandParent.transform.position).normalized;
|
||||
|
||||
aSM.stickyHandParent.GetComponent<CharacterController>().Move(throwDir * 80 * Time.deltaTime);
|
||||
aSM.stickyHandParent.GetComponent<CharacterController>().Move(throwDir * 120 * Time.deltaTime);
|
||||
if(Vector3.Distance(aSM.hookPoint.transform.position, aSM.stickyHandParent.transform.position) <= 3f){
|
||||
|
||||
Vector3 updatedXHookPointDirection = (new Vector3(aSM.transform.position.x, 0, aSM.transform.position.z) - new Vector3(aSM.hookPoint.transform.position.x, 0, aSM.hookPoint.transform.position.z)).normalized;
|
||||
|
||||
desiredPosition = updatedYHookPoint + (updatedXHookPointDirection * -distanceAfterHook);
|
||||
//rope length limit
|
||||
initialForceDirection = desiredPosition - aSM.transform.position;
|
||||
initialForceDirection = initialForceDirection.normalized;
|
||||
|
||||
aSM.postForceDirection = new Vector3(initialForceDirection.x, 0, initialForceDirection.z).normalized;
|
||||
handReached = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public class AerialGlidingState : AerialBaseState
|
||||
|
||||
//Modify base traction
|
||||
aSM.pStats.CurTraction = 1.0f;
|
||||
aSM.pStats.GravVel = -1;
|
||||
aSM.pStats.GravVel = -4;
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
@@ -44,7 +44,7 @@ public class AerialGlidingState : AerialBaseState
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
|
||||
//modified gravity calculation to fall slower
|
||||
aSM.GravityCalculation(8);
|
||||
aSM.GravityCalculation(9);
|
||||
|
||||
//if grapple released apply release force
|
||||
if(aSM.pStats.HasGrapple){
|
||||
|
||||
@@ -175,8 +175,8 @@ public class PlayerStats : MonoBehaviour
|
||||
}
|
||||
|
||||
//temp values for reseting stuff
|
||||
private float accModification;
|
||||
private float tractionModification;
|
||||
private float accModification = 1;
|
||||
private float tractionModification = 1;
|
||||
private bool weatherOn = false;
|
||||
////
|
||||
|
||||
@@ -244,11 +244,11 @@ public class PlayerStats : MonoBehaviour
|
||||
traction *= tractionModification;
|
||||
curTraction *= tractionModification;
|
||||
|
||||
accModification = .5f;
|
||||
accModification = .3f;
|
||||
acc *= accModification;
|
||||
curAcc *= accModification;
|
||||
|
||||
curVel *= .5f;
|
||||
curVel *= .3f;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user