Gate created and player tagged correctly

This commit is contained in:
Melbyj1125
2021-12-03 13:17:12 -06:00
parent 55885e2ef1
commit 17d804080d
59 changed files with 419 additions and 76 deletions

View File

@@ -28,8 +28,6 @@ public class dKickController : NetworkBehaviour
}
void Kick(){
//Note: when we merge this into PlayerMovement, we may want to change isgrounded to our
//custom is grounded
if (Input.GetKeyDown(KeyCode.F) && isKicking == false && characterController.isGrounded == false)
{
Debug.Log("dive");
@@ -67,6 +65,9 @@ public class dKickController : NetworkBehaviour
//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){
collision.gameObject.GetComponent<Rigidbody>().isKinematic = false;
}
Vector3 direction = this.transform.forward;
Debug.Log(direction);
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);

View File

@@ -7,7 +7,7 @@ using UnityEngine.Rendering;
public class dWallRun : NetworkBehaviour
{
public float wallMaxDistance = 5;
public float wallMaxDistance = .8f;
public float wallSpeedMultiplier = 1.2f;
public float minimumHeight = .1f;
public float maxAngleRoll = 20;
@@ -32,7 +32,6 @@ public class dWallRun : NetworkBehaviour
float elapsedTimeSinceJump = 0;
float elapsedTimeSinceWallAttach = 0;
float elapsedTimeSinceWallDetatch = 0;
bool attachOnce = false;
bool jumping;
bool isPlayergrounded() => playerMovementController.isGrounded;
@@ -177,9 +176,8 @@ public class dWallRun : NetworkBehaviour
playerMovementController.SetPlayerVelocity(moveToSet);
isWallRunning = true;
if(!attachOnce && playerMovementController.curJumpNum != 0){
playerMovementController.curJumpNum = playerMovementController.curJumpNum - 2 ;
attachOnce = true;
if(playerMovementController.curJumpNum != 0){
playerMovementController.curJumpNum = 0 ;
}
}
@@ -199,10 +197,6 @@ public class dWallRun : NetworkBehaviour
public Vector3 GetWallJumpDirection() //Add call in jump where if we are wallrunning and jump, the jump vector is multiplied by this
{
if(isWallRunning)
{
return lastWallNormal * wallBouncing + Vector3.up;
}
return Vector3.zero;
}
return lastWallNormal * wallBouncing + (transform.up);
}
}

View File

@@ -65,7 +65,7 @@ public class dPlayerMovement : NetworkBehaviour
private Rigidbody rB;
private CapsuleCollider capCol;
private bool firstHit = false;
private bool heldDown = false;
//private bool heldDown = false; //Variable for testing Ragdoll reenable if needed
private bool beginRagTimer = false;
private float ragTime;
private Vector3 prevRot;
@@ -262,7 +262,8 @@ public class dPlayerMovement : NetworkBehaviour
if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding)
{
if(wallRun.IsWallRunning()){
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow);
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 1.3f);
AddImpact(transform.up, pStats.JumpPow);
}
else{
AddImpact(transform.up, pStats.JumpPow);
@@ -367,8 +368,6 @@ public class dPlayerMovement : NetworkBehaviour
else{
vel.y -= pStats.PlayerGrav * Time.deltaTime;
}
//If gliding
//Go down slowly
}

View File

