mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
grapple still has issues
This commit is contained in:
@@ -17,8 +17,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
|
||||
private Vector3 moveZ;
|
||||
private Vector3 moveX;
|
||||
private Vector3 driftVel;
|
||||
private Vector3 lerpY;
|
||||
public Vector3 driftVel;
|
||||
|
||||
//Player prefab
|
||||
private GameObject parentObj;
|
||||
@@ -79,7 +78,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
private Vector3 hitForce;
|
||||
|
||||
//Slide Variables
|
||||
private bool isSliding = false;
|
||||
public bool isSliding = false;
|
||||
private float originalTraction;
|
||||
private RaycastHit ray;
|
||||
private Vector3 up;
|
||||
@@ -87,6 +86,8 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
|
||||
//Blink
|
||||
private dBlink blink;
|
||||
|
||||
private dGrapplingHook grapple;
|
||||
|
||||
|
||||
//Animation controller
|
||||
@@ -106,6 +107,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
pStats = GetComponent<PlayerStats>(); // PlayerStats
|
||||
wallRun = GetComponent<dWallRun>(); //Wallrun
|
||||
blink = GetComponent<dBlink>(); //Blink
|
||||
grapple = GetComponent<dGrapplingHook>();
|
||||
|
||||
//Get parents up direction
|
||||
up = GetComponentInParent<Transform>().up;
|
||||
@@ -204,8 +206,9 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
if(animator != null) animator.SetBool("isRunning", true);
|
||||
}
|
||||
//if low enough movement from player (this will be still at this value) stop animation
|
||||
else if (driftVel.magnitude < .510f)
|
||||
else if (driftVel.magnitude < .05f)
|
||||
{
|
||||
driftVel = Vector3.zero;
|
||||
if(animator != null) animator.SetBool("isRunning", false);
|
||||
}
|
||||
|
||||
@@ -266,7 +269,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && !isSliding)
|
||||
{
|
||||
if(wallRun.IsWallRunning()){
|
||||
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 20f);
|
||||
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 10f);
|
||||
g = pStats.JumpPow;
|
||||
}
|
||||
|
||||
@@ -380,9 +383,9 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
private void UpdateGravity(){
|
||||
|
||||
//Gliding
|
||||
if(pStats.HasGlider && g < 0 && jumpHeld){
|
||||
if(pStats.HasGlider && g < 0 && Input.GetButton("Jump")){
|
||||
//Gravity with glider
|
||||
GravityCalculation(10);
|
||||
GravityCalculation(6);
|
||||
|
||||
//Set temp values to put traction back to normal
|
||||
if(tempSet == false){
|
||||
@@ -425,22 +428,22 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
private void GravityCalculation(float grav){
|
||||
//apply slight upwards force for jump smoothing when g < 0
|
||||
if(g < 0){
|
||||
g += grav * (fallMultiplier - 1) * Time.deltaTime;
|
||||
g += grav * (fallMultiplier - 1) * Time.deltaTime;
|
||||
}
|
||||
|
||||
//apply smaller upwards force if jump is released early when jumping creating a short jump
|
||||
else if (g > 0 && !Input.GetButton("Jump")){
|
||||
g += grav * (lowJumpMultiplier - 1) * Time.deltaTime;
|
||||
g += grav * (lowJumpMultiplier - 1) * Time.deltaTime;
|
||||
}
|
||||
|
||||
//apply gravity if not grounded and coyote timer is less than 0
|
||||
if(isGrounded == false && curCoyJumpTimer <= 0){
|
||||
g -= grav * Time.deltaTime;
|
||||
if((isGrounded == false && curCoyJumpTimer <= 0) || (!grapple.isGrappled && isGrounded == false)){
|
||||
g -= grav * Time.deltaTime;
|
||||
}
|
||||
|
||||
//else don't apply gravity
|
||||
else{
|
||||
g = 0;
|
||||
g = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,7 +465,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
{
|
||||
isGrounded = true;
|
||||
// handle snapping to the ground
|
||||
if (groundHit.distance > moveController.skinWidth)
|
||||
if (groundHit.distance > moveController.skinWidth && !grapple.isGrappled)
|
||||
{
|
||||
moveController.Move(Vector3.down * groundHit.distance);
|
||||
}
|
||||
@@ -494,6 +497,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
rB.isKinematic = true;
|
||||
rB.detectCollisions = false;
|
||||
transform.localEulerAngles = prevRot;
|
||||
CancelMomentum();
|
||||
}
|
||||
|
||||
//When to begin the ragdoll timer
|
||||
@@ -556,7 +560,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
vel = Vector3.zero;
|
||||
moveX = Vector3.zero;
|
||||
moveZ = Vector3.zero;
|
||||
moveController.enabled = false;
|
||||
driftVel = Vector3.zero;
|
||||
}
|
||||
|
||||
private IEnumerator RespawnTimer()
|
||||
@@ -571,4 +575,8 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
moveController.enabled = true;
|
||||
}
|
||||
|
||||
|
||||
public void TeleportPlayer(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user