Rigidbody Standup has been implemented

This commit is contained in:
Melbyj1125
2021-10-29 12:28:36 -05:00
parent 5c8e13e0f5
commit 45a2c5b473
15 changed files with 246 additions and 155 deletions

View File

@@ -4,15 +4,17 @@ using UnityEngine;
public class InventoryManager : MonoBehaviour
{
public Item[] allItems;
private List<Item> itemList;
public List<Item> ItemList{
public Item[] allItems;
private List<Item> itemList;
public List<Item> ItemList{
get{ return itemList; }
set{ itemList = value; }
}
void Awake(){
allItems = Resources.LoadAll<Item>("ItemObjects");
}
void Awake(){
allItems = Resources.LoadAll<Item>("ItemObjects");
itemList = new List<Item>(allItems);
}
itemList = new List<Item>(allItems);
}
}

View File

@@ -13,7 +13,7 @@ public class SpecialItem : Item
public bool hasNitroM;
public bool hasDashM;
public float cooldownM;
public MonoScript scriptM;
//public TextAsset scriptM;
public override void Equip(PlayerStats p, GameObject player){
if(maxVelM != 0){
@@ -61,9 +61,11 @@ public class SpecialItem : Item
if(hasDashM != false){
p.HasDash = hasDashM;
}
/*
if(scriptM != null){
player.AddComponent(scriptM.GetClass());
player.AddComponent(scriptM);
}
*/
}
public override void Unequip(PlayerStats p, GameObject player){
@@ -112,9 +114,11 @@ public class SpecialItem : Item
if(hasDashM != false){
p.HasDash = false;
}
/*
if(scriptM != null){
Destroy(player.GetComponent(scriptM.GetClass()));
Destroy(player.GetComponent(scriptM));
}
*/
}
}

View File

@@ -1,7 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
}

View File

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

View File

@@ -30,7 +30,6 @@ public class PlayerInventory : MonoBehaviour
Debug.Log("Item Removed");
RemoveItem(item);
}
}
public void AddSpecialItem<T>(T itemCandidate) { // Unless we don't want the four special items to be handled by inventory/inventory manager?

View File

@@ -62,6 +62,8 @@ public class PlayerMovement : MonoBehaviour
private CapsuleCollider capCol;
private bool firstHit = false;
private bool heldDown = false;
private bool beginRagTimer = false;
private float ragTime;
private Vector3 prevRot;
private Vector3 hitForce;
@@ -78,7 +80,7 @@ public class PlayerMovement : MonoBehaviour
capCol.enabled = false;
//Wallrun
//wallRun = gameObject.GetComponent<WallRun>();
wallRun = gameObject.GetComponent<WallRun>();
}
void Start()
@@ -90,7 +92,7 @@ public class PlayerMovement : MonoBehaviour
// Update is called once per frame
void FixedUpdate()
{
//Controls for camera
Rotation();
@@ -107,7 +109,7 @@ public class PlayerMovement : MonoBehaviour
}
else{
if (rB.velocity.magnitude < 0.2f){
if (RagdollTimer() == 0){
firstHit = false;
DisableRagdoll();
@@ -258,12 +260,15 @@ public class PlayerMovement : MonoBehaviour
//Camera and Player Rotation
private void Rotation()
{
transform.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
Vector3 lastCamPos = new Vector3(0,0,0);
if(moveController.enabled){
transform.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
cam.transform.localEulerAngles = camRotation;
}
}
@@ -344,20 +349,40 @@ public class PlayerMovement : MonoBehaviour
}
}
private void EnableRagdoll(){
prevRot = transform.localEulerAngles;
capCol.enabled = true;
moveController.enabled = false;
rB.isKinematic = false;
rB.detectCollisions = true;
ragTime = pStats.RecovTime;
prevRot = transform.localEulerAngles;
capCol.enabled = true;
moveController.enabled = false;
rB.isKinematic = false;
rB.detectCollisions = true;
}
private void DisableRagdoll(){
capCol.enabled = false;
moveController.enabled = true;
rB.isKinematic = true;
rB.detectCollisions = false;
transform.localEulerAngles = prevRot;
capCol.enabled = false;
moveController.enabled = true;
rB.isKinematic = true;
rB.detectCollisions = false;
transform.localEulerAngles = prevRot;
}
//When to begin the ragdoll timer
private float RagdollTimer(){
if(beginRagTimer == false){
beginRagTimer = Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1f);
}
else if(ragTime <= 0){
ragTime = 0;
beginRagTimer = false;
}
if(beginRagTimer == true){
ragTime -= Time.deltaTime;
}
return ragTime;
}
}

View File

@@ -62,7 +62,7 @@ public class PlayerStats : MonoBehaviour
}
//Player Recovery Time When Knocked Down
private float recovTime;
private float recovTime = 5;
public float RecovTime{
get{ return recovTime; }
set{ recovTime = value; }

View File

@@ -1,18 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Setup : MonoBehaviour
{
private PlayerStats pstats;
public bool hasWallRun;
[Range( 1, 50)]
public float maxSpeed;
// Start is called before the first frame update
void Start()
{
pstats = this.gameObject.GetComponent<PlayerStats>();
pstats.HasWallrun = hasWallRun;
pstats.MaxVel = maxSpeed;
}
}

View File

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