@@ -62,11 +62,14 @@ public class KickController : NetworkBehaviour
}
private void OnCollisionEnter(Collision collision)
private void OnCollisionEnter(Collision collision)
{
//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){
collision.gameObject.GetComponent<Rigidbody>().isKinematic = false;
}
Vector3 direction = this.transform.forward;
Debug.Log(direction);
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d808f60ee05185d43a154521748992a0
guid: 286df2f965f4f3c4eb74950f0550e68f
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -7,7 +7,7 @@ using UnityEngine.Rendering;
public class WallRun : NetworkBehaviour
{
public float wallMaxDistance = 5;
public float wallMaxDistance = 5;
public float wallSpeedMultiplier = 1.2f;
public float minimumHeight = .1f;
public float maxAngleRoll = 20;
@@ -83,14 +83,14 @@ public class WallRun : NetworkBehaviour
{
Vector3 dir = transform.TransformDirection(directions[i]);
Physics.Raycast(transform.position, dir, out hits[i], wallMaxDistance);
// if(hits[i].collider != null)
// {
// Debug.DrawRay(transform.position, dir * hits[i].distance, Color.green);
// }
// else
// {
// Debug.DrawRay(transform.position, dir * wallMaxDistance, Color.red);
// }
if(hits[i].collider != null)
{
Debug.DrawRay(transform.position, dir * hits[i].distance, Color.green);
}
else
{
Debug.DrawRay(transform.position, dir * wallMaxDistance, Color.red);
}
}
if(CanWallRun())
@@ -159,7 +159,6 @@ public class WallRun : NetworkBehaviour
if((moveToSetNorm.x < 0 && velNorm.x > 0)){
moveToSet.x = (moveToSet.x * -velNorm.x);
Debug.Log("x");
}
else if((moveToSetNorm.x > 0 && velNorm.x < 0) ){
moveToSet.x = (-moveToSet.x * -velNorm.x);
@@ -167,7 +166,6 @@ public class WallRun : NetworkBehaviour
if((moveToSetNorm.z < 0 && velNorm.z > 0)){
moveToSet.z = (moveToSet.z * -velNorm.z);
Debug.Log("z");
}
else if((moveToSetNorm.z > 0 && velNorm.z < 0)){
moveToSet.z = (-moveToSet.z * -velNorm.z);
@@ -178,6 +176,10 @@ public class WallRun : NetworkBehaviour
playerMovementController.SetPlayerVelocity(moveToSet);
isWallRunning = true;
if(playerMovementController.curJumpNum != 0){
playerMovementController.curJumpNum = 0 ;
}
}
}
@@ -195,10 +197,6 @@ public class WallRun : NetworkBehaviour
public Vector3 GetWallJumpDirection() //Add call in jump where if we are wallrunning and jump, the jump vector is multiplied by this
{
if(isWallRunning)
{
return lastWallNormal * wallBouncing + Vector3.up;
}
return Vector3.zero;
return lastWallNormal * wallBouncing + (transform.up);
}
}

View File

@@ -26,7 +26,7 @@ public class PlayerMovement : NetworkBehaviour
private CharacterController moveController;
//Jump value
private int curJumpNum;
public int curJumpNum;
private bool jumpPressed;
bool tempSet = false;
float tempTraction = 0.0f;
@@ -65,7 +65,7 @@ public class PlayerMovement : NetworkBehaviour
private Rigidbody rB;
private CapsuleCollider capCol;
private bool firstHit = false;
private bool heldDown = false;
//private bool heldDown = false; //Variable for testing ragdoll reenable if needed
private bool beginRagTimer = false;
private float ragTime;
private Vector3 prevRot;
@@ -239,7 +239,13 @@ public class PlayerMovement : NetworkBehaviour
//If space is pressed apply an upwards force to the player
if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding)
{
AddImpact(transform.up, pStats.JumpPow);
if(wallRun.IsWallRunning()){
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 1.3f);
AddImpact(transform.up, pStats.JumpPow);
}
else{
AddImpact(transform.up, pStats.JumpPow);
}
curJumpNum++;
jumpPressed = true;
}
@@ -328,7 +334,7 @@ public class PlayerMovement : NetworkBehaviour
tempSet = true;
}
}
else{
else if(!jumpPressed && pStats.HasGlider){
if(tempSet == true){
pStats.Traction = tempTraction;
@@ -340,9 +346,11 @@ public class PlayerMovement : NetworkBehaviour
}
//Wallrunning
if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning
//If gliding
//Go down slowly
else if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning
else{
vel.y -= pStats.PlayerGrav * Time.deltaTime;
}
}

View File

@@ -55,7 +55,7 @@ public class PlayerStats : MonoBehaviour
}
//Player Kick Power
[SerializeField] private float kickPow = 100.0f;
[SerializeField] private float kickPow = 150.0f;
public float KickPow{
get{ return kickPow; }
set{ kickPow = value; }
@@ -68,7 +68,6 @@ public class PlayerStats : MonoBehaviour
set{ recovTime = value; }
}
//MAY BE UNNECCESARY DEPENDING ON HOW GLIDER TURNS OUT
//Gravity Affecting the player
[SerializeField] private float playerGrav = 20.0f;
public float PlayerGrav{