mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-09-10 03:15:17 -05:00
Updated networked Grapple
This commit is contained in:
@@ -10,8 +10,9 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
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 AerialGrappleAirState : AerialBaseState
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState 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;
|
||||
|
||||
}
|
||||
@@ -52,7 +43,6 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
aSM.handController.enabled = false;
|
||||
aSM.stickyHandParent.SetActive(false);
|
||||
aSM.lr.enabled = false;
|
||||
aSM.removeableHand.SetActive(true);
|
||||
|
||||
if(nextState == aSM.GroundedState || nextState == aSM.WallRunState){
|
||||
aSM.release = false;
|
||||
@@ -82,21 +72,11 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager 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);
|
||||
@@ -107,6 +87,14 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
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;
|
||||
@@ -121,7 +109,6 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
|
||||
public void ThrowStickyHand(AerialStateManager aSM){
|
||||
if(!aSM.stickyHandParent.active){
|
||||
aSM.removeableHand.SetActive(false);
|
||||
aSM.stickyHandParent.SetActive(true);
|
||||
aSM.lr.enabled = true;
|
||||
aSM.stickyHandParent.transform.position = aSM.handPosition.position;
|
||||
@@ -133,8 +120,17 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -147,9 +143,6 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
if(Vector3.Distance(aSM.handPosition.transform.position, aSM.stickyHandParent.transform.position) > .5f){
|
||||
aSM.stickyHandParent.GetComponent<CharacterController>().Move(catchDir * 30 * Time.deltaTime);
|
||||
}
|
||||
else{
|
||||
aSM.removeableHand.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user