mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 01:44:30 -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user