mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 18:04:27 -05:00
Merge branch 'MelbyFinalSprint'
This commit is contained in:
@@ -5,9 +5,9 @@ using UnityEngine;
|
||||
|
||||
public class GrapplingHook : NetworkBehaviour
|
||||
{
|
||||
public float maxGrappleDistance = 25;
|
||||
public float maxGrappleDistance = 25;
|
||||
|
||||
private bool isGrappled;
|
||||
public bool isGrappled;
|
||||
private int hookPointIndex;
|
||||
private GameObject hookPoint;
|
||||
private GameObject[] hookPoints;
|
||||
@@ -16,7 +16,7 @@ public class GrapplingHook : NetworkBehaviour
|
||||
private CharacterController movementController;
|
||||
private PlayerMovement playerMovement;
|
||||
private PlayerStats pStats;
|
||||
private float ropeLength;
|
||||
[SerializeField] private float ropeLength;
|
||||
private float climbRate = 5;
|
||||
|
||||
// Start is called before the first frame update
|
||||
@@ -56,6 +56,7 @@ public class GrapplingHook : NetworkBehaviour
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!IsLocalPlayer) { return; }
|
||||
if (isGrappled)
|
||||
{
|
||||
Debug.DrawRay(gameObject.transform.position, (hookPoint.transform.position - gameObject.transform.position)); //Visual of line
|
||||
@@ -79,15 +80,16 @@ public class GrapplingHook : NetworkBehaviour
|
||||
//Debug.Log(ropeLength.ToString());
|
||||
}
|
||||
//Do grappling physics based on hookPoint
|
||||
if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength)
|
||||
if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength )
|
||||
{
|
||||
//Impact Based
|
||||
playerMovement.AddImpact((hookPoint.transform.position - gameObject.transform.position), pStats.PlayerGrav);
|
||||
//Character controller move?
|
||||
//movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * ropeLength*Time.deltaTime);
|
||||
//Lerp? or another smoother way? Better physics? Wait until refinement to deal with
|
||||
Debug.Log("y");
|
||||
playerMovement.g = 2;
|
||||
movementController.Move((hookPoint.transform.position - gameObject.transform.position) * Time.deltaTime);
|
||||
|
||||
}
|
||||
}
|
||||
if(playerMovement.GetJumpPressed()) isGrappled = false;
|
||||
}
|
||||
|
||||
int FindHookPoint()
|
||||
@@ -104,4 +106,60 @@ 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;
|
||||
|
||||
// private CharacterController movementController;
|
||||
// private dPlayerMovement playerMovement;
|
||||
// private PlayerStats pStats;
|
||||
// private Camera cam;
|
||||
// private Vector3 forwardHookLerp;
|
||||
// private Vector3 upwardsHookLerp;
|
||||
|
||||
// // 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);
|
||||
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user