mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-23 02:44:36 -05:00
Changed Player Stats and altered kick hit box
This commit is contained in:
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
|
||||
public class dGrapplingHook : NetworkBehaviour
|
||||
{
|
||||
public float maxGrappleDistance = 25;
|
||||
public float maxGrappleDistance = 25;
|
||||
|
||||
public bool isGrappled;
|
||||
private int hookPointIndex;
|
||||
@@ -19,6 +19,13 @@ public class dGrapplingHook : 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()
|
||||
{
|
||||
@@ -56,6 +63,7 @@ public class dGrapplingHook : NetworkBehaviour
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
if (isGrappled)
|
||||
{
|
||||
Debug.DrawRay(gameObject.transform.position, (hookPoint.transform.position - gameObject.transform.position)); //Visual of line
|
||||
@@ -82,9 +90,7 @@ public class dGrapplingHook : 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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -105,60 +111,20 @@ public class dGrapplingHook : 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ public class dKickController : NetworkBehaviour
|
||||
leg.SetActive(true);
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
isKicking = false;
|
||||
leg.GetComponent<Collider>().isTrigger = false;
|
||||
leg.SetActive(false);
|
||||
|
||||
}
|
||||
@@ -74,6 +75,7 @@ public class dKickController : NetworkBehaviour
|
||||
Vector3 direction = this.transform.forward;
|
||||
Debug.Log(direction);
|
||||
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);
|
||||
leg.GetComponent<Collider>().isTrigger = true;
|
||||
}
|
||||
if (collision.transform.CompareTag("destroyable") && myCollider == leg.GetComponent<Collider>()){
|
||||
collision.transform.gameObject.GetComponent<BreakableBlock>().damage(pStats.KickPow);
|
||||
|
||||
@@ -212,9 +212,9 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
driftVel = Vector3.zero;
|
||||
if(animator != null) animator.SetBool("isRunning", false);
|
||||
}
|
||||
|
||||
//Move Player
|
||||
moveController.Move(driftVel + (moveY * Time.deltaTime));
|
||||
if(grapple.isGrappled) moveController.Move(grapple.forceDirection * Time.deltaTime);
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && !isSliding)
|
||||
{
|
||||
if(wallRun.IsWallRunning()){
|
||||
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 10f);
|
||||
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 8f);
|
||||
g = pStats.JumpPow;
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
}
|
||||
|
||||
//apply gravity if not grounded and coyote timer is less than 0
|
||||
if(isGrounded == false && curCoyJumpTimer <= 0){
|
||||
if((isGrounded == false && curCoyJumpTimer <= 0) || grapple.isGrappled){
|
||||
g -= grav * Time.deltaTime;
|
||||
}
|
||||
//else don't apply gravity
|
||||
|
||||
@@ -59,13 +59,14 @@ public class KickController : NetworkBehaviour
|
||||
leg.SetActive(true);
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
isKicking = false;
|
||||
leg.GetComponent<Collider>().isTrigger = false;
|
||||
leg.SetActive(false);
|
||||
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
if (!IsLocalPlayer) { return; }
|
||||
Collider myCollider = collision.contacts[0].thisCollider;
|
||||
if (collision.transform.CompareTag("kickable") && myCollider == leg.GetComponent<Collider>()){
|
||||
if(collision.gameObject.GetComponent<Rigidbody>().isKinematic == true){
|
||||
@@ -74,6 +75,7 @@ public class KickController : NetworkBehaviour
|
||||
Vector3 direction = this.transform.forward;
|
||||
Debug.Log(direction);
|
||||
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);
|
||||
leg.GetComponent<Collider>().isTrigger = true;
|
||||
}
|
||||
if (collision.transform.CompareTag("destroyable") && myCollider == leg.GetComponent<Collider>()){
|
||||
collision.transform.gameObject.GetComponent<BreakableBlock>().damage(pStats.KickPow);
|
||||
|
||||
@@ -16,15 +16,32 @@ public class Dash : NetworkBehaviour {
|
||||
float dashSpeed = 12;
|
||||
|
||||
CharacterController characterController;
|
||||
PlayerMovement pMove;
|
||||
|
||||
void Start(){
|
||||
characterController = this.gameObject.GetComponent<CharacterController>();
|
||||
characterController = GetComponent<CharacterController>();
|
||||
pMove = GetComponent<PlayerMovement>();
|
||||
}
|
||||
|
||||
//UPDATE CHECK FOR MOVEMENT ONLY WHEN DASHING
|
||||
void FixedUpdate(){
|
||||
if (!IsLocalPlayer) { return; }
|
||||
if(pMove.pStats.HasDash){
|
||||
DashMovement();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator startCoolDown(){
|
||||
Debug.Log("start corotine");
|
||||
isOnCoolDown = true;
|
||||
//driver.startUICooldown("Nitro");
|
||||
yield return new WaitForSeconds(dashItem.cooldownM);
|
||||
isOnCoolDown = false;
|
||||
Debug.Log("end corotine");
|
||||
}
|
||||
|
||||
private void DashMovement(){
|
||||
if (Input.GetKeyDown(KeyCode.E) && isOnCoolDown == false)
|
||||
{
|
||||
currentDashTime = 0;
|
||||
@@ -43,13 +60,4 @@ public class Dash : NetworkBehaviour {
|
||||
characterController.Move(moveDirection * Time.deltaTime * dashSpeed);
|
||||
}
|
||||
|
||||
private IEnumerator startCoolDown(){
|
||||
Debug.Log("start corotine");
|
||||
isOnCoolDown = true;
|
||||
//driver.startUICooldown("Nitro");
|
||||
yield return new WaitForSeconds(dashItem.cooldownM);
|
||||
isOnCoolDown = false;
|
||||
Debug.Log("end corotine");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,23 +33,24 @@ public class GrapplingHook : NetworkBehaviour
|
||||
void Update()
|
||||
{
|
||||
if (!IsLocalPlayer) { return; }
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
|
||||
{
|
||||
if (!isGrappled) //If we are not grappling
|
||||
if(pStats.HasGrapple){
|
||||
if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
|
||||
{
|
||||
hookPointIndex = FindHookPoint(); //Find the nearest hook point within max distance
|
||||
if (hookPointIndex != -1) //If there is a hookpoint
|
||||
if (!isGrappled) //If we are not grappling
|
||||
{
|
||||
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
|
||||
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
|
||||
}
|
||||
}
|
||||
else //Else we are grappling
|
||||
{
|
||||
//physics tear down?
|
||||
isGrappled = false; //toggle grappling state to release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ MonoBehaviour:
|
||||
minVelM: 0
|
||||
curVelM: 0
|
||||
accM: 0
|
||||
jumpPowM: 10
|
||||
jumpPowM: 15
|
||||
jumpNumM: 0
|
||||
tractionM: 0
|
||||
kickPowM: 0
|
||||
|
||||
@@ -22,7 +22,7 @@ MonoBehaviour:
|
||||
jumpPowM: 0
|
||||
jumpNumM: 0
|
||||
tractionM: 0
|
||||
kickPowM: 100
|
||||
kickPowM: 500
|
||||
recovTimeM: 0
|
||||
playerGravM: 0
|
||||
costM: 3
|
||||
|
||||
@@ -87,7 +87,6 @@ public class PlayerMovement : NetworkBehaviour
|
||||
private Blink blink;
|
||||
|
||||
private GrapplingHook grapple;
|
||||
|
||||
|
||||
//Animation controller
|
||||
Animator animator;
|
||||
@@ -252,7 +251,7 @@ public class PlayerMovement : NetworkBehaviour
|
||||
//Apply Impact for when force needs to be applied without ragdolling
|
||||
public void AddImpact(Vector3 dir, float force)
|
||||
{
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
if (!IsLocalPlayer) { return; }
|
||||
|
||||
//Normalize direction multiply by force and add it to the impact
|
||||
dir.Normalize();
|
||||
@@ -269,7 +268,7 @@ public class PlayerMovement : NetworkBehaviour
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && !isSliding)
|
||||
{
|
||||
if(wallRun.IsWallRunning()){
|
||||
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 10f);
|
||||
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 8f);
|
||||
g = pStats.JumpPow;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user