Cleaned up code

Slide Works again
Ragdoll works again
Cam is stable
New Debugging prefab
This commit is contained in:
Melbyj1125
2021-11-03 14:06:19 -05:00
parent 76cd66fa0b
commit 7c72259708
36 changed files with 2193 additions and 346 deletions

View File

@@ -1,10 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using MLAPI;
using UnityEngine;
public class Blink : MonoBehaviour{
public class Blink : NetworkBehaviour{
// Start is called before the first frame update
@@ -42,6 +43,9 @@ public class Blink : MonoBehaviour{
//blinks the player forwards
private void BlinkMove()
{
if (!IsLocalPlayer) { return; }
if (Input.GetMouseButton(1))
{
// Finding the origin and end point of laser.

View File

@@ -1,9 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using MLAPI;
using UnityEngine;
public class Dash : MonoBehaviour{
public class Dash : NetworkBehaviour{
public Vector3 moveDirection;
public const float maxDashTime = 1.0f;
@@ -20,6 +21,9 @@ public class Dash : MonoBehaviour{
//UPDATE CHECK FOR MOVEMENT ONLY WHEN DASHING
void FixedUpdate(){
//if (!IsLocalPlayer) { return; }
if (Input.GetKeyDown(KeyCode.E))
{
currentDashTime = 0;

View File

@@ -1,8 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using MLAPI;
using UnityEngine;
public class GrapplingHook : MonoBehaviour
public class GrapplingHook : NetworkBehaviour
{
public float maxGrappleDistance = 25;
@@ -22,6 +23,8 @@ public class GrapplingHook : MonoBehaviour
// Update is called once per frame
void Update()
{
//if (!IsLocalPlayer) { return; }
if (Input.GetKeyDown(KeyCode.E)) //If grapple button is hit
{
if (!isGrappled) //If we are not grappling

View File

@@ -1,25 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Kick : MonoBehaviour
{
private float kickForce = 50f;
// Start is called before the first frame update
void Start(){
}
// Update is called once per frame
void Update(){
}
private void OnCollisionEnter(Collision collision)
{
if (collision.transform.CompareTag("kickable")){
Vector3 direction = this.transform.forward;
Debug.Log(direction);
collision.rigidbody.AddForce(direction * kickForce, ForceMode.Impulse);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f9b52b0ade3c44e47a3a4dc48c47ec1c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,23 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using MLAPI;
using UnityEngine;
public class KickController : MonoBehaviour
public class KickController : NetworkBehaviour
{
//Important, may want to change blink code to only work for trigger collider
// so that the player doesn't teleport to their leg
public GameObject leg;
private GameObject leg;
private bool isKicking = false;
//slightly bad practice, when merging find a better work around
private bool isDiveKicking = false;
private CharacterController characterController;
public PlayerStats pStats;
void Start(){
pStats = GetComponent<PlayerStats>();
characterController = this.gameObject.GetComponent<CharacterController>();
leg = transform.GetChild(0).gameObject;
leg.SetActive(false);
}
void Update(){
Kick();
}
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)
@@ -52,4 +62,15 @@ public class KickController : MonoBehaviour
}
private void OnCollisionEnter(Collision collision)
{
//if (!IsLocalPlayer) { return; }
Collider myCollider = collision.contacts[0].thisCollider;
if (collision.transform.CompareTag("kickable") && myCollider == leg.GetComponent<Collider>()){
Vector3 direction = this.transform.forward;
Debug.Log(direction);
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);
}
}
}

View File

@@ -1,71 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Mote: This should be refactored at some point
public class Slide : MonoBehaviour{
public Camera playerCam;
private bool isSliding = false;
private CharacterController charController;
private PlayerStats playerStats;
private float orignalTraction;
private RaycastHit ray;
private Vector3 up;
private void Awake(){
charController = this.gameObject.GetComponentInParent<CharacterController>();
playerStats = this.gameObject.GetComponentInParent<PlayerStats>();
up = this.gameObject.GetComponentInParent<Transform>().up;
}
// Update is called once per frame
void Update(){
//Debug.DrawRay(this.gameObject.transform.position, up, Color.red, 5.0f);
//NOTE::
//if button is held down, start sliding
if (Input.GetKey(KeyCode.Q)){
if (isSliding == false){
orignalTraction = playerStats.Traction;
this.gameObject.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x - 90, this.transform.eulerAngles.y, this.transform.eulerAngles.z);
isSliding = true;
charController.height = 1.0f;
playerStats.Traction = 0.01f;
}
}
//NOTE: potentialy change this to only allow player back up if there is nothing above them
if (Input.GetKeyUp(KeyCode.Q)) {
//if nothing is above the object, stop slidding
if (Physics.Raycast(this.gameObject.transform.position, up, out ray, 5f) == false)
{
this.gameObject.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x - 90, this.transform.eulerAngles.y, this.transform.eulerAngles.z);
isSliding = false;
charController.height = 2.0f;
playerStats.Traction = orignalTraction;
}
else{
Debug.Log("Object above you");
}
}
//if button is not held down, and still slidding (if they let go but something was above them) check to see if something is still above them, if not
else if (Input.GetKey(KeyCode.Q) == false && isSliding==true){
//if nothing is above the object, stop slidding
if (Physics.Raycast(this.gameObject.transform.position, up, out ray, 5f) == false)
{
this.gameObject.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x - 90, this.transform.eulerAngles.y, this.transform.eulerAngles.z);
isSliding = false;
charController.height = 2.0f;
playerStats.Traction = orignalTraction;
}
else
{
Debug.Log("Object above you");
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: aa419fd069f632e479eda138a7764362
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,9 +1,10 @@
using UnityEngine;
using System.Linq;
using MLAPI;
using UnityEngine.Rendering;
[RequireComponent (typeof(PlayerMovement))]
public class WallRun : MonoBehaviour
public class WallRun : NetworkBehaviour
{
public float wallMaxDistance = 1;
@@ -66,6 +67,9 @@ public class WallRun : MonoBehaviour
public void WallRunRoutine()
{
//if (!IsLocalPlayer) { return; }
isWallRunning = false;
if(playerMovementController.GetJumpPressed())