A lot of cleanup and adjustments

traction resets after a glide
Keep Momentum after sliding
Wallrun adjusted on player prefab
Wallrun added to Player prefab2
A lot of stats adjusted on all prefabs
This commit is contained in:
Melbyj1125
2021-12-17 02:04:15 -06:00
parent bb5ee9d2b2
commit 79626242c0
14 changed files with 160 additions and 162 deletions

View File

@@ -5,7 +5,7 @@ using UnityEngine;
public class GrapplingHook : NetworkBehaviour
{
public float maxGrappleDistance = 25;
public float maxGrappleDistance = 25;
public bool isGrappled;
private int hookPointIndex;
@@ -19,6 +19,13 @@ public class GrapplingHook : NetworkBehaviour
[SerializeField] private float ropeLength;
private float climbRate = 5;
Vector3 tensionDirection;
Vector3 pendulumSideDirection;
Vector3 tangentDirection;
float tensionForce;
public Vector3 forceDirection;
// Start is called before the first frame update
void Start()
{
@@ -33,24 +40,23 @@ public class GrapplingHook : NetworkBehaviour
void Update()
{
if (!IsLocalPlayer) { return; }
if(pStats.HasGrapple){
if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
if ((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && pStats.HasGrapple) //If grapple button is hit
{
if (!isGrappled) //If we are not grappling
{
if (!isGrappled) //If we are not grappling
hookPointIndex = FindHookPoint(); //Find the nearest hook point within max distance
if (hookPointIndex != -1) //If there is a hookpoint
{
hookPointIndex = FindHookPoint(); //Find the nearest hook point within max distance
if (hookPointIndex != -1) //If there is a hookpoint
{
hookPoint = hookPoints[hookPointIndex]; //The point we are grappling from
ropeLength = Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) + 0.5f;
isGrappled = true; //toggle grappling state
}
}
else //Else we are grappling
{
//physics tear down?
isGrappled = false; //toggle grappling state to release
hookPoint = hookPoints[hookPointIndex]; //The point we are grappling from
ropeLength = Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) + 0.5f;
isGrappled = true; //toggle grappling state
}
}
else //Else we are grappling
{
//physics tear down?
isGrappled = false; //toggle grappling state to release
}
}
}
@@ -84,9 +90,7 @@ public class GrapplingHook : NetworkBehaviour
if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength )
{
//Impact Based
Debug.Log("y");
playerMovement.g = 2;
movementController.Move((hookPoint.transform.position - gameObject.transform.position) * Time.deltaTime);
forceDirection = calculateForceDirection(1, playerMovement.g, hookPoint.transform.position);
}
}
@@ -107,60 +111,20 @@ public class GrapplingHook : NetworkBehaviour
}
return index;
}
///////////Hookshot Concept
// public float maxGrappleDistance = 25;
// public bool isGrappled;
// private Vector3 hookPoint;
// private float distance;
// public float propelPower = 100;
Vector3 calculateForceDirection(float mass, float g, Vector3 hPoint){
tensionDirection = (hPoint - transform.position).normalized;
Debug.Log(tensionDirection);
// private CharacterController movementController;
// private dPlayerMovement playerMovement;
// private PlayerStats pStats;
// private Camera cam;
// private Vector3 forwardHookLerp;
// private Vector3 upwardsHookLerp;
float inclinationAngle = Vector3.Angle(transform.position - hPoint, -transform.up);
// // Start is called before the first frame update
// void Start()
// {
// isGrappled = false;
// movementController = gameObject.GetComponent<CharacterController>();
// playerMovement = gameObject.GetComponent<dPlayerMovement>();
// pStats = gameObject.GetComponent<PlayerStats>();
// cam = playerMovement.cam;
// }
// private void FixedUpdate()
// {
// getGrapplePoint();
// //Debug.Log((hookPoint.transform.position - transform.position).normalized);
// if (isGrappled && !Input.GetKeyDown(KeyCode.E))
// {
// //playerMovement.AddImpact((hookPoint - transform.position), propelPower);
// forwardHookLerp = Vector3.Lerp(forwardHookLerp, transform.forward * 50, .03f);
// movementController.Move(forwardHookLerp * Time.deltaTime);
tensionForce = mass * -g * Mathf.Cos(Mathf.Deg2Rad * inclinationAngle);
Debug.Log(g);
// upwardsHookLerp = Vector3.Lerp(upwardsHookLerp, (hookPoint - transform.position).normalized * Vector3.Distance(transform.position, hookPoint) * propelPower, .03f);
// movementController.Move(upwardsHookLerp * Time.deltaTime);
// isGrappled = false;
// }
// }
// private void getGrapplePoint(){
// //if E or left face gamepad button is pressed is slightly pressed
// if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
// {
// if (!isGrappled) //If we are not grappling
// {
// if(Physics.Raycast(cam.transform.position, cam.transform.forward, out RaycastHit raycastHit)){
// if(raycastHit.collider.gameObject.transform.tag == "HookPoint"){
// isGrappled = true;
// hookPoint = new Vector3 (raycastHit.point.x,raycastHit.point.y,raycastHit.point.z);
// }
// }
// }
// }
// }
Vector3 fDirection = tensionDirection * tensionForce;
Debug.Log(fDirection);
return fDirection;
}
}

View File

@@ -7,7 +7,7 @@ using UnityEngine.Rendering;
public class WallRun : NetworkBehaviour
{
public float wallMaxDistance = 5;
public float wallMaxDistance = 3;
public float wallSpeedMultiplier = 1.2f;
public float minimumHeight = .1f;
public float maxAngleRoll = 20;
@@ -66,7 +66,7 @@ public class WallRun : NetworkBehaviour
public void WallRunRoutine()
{
//if (!IsLocalPlayer) { return; }
if (!IsLocalPlayer) { return; }
isWallRunning = false;
@@ -174,8 +174,8 @@ public class WallRun : NetworkBehaviour
playerMovementController.SetPlayerVelocity(moveToSet);
isWallRunning = true;
if(playerMovementController.curJumpNum != 0){
playerMovementController.curJumpNum = 0 ;
if(playerMovementController.curJumpNum == playerMovementController.pStats.JumpNum){
playerMovementController.curJumpNum = 0;
}
}