momentum grappling issue solved

Need to adjust smaller things but swing feels more complete
This commit is contained in:
Melbyj1125
2022-01-21 03:08:58 -06:00
parent c881e37b9c
commit 3306da25ba
2 changed files with 19 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ using UnityEngine;
public class dGrapplingHook : NetworkBehaviour
{
public float maxGrappleDistance = 25;
public float maxGrappleDistance = 15;
public bool isGrappled;
private int hookPointIndex;
@@ -20,6 +20,7 @@ public class dGrapplingHook : NetworkBehaviour
private float climbRate = 5;
private Vector3 swingDirection;
private float swingSpeed = 90;
private float swingMom = 0;
Vector3 tensionDirection;
Vector3 pendulumSideDirection;
@@ -125,9 +126,15 @@ public class dGrapplingHook : NetworkBehaviour
Vector3 calculateForceDirection(float mass, float g, Vector3 hPoint){
tensionDirection = (hPoint - transform.position).normalized;
float inclinationAngle = Vector3.Angle(transform.position - hPoint, -transform.up);
tensionForce = mass * -g * Mathf.Cos(Mathf.Deg2Rad * inclinationAngle);
float inclinationAngle = Vector3.Angle((transform.position - hPoint).normalized, -transform.up);
float theta = Mathf.Deg2Rad * inclinationAngle;
if(theta <= .3 && swingMom <= 0 && theta > 0){
theta -= .05f;
}
if(theta<0) theta = 0;
Debug.Log(theta);
tensionForce = mass * -g * Mathf.Cos(theta);
Vector3 fDirection = tensionDirection * tensionForce;
return fDirection;

View File

@@ -220,8 +220,14 @@ public class dPlayerMovement : NetworkBehaviour
if(animator != null) animator.SetBool("isRunning", false);
}
//Move Player
moveController.Move(driftVel + (moveY * Time.deltaTime));
if(grapple.isGrappled) moveController.Move(grapple.forceDirection * Time.deltaTime);
if(grapple.isGrappled && !isGrounded){
moveController.Move(driftVel + ((moveY + grapple.forceDirection) * Time.deltaTime));
}
else{
moveController.Move(driftVel + (moveY * Time.deltaTime));
}
}