mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
momentum grappling issue solved
Need to adjust smaller things but swing feels more complete
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user