From 45a2c5b473c0cf2a08c004ecb27a4b446770bfb5 Mon Sep 17 00:00:00 2001 From: Melbyj1125 <60886701+Melbyj1125@users.noreply.github.com> Date: Fri, 29 Oct 2021 12:28:36 -0500 Subject: [PATCH 1/2] Rigidbody Standup has been implemented --- Assets/Prefabs/Player/PlayerPrefab.prefab | 122 +++++++++++++++++- Assets/Scenes/Demos/InventorySelection.unity | 37 ++++++ Assets/Scenes/Demos/MovementScene.unity | 75 +---------- .../ItemScripts/InventoryManager.cs | 18 +-- .../PlayerScripts/ItemScripts/SpecialItem.cs | 10 +- Assets/Scripts/PlayerScripts/Player.cs | 7 - Assets/Scripts/PlayerScripts/Player.cs.meta | 11 -- .../Scripts/PlayerScripts/PlayerInventory.cs | 1 - .../Scripts/PlayerScripts/PlayerMovement.cs | 59 ++++++--- Assets/Scripts/PlayerScripts/PlayerStats.cs | 2 +- Assets/Scripts/PlayerScripts/Setup.cs | 18 --- Assets/Scripts/PlayerScripts/Setup.cs.meta | 11 -- .../Scripts/SetInvScene/InvSceneSettings.cs | 23 ++++ ProjectSettings/TagManager.asset | 3 +- UserSettings/EditorUserSettings.asset | 4 +- 15 files changed, 246 insertions(+), 155 deletions(-) delete mode 100644 Assets/Scripts/PlayerScripts/Player.cs delete mode 100644 Assets/Scripts/PlayerScripts/Player.cs.meta delete mode 100644 Assets/Scripts/PlayerScripts/Setup.cs delete mode 100644 Assets/Scripts/PlayerScripts/Setup.cs.meta diff --git a/Assets/Prefabs/Player/PlayerPrefab.prefab b/Assets/Prefabs/Player/PlayerPrefab.prefab index 862d09e..70ac2ee 100644 --- a/Assets/Prefabs/Player/PlayerPrefab.prefab +++ b/Assets/Prefabs/Player/PlayerPrefab.prefab @@ -98,6 +98,14 @@ GameObject: - component: {fileID: 471272923182148881} - component: {fileID: 1292213096936070766} - component: {fileID: 7623511089535041046} + - component: {fileID: 1602186932439279558} + - component: {fileID: 4910425103423673310} + - component: {fileID: 1122837021074491360} + - component: {fileID: 1006370620272136424} + - component: {fileID: 623466146960117777} + - component: {fileID: 1121632309457683679} + - component: {fileID: 7442108947324986527} + - component: {fileID: 3454731726544993114} m_Layer: 3 m_Name: PlayerPrefab m_TagString: Player @@ -238,7 +246,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 7188906082087890184} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3} m_Name: @@ -279,6 +287,118 @@ MonoBehaviour: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!114 &1602186932439279558 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7188906082087890184} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5162a84172831f4449df60b9ad0ce22f, type: 3} + m_Name: + m_EditorClassIdentifier: + controller: {fileID: 0} +--- !u!114 &4910425103423673310 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7188906082087890184} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 980b3f40ede2d8a4c96587100cf71d02, type: 3} + m_Name: + m_EditorClassIdentifier: + moveDirection: {x: 0, y: 0, z: 0} + dashDistance: 10 + dashStoppingSpeed: 0.1 +--- !u!114 &1122837021074491360 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7188906082087890184} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cee70ea30de57ec43a325c1ca6257526, type: 3} + m_Name: + m_EditorClassIdentifier: + maxGrappleDistance: 25 +--- !u!114 &1006370620272136424 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7188906082087890184} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f9b52b0ade3c44e47a3a4dc48c47ec1c, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &623466146960117777 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7188906082087890184} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0c0aad94b3b1332408ef8e7d07f3b321, type: 3} + m_Name: + m_EditorClassIdentifier: + leg: {fileID: 0} +--- !u!114 &1121632309457683679 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7188906082087890184} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1a8c22589436d2449a89cf3a40b6d252, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &7442108947324986527 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7188906082087890184} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: aa419fd069f632e479eda138a7764362, type: 3} + m_Name: + m_EditorClassIdentifier: + playerCam: {fileID: 0} +--- !u!114 &3454731726544993114 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7188906082087890184} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 535009eaa735a4c4e95c6fc270e32741, type: 3} + m_Name: + m_EditorClassIdentifier: + wallMaxDistance: 1 + wallSpeedMultiplier: 1.2 + minimumHeight: 1.2 + maxAngleRoll: 20 + normalizedAngleThreshold: 0.1 + jumpDuration: 1 + wallBouncing: 3 + cameraTransitionDuration: 1 + wallGravityDownForce: 20 --- !u!1 &7188906082643956521 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Demos/InventorySelection.unity b/Assets/Scenes/Demos/InventorySelection.unity index 1b6d5ae..dd77da2 100644 --- a/Assets/Scenes/Demos/InventorySelection.unity +++ b/Assets/Scenes/Demos/InventorySelection.unity @@ -388,6 +388,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: itemOptPrefab: {fileID: 8447329698821624902, guid: 51a78c57dc85625428c8f1e6448d113f, type: 3} + moveScripts: [] --- !u!114 &526839288 MonoBehaviour: m_ObjectHideFlags: 0 @@ -501,6 +502,34 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 623466146960117777, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1006370620272136424, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1121632309457683679, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1122837021074491360, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1602186932439279558, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3454731726544993114, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4910425103423673310, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} propertyPath: m_RootOrder value: 3 @@ -549,6 +578,14 @@ PrefabInstance: propertyPath: m_Name value: PlayerPrefab objectReference: {fileID: 0} + - target: {fileID: 7442108947324986527, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7623511089535041046, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} --- !u!1 &591528209 diff --git a/Assets/Scenes/Demos/MovementScene.unity b/Assets/Scenes/Demos/MovementScene.unity index 561cfa5..beeee65 100644 --- a/Assets/Scenes/Demos/MovementScene.unity +++ b/Assets/Scenes/Demos/MovementScene.unity @@ -313,79 +313,6 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 228851343} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!1001 &279177648 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 2274833863450849408, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_Enabled - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_RootOrder - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_LocalPosition.x - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_LocalPosition.y - value: 1.8 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_LocalPosition.z - value: -0.2 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890183, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: items.Array.size - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890183, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: items.Array.data[0] - value: - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890184, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_Name - value: PlayerPrefab - objectReference: {fileID: 0} - - target: {fileID: 7188906082087890184, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} - propertyPath: m_IsActive - value: 1 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} --- !u!1 &478416584 GameObject: m_ObjectHideFlags: 0 @@ -1060,7 +987,7 @@ GameObject: - component: {fileID: 1493944131} m_Layer: 0 m_Name: Platforms - m_TagString: Untagged + m_TagString: Floor m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 diff --git a/Assets/Scripts/PlayerScripts/ItemScripts/InventoryManager.cs b/Assets/Scripts/PlayerScripts/ItemScripts/InventoryManager.cs index 5e153e9..061f336 100644 --- a/Assets/Scripts/PlayerScripts/ItemScripts/InventoryManager.cs +++ b/Assets/Scripts/PlayerScripts/ItemScripts/InventoryManager.cs @@ -4,15 +4,17 @@ using UnityEngine; public class InventoryManager : MonoBehaviour { - public Item[] allItems; - private List itemList; - public List ItemList{ + public Item[] allItems; + private List itemList; + public List ItemList{ get{ return itemList; } set{ itemList = value; } - } - void Awake(){ - allItems = Resources.LoadAll("ItemObjects"); + } + + + void Awake(){ + allItems = Resources.LoadAll("ItemObjects"); - itemList = new List(allItems); - } + itemList = new List(allItems); + } } diff --git a/Assets/Scripts/PlayerScripts/ItemScripts/SpecialItem.cs b/Assets/Scripts/PlayerScripts/ItemScripts/SpecialItem.cs index ac74a2e..7441ae5 100644 --- a/Assets/Scripts/PlayerScripts/ItemScripts/SpecialItem.cs +++ b/Assets/Scripts/PlayerScripts/ItemScripts/SpecialItem.cs @@ -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)); } + */ } } diff --git a/Assets/Scripts/PlayerScripts/Player.cs b/Assets/Scripts/PlayerScripts/Player.cs deleted file mode 100644 index 06a0ed3..0000000 --- a/Assets/Scripts/PlayerScripts/Player.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Player : MonoBehaviour -{ -} diff --git a/Assets/Scripts/PlayerScripts/Player.cs.meta b/Assets/Scripts/PlayerScripts/Player.cs.meta deleted file mode 100644 index e75b2ac..0000000 --- a/Assets/Scripts/PlayerScripts/Player.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c2c2e0314365de34c923bb88c9b334ca -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/PlayerScripts/PlayerInventory.cs b/Assets/Scripts/PlayerScripts/PlayerInventory.cs index 8589700..c9f81b2 100644 --- a/Assets/Scripts/PlayerScripts/PlayerInventory.cs +++ b/Assets/Scripts/PlayerScripts/PlayerInventory.cs @@ -30,7 +30,6 @@ public class PlayerInventory : MonoBehaviour Debug.Log("Item Removed"); RemoveItem(item); } - } public void AddSpecialItem(T itemCandidate) { // Unless we don't want the four special items to be handled by inventory/inventory manager? diff --git a/Assets/Scripts/PlayerScripts/PlayerMovement.cs b/Assets/Scripts/PlayerScripts/PlayerMovement.cs index 96aabf4..69f0d25 100644 --- a/Assets/Scripts/PlayerScripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerScripts/PlayerMovement.cs @@ -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 = gameObject.GetComponent(); } 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; + } + + } diff --git a/Assets/Scripts/PlayerScripts/PlayerStats.cs b/Assets/Scripts/PlayerScripts/PlayerStats.cs index b0da84e..76d1935 100644 --- a/Assets/Scripts/PlayerScripts/PlayerStats.cs +++ b/Assets/Scripts/PlayerScripts/PlayerStats.cs @@ -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; } diff --git a/Assets/Scripts/PlayerScripts/Setup.cs b/Assets/Scripts/PlayerScripts/Setup.cs deleted file mode 100644 index aa28d53..0000000 --- a/Assets/Scripts/PlayerScripts/Setup.cs +++ /dev/null @@ -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(); - pstats.HasWallrun = hasWallRun; - pstats.MaxVel = maxSpeed; - } -} diff --git a/Assets/Scripts/PlayerScripts/Setup.cs.meta b/Assets/Scripts/PlayerScripts/Setup.cs.meta deleted file mode 100644 index 84b5c93..0000000 --- a/Assets/Scripts/PlayerScripts/Setup.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ed382e04d00059e40a6803fa4ad43469 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/SetInvScene/InvSceneSettings.cs b/Assets/Scripts/SetInvScene/InvSceneSettings.cs index 123f5db..cbb0bbb 100644 --- a/Assets/Scripts/SetInvScene/InvSceneSettings.cs +++ b/Assets/Scripts/SetInvScene/InvSceneSettings.cs @@ -29,11 +29,16 @@ public class InvSceneSettings : MonoBehaviour } void Start(){ + player1.GetComponent().enabled = true; InitializeItemB(); pointsLeft = pStats.PlayerPoints; pointText.text = "Points Left: " + pointsLeft; } + void FixedUpdate(){ + itemToEnable(); + } + private void InitializeItemB(){ int index = 0; if(itemOptPrefab != null){ @@ -82,8 +87,26 @@ public class InvSceneSettings : MonoBehaviour } } + + //Enables Script on player + //NEEDS TO BE CLEANED UP AND IMPROVED + public void itemToEnable(){ + if(pStats.HasBlink != player1.GetComponent().enabled) + player1.GetComponent().enabled = pStats.HasBlink; + if(pStats.HasDash != player1.GetComponent().enabled) + player1.GetComponent().enabled = pStats.HasDash; + if(pStats.HasWallrun != player1.GetComponent().enabled) + player1.GetComponent().enabled = pStats.HasWallrun; + if(pStats.HasGrapple != player1.GetComponent().enabled) + player1.GetComponent().enabled = pStats.HasGrapple; + if(pStats.HasNitro != player1.GetComponent().enabled) + player1.GetComponent().enabled = pStats.HasNitro; + + } + public void nextScene(){ player1.GetComponent().enabled = true; + player1.GetComponent().enabled = false; player1.transform.GetChild(0).gameObject.SetActive(true); SceneManager.LoadScene (SceneManager.GetActiveScene().buildIndex + 1); } diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index ab274e7..d6fbece 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -8,6 +8,7 @@ TagManager: - kickable - PlayerCam - HookPoint + - Floor layers: - Default - TransparentFX @@ -15,7 +16,7 @@ TagManager: - Player - Water - UI - - + - Floor - - - diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index d0e822a..71a6fbf 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -21,10 +21,10 @@ EditorUserSettings: value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb flags: 0 RecentlyUsedScenePath-5: - value: 22424703114646680e0b0227036c7b151b180b6505263035233d1221fbd33134e7e422e0e8347129370bfb25 + value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26 flags: 0 RecentlyUsedScenePath-6: - value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26 + value: 22424703114646680e0b0227036c7b151b180b6505263035233d1221fbd33134e7e422e0e8347129370bfb25 flags: 0 UnityRemoteCompression: value: 337f73 From 63e23182520f64abbda835eb74331494b51b16ae Mon Sep 17 00:00:00 2001 From: Melbyj1125 <60886701+Melbyj1125@users.noreply.github.com> Date: Mon, 1 Nov 2021 12:15:17 -0500 Subject: [PATCH 2/2] Updated PlayerPrefab Implemented Slide into player Added CamFollow --- Assets/Prefabs/Player/PlayerPrefab.prefab | 376 +++++++++--------- Assets/Scenes/Demos/InventorySelection.unity | 21 +- .../PlayerScripts/MovementAbilities/Slide.cs | 7 +- Assets/Scripts/PlayerScripts/PlayerCam.cs | 23 ++ .../Scripts/PlayerScripts/PlayerCam.cs.meta | 11 + .../Scripts/PlayerScripts/PlayerInventory.cs | 2 +- .../Scripts/PlayerScripts/PlayerMovement.cs | 97 ++++- Assets/Scripts/PlayerScripts/PlayerStats.cs | 27 +- .../Scripts/SetInvScene/InvSceneSettings.cs | 8 +- 9 files changed, 354 insertions(+), 218 deletions(-) create mode 100644 Assets/Scripts/PlayerScripts/PlayerCam.cs create mode 100644 Assets/Scripts/PlayerScripts/PlayerCam.cs.meta diff --git a/Assets/Prefabs/Player/PlayerPrefab.prefab b/Assets/Prefabs/Player/PlayerPrefab.prefab index 70ac2ee..b601afb 100644 --- a/Assets/Prefabs/Player/PlayerPrefab.prefab +++ b/Assets/Prefabs/Player/PlayerPrefab.prefab @@ -11,6 +11,21 @@ GameObject: - component: {fileID: 394725941300514827} - component: {fileID: 3891196372269872751} - component: {fileID: 1779614325098168083} + - component: {fileID: 5086810605069144388} + - component: {fileID: 3725107173017604129} + - component: {fileID: 508183713705064073} + - component: {fileID: 6646742430777996202} + - component: {fileID: 6946259593417347243} + - component: {fileID: 273103334658887749} + - component: {fileID: 1952443820573609623} + - component: {fileID: 4323471435859684389} + - component: {fileID: 3672942772524564832} + - component: {fileID: 2620970719070296463} + - component: {fileID: 2356773567935625033} + - component: {fileID: 2942875262947626129} + - component: {fileID: 8956701063868523892} + - component: {fileID: 3772338269032432186} + - component: {fileID: 5687943635225929219} m_Layer: 0 m_Name: PlayerModel m_TagString: Untagged @@ -81,73 +96,25 @@ MeshRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_AdditionalVertexStreams: {fileID: 0} ---- !u!1 &7188906082087890184 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 7188906082087890177} - - component: {fileID: 7188906082087890180} - - component: {fileID: 7188906082087890183} - - component: {fileID: 7188906082087890185} - - component: {fileID: 6558661690282462800} - - component: {fileID: 2274833863450849408} - - component: {fileID: 471272923182148881} - - component: {fileID: 1292213096936070766} - - component: {fileID: 7623511089535041046} - - component: {fileID: 1602186932439279558} - - component: {fileID: 4910425103423673310} - - component: {fileID: 1122837021074491360} - - component: {fileID: 1006370620272136424} - - component: {fileID: 623466146960117777} - - component: {fileID: 1121632309457683679} - - component: {fileID: 7442108947324986527} - - component: {fileID: 3454731726544993114} - m_Layer: 3 - m_Name: PlayerPrefab - m_TagString: Player - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &7188906082087890177 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 1, y: 1.8, z: -0.2} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 7188906082643956518} - - {fileID: 394725941300514827} - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &7188906082087890180 +--- !u!114 &5086810605069144388 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} + m_GameObject: {fileID: 4814433541978696327} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: addc2e37ff81c1b4989ec34b6150b4f7, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &7188906082087890183 +--- !u!114 &3725107173017604129 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} + m_GameObject: {fileID: 4814433541978696327} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5a5d879591af1084ab5d3a35fcd53086, type: 3} @@ -155,13 +122,13 @@ MonoBehaviour: m_EditorClassIdentifier: items: [] pStats: {fileID: 0} ---- !u!114 &7188906082087890185 +--- !u!114 &508183713705064073 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} + m_GameObject: {fileID: 4814433541978696327} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 22ae0d31c49624d4fb9990f2f5f72fd9, type: 3} @@ -174,61 +141,13 @@ MonoBehaviour: minAngle: -30 maxAngle: 45 sensitivity: 301 ---- !u!143 &6558661690282462800 -CharacterController: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Height: 2 - m_Radius: 0.5 - m_SlopeLimit: 45 - m_StepOffset: 0.3 - m_SkinWidth: 0.08 - m_MinMoveDistance: 0.001 - m_Center: {x: 0, y: 0, z: 0} ---- !u!136 &2274833863450849408 -CapsuleCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 0 - m_Radius: 0.5 - m_Height: 2 - m_Direction: 1 - m_Center: {x: 0, y: 0, z: 0} ---- !u!54 &471272923182148881 -Rigidbody: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} - serializedVersion: 2 - m_Mass: 1 - m_Drag: 0 - m_AngularDrag: 0.05 - m_UseGravity: 0 - m_IsKinematic: 1 - m_Interpolate: 0 - m_Constraints: 0 - m_CollisionDetection: 0 ---- !u!114 &1292213096936070766 +--- !u!114 &6646742430777996202 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} + m_GameObject: {fileID: 4814433541978696327} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} @@ -239,13 +158,13 @@ MonoBehaviour: PrefabHashGenerator: PlayerPrefab AlwaysReplicateAsRoot: 0 DontDestroyWithOwner: 0 ---- !u!114 &7623511089535041046 +--- !u!114 &6946259593417347243 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} + m_GameObject: {fileID: 4814433541978696327} m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3} @@ -287,104 +206,26 @@ MonoBehaviour: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 ---- !u!114 &1602186932439279558 +--- !u!114 &273103334658887749 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} + m_GameObject: {fileID: 4814433541978696327} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 5162a84172831f4449df60b9ad0ce22f, type: 3} m_Name: m_EditorClassIdentifier: controller: {fileID: 0} ---- !u!114 &4910425103423673310 +--- !u!114 &1952443820573609623 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 980b3f40ede2d8a4c96587100cf71d02, type: 3} - m_Name: - m_EditorClassIdentifier: - moveDirection: {x: 0, y: 0, z: 0} - dashDistance: 10 - dashStoppingSpeed: 0.1 ---- !u!114 &1122837021074491360 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cee70ea30de57ec43a325c1ca6257526, type: 3} - m_Name: - m_EditorClassIdentifier: - maxGrappleDistance: 25 ---- !u!114 &1006370620272136424 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f9b52b0ade3c44e47a3a4dc48c47ec1c, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!114 &623466146960117777 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0c0aad94b3b1332408ef8e7d07f3b321, type: 3} - m_Name: - m_EditorClassIdentifier: - leg: {fileID: 0} ---- !u!114 &1121632309457683679 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 1a8c22589436d2449a89cf3a40b6d252, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!114 &7442108947324986527 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: aa419fd069f632e479eda138a7764362, type: 3} - m_Name: - m_EditorClassIdentifier: - playerCam: {fileID: 0} ---- !u!114 &3454731726544993114 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7188906082087890184} + m_GameObject: {fileID: 4814433541978696327} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 535009eaa735a4c4e95c6fc270e32741, type: 3} @@ -399,6 +240,151 @@ MonoBehaviour: wallBouncing: 3 cameraTransitionDuration: 1 wallGravityDownForce: 20 +--- !u!114 &4323471435859684389 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4814433541978696327} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 980b3f40ede2d8a4c96587100cf71d02, type: 3} + m_Name: + m_EditorClassIdentifier: + moveDirection: {x: 0, y: 0, z: 0} + dashDistance: 10 + dashStoppingSpeed: 0.1 +--- !u!114 &3672942772524564832 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4814433541978696327} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cee70ea30de57ec43a325c1ca6257526, type: 3} + m_Name: + m_EditorClassIdentifier: + maxGrappleDistance: 25 +--- !u!114 &2620970719070296463 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4814433541978696327} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f9b52b0ade3c44e47a3a4dc48c47ec1c, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &2356773567935625033 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4814433541978696327} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0c0aad94b3b1332408ef8e7d07f3b321, type: 3} + m_Name: + m_EditorClassIdentifier: + leg: {fileID: 0} +--- !u!114 &2942875262947626129 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4814433541978696327} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1a8c22589436d2449a89cf3a40b6d252, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!54 &8956701063868523892 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4814433541978696327} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_UseGravity: 0 + m_IsKinematic: 1 + m_Interpolate: 0 + m_Constraints: 0 + m_CollisionDetection: 0 +--- !u!136 &3772338269032432186 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4814433541978696327} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 1 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} +--- !u!143 &5687943635225929219 +CharacterController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4814433541978696327} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Height: 2 + m_Radius: 0.5 + m_SlopeLimit: 45 + m_StepOffset: 0.3 + m_SkinWidth: 0.08 + m_MinMoveDistance: 0.001 + m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &7188906082087890184 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7188906082087890177} + m_Layer: 3 + m_Name: PlayerPrefab + m_TagString: Player + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7188906082087890177 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7188906082087890184} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 1, y: 1.8, z: -0.2} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7188906082643956518} + - {fileID: 394725941300514827} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &7188906082643956521 GameObject: m_ObjectHideFlags: 0 @@ -410,6 +396,7 @@ GameObject: - component: {fileID: 7188906082643956518} - component: {fileID: 7188906082643956516} - component: {fileID: 7188906082643956519} + - component: {fileID: 4875054560273456582} m_Layer: 3 m_Name: PlayerCam m_TagString: PlayerCam @@ -482,3 +469,16 @@ AudioListener: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 7188906082643956521} m_Enabled: 1 +--- !u!114 &4875054560273456582 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7188906082643956521} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 394466212a506df4da8f22e46bd4e333, type: 3} + m_Name: + m_EditorClassIdentifier: + player: {fileID: 4814433541978696327} diff --git a/Assets/Scenes/Demos/InventorySelection.unity b/Assets/Scenes/Demos/InventorySelection.unity index dd77da2..a75d3b0 100644 --- a/Assets/Scenes/Demos/InventorySelection.unity +++ b/Assets/Scenes/Demos/InventorySelection.unity @@ -388,7 +388,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: itemOptPrefab: {fileID: 8447329698821624902, guid: 51a78c57dc85625428c8f1e6448d113f, type: 3} - moveScripts: [] --- !u!114 &526839288 MonoBehaviour: m_ObjectHideFlags: 0 @@ -526,10 +525,22 @@ PrefabInstance: propertyPath: m_Enabled value: 1 objectReference: {fileID: 0} + - target: {fileID: 3772338269032432186, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_Height + value: 2 + objectReference: {fileID: 0} - target: {fileID: 4910425103423673310, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} propertyPath: m_Enabled value: 1 objectReference: {fileID: 0} + - target: {fileID: 7061360697648900808, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_UseGravity + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7061360697648900808, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_IsKinematic + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} propertyPath: m_RootOrder value: 3 @@ -586,6 +597,14 @@ PrefabInstance: propertyPath: m_Enabled value: 0 objectReference: {fileID: 0} + - target: {fileID: 8956701063868523892, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_UseGravity + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8956701063868523892, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} + propertyPath: m_CollisionDetection + value: 3 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3} --- !u!1 &591528209 diff --git a/Assets/Scripts/PlayerScripts/MovementAbilities/Slide.cs b/Assets/Scripts/PlayerScripts/MovementAbilities/Slide.cs index 8cf40c4..a4f3a9b 100644 --- a/Assets/Scripts/PlayerScripts/MovementAbilities/Slide.cs +++ b/Assets/Scripts/PlayerScripts/MovementAbilities/Slide.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; //Mote: This should be refactored at some point public class Slide : MonoBehaviour{ - //this may be deprecated at some poiint later in development if we start ussing a rigid bod + public Camera playerCam; private bool isSliding = false; private CharacterController charController; @@ -11,10 +11,7 @@ public class Slide : MonoBehaviour{ private float orignalTraction; private RaycastHit ray; private Vector3 up; - // Start is called before the first frame update - void Start(){ - - } + private void Awake(){ charController = this.gameObject.GetComponentInParent(); playerStats = this.gameObject.GetComponentInParent(); diff --git a/Assets/Scripts/PlayerScripts/PlayerCam.cs b/Assets/Scripts/PlayerScripts/PlayerCam.cs new file mode 100644 index 0000000..1196014 --- /dev/null +++ b/Assets/Scripts/PlayerScripts/PlayerCam.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerCam : MonoBehaviour +{ + public GameObject player; + + private Vector3 offset; + private Vector3 rad; + + void Start () + { + rad = (transform.position - player.transform.position); + } + + void Update () + { + offset = transform.parent.forward * rad.magnitude; + transform.position = new Vector3((player.transform.position.x - offset.x),((player.transform.position.y - offset.y)+2),(player.transform.position.z - offset.z)); + + } +} diff --git a/Assets/Scripts/PlayerScripts/PlayerCam.cs.meta b/Assets/Scripts/PlayerScripts/PlayerCam.cs.meta new file mode 100644 index 0000000..089bcca --- /dev/null +++ b/Assets/Scripts/PlayerScripts/PlayerCam.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 394466212a506df4da8f22e46bd4e333 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PlayerScripts/PlayerInventory.cs b/Assets/Scripts/PlayerScripts/PlayerInventory.cs index c9f81b2..52c6752 100644 --- a/Assets/Scripts/PlayerScripts/PlayerInventory.cs +++ b/Assets/Scripts/PlayerScripts/PlayerInventory.cs @@ -13,7 +13,7 @@ public class PlayerInventory : MonoBehaviour void Awake(){ pStats = GetComponent(); - DontDestroyOnLoad(this.gameObject); + DontDestroyOnLoad(transform.parent.gameObject); } diff --git a/Assets/Scripts/PlayerScripts/PlayerMovement.cs b/Assets/Scripts/PlayerScripts/PlayerMovement.cs index 69f0d25..1e090e5 100644 --- a/Assets/Scripts/PlayerScripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerScripts/PlayerMovement.cs @@ -18,6 +18,9 @@ public class PlayerMovement : MonoBehaviour private Vector3 moveX; private Vector3 driftVel; + //Player prefab + private GameObject parentObj; + //Character Moving private CharacterController moveController; @@ -67,6 +70,15 @@ public class PlayerMovement : MonoBehaviour private Vector3 prevRot; private Vector3 hitForce; + //Slide Variables + private bool isSliding = false; + private float originalTraction; + private RaycastHit ray; + private Vector3 up; + private bool qDown; + + //Kick Variables + void Awake() { //Initialize Components @@ -74,13 +86,16 @@ public class PlayerMovement : MonoBehaviour rB = GetComponent(); capCol = GetComponent(); pStats = GetComponent(); + parentObj = transform.parent.gameObject; //camera transform - cam = GetComponentInChildren(); + cam = parentObj.GetComponentInChildren(); capCol.enabled = false; //Wallrun wallRun = gameObject.GetComponent(); + + up = this.gameObject.GetComponentInParent().up; } void Start() @@ -137,8 +152,6 @@ public class PlayerMovement : MonoBehaviour //Checks if player should respawn Respawn(); - - } @@ -162,9 +175,13 @@ public class PlayerMovement : MonoBehaviour Gravity(); driftVel = Vector3.Lerp(driftVel, vel, pStats.Traction * Time.deltaTime); + + //Moving outside basic wasd //Jump Function Jump(); - + //Slide Function + Slide(); + moveController.Move(driftVel); } @@ -174,7 +191,7 @@ public class PlayerMovement : MonoBehaviour public float PlayerSpeed() { //If nothing is pressed speed is 0 - if (Input.GetAxis("Vertical") == 0.0f && Input.GetAxis("Horizontal") == 0.0f) + if ((Input.GetAxis("Vertical") == 0.0f && Input.GetAxis("Horizontal") == 0.0f) || isSliding) { pStats.CurVel = 0.0f; return pStats.CurVel; @@ -215,7 +232,7 @@ public class PlayerMovement : MonoBehaviour private void Jump() { //If space is pressed apply an upwards force to the player - if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum) + if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding) { AddImpact(transform.up, pStats.JumpPow); curJumpNum++; @@ -261,14 +278,21 @@ public class PlayerMovement : MonoBehaviour private void Rotation() { Vector3 lastCamPos = new Vector3(0,0,0); + Vector3 rotOffset = transform.localEulerAngles; if(moveController.enabled){ - transform.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X")); + transform.parent.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); - cam.transform.localEulerAngles = camRotation; + camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime; + camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle); + + cam.transform.localEulerAngles = camRotation; } + /* + else{ + cam.transform.localEulerAngles = cam.transform.localEulerAngles - rotOffset; + } + */ } @@ -368,7 +392,7 @@ public class PlayerMovement : MonoBehaviour //When to begin the ragdoll timer private float RagdollTimer(){ if(beginRagTimer == false){ - beginRagTimer = Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1f); + beginRagTimer = Physics.Raycast(transform.position, -Vector3.up, distToGround + 1f); } else if(ragTime <= 0){ @@ -383,6 +407,57 @@ public class PlayerMovement : MonoBehaviour return ragTime; } + //Slide Function + private void Slide(){ + if (Input.GetKey(KeyCode.Q)){ + qDown = true; + if (isSliding == false){ + originalTraction = pStats.Traction; + this.gameObject.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x - 90, this.transform.eulerAngles.y, this.transform.eulerAngles.z); + isSliding = true; + moveController.height = 1.0f; + pStats.Traction = 0.01f; + + } + pStats.Traction += .02f; + } + else{ + qDown = false; + } + //NOTE: potentialy change this to only allow player back up if there is nothing above them + if (qDown == 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; + moveController.height = 2.0f; + pStats.Traction = originalTraction; + } + 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; + moveController.height = 2.0f; + pStats.Traction = originalTraction; + + } + else + { + Debug.Log("Object above you"); + + } + + } + } } diff --git a/Assets/Scripts/PlayerScripts/PlayerStats.cs b/Assets/Scripts/PlayerScripts/PlayerStats.cs index 76d1935..9db11a3 100644 --- a/Assets/Scripts/PlayerScripts/PlayerStats.cs +++ b/Assets/Scripts/PlayerScripts/PlayerStats.cs @@ -26,7 +26,7 @@ public class PlayerStats : MonoBehaviour set{ curVel = value; } } - //Player Jump power + //Player Acceleration private float acc = 0.1f; public float Acc{ get{ return acc; } @@ -62,7 +62,7 @@ public class PlayerStats : MonoBehaviour } //Player Recovery Time When Knocked Down - private float recovTime = 5; + private float recovTime = 3.0f; public float RecovTime{ get{ return recovTime; } set{ recovTime = value; } @@ -112,7 +112,7 @@ public class PlayerStats : MonoBehaviour } //If The Player Has Dash - private bool hasDash = false; + private bool hasDash; public bool HasDash{ get{ return hasDash; } set{ hasDash = value; } @@ -124,12 +124,21 @@ public class PlayerStats : MonoBehaviour set{ playerPoints = value; } } - // void Update(){ - // VariableValidation(); - // } + void Update(){ + VariableValidation(); + } - // void VariableValidation(){ - // Debug.Assert((playerPoints != null && playerPoints > 0), "Not valid value"); - // } + void VariableValidation(){ + Debug.Assert((maxVel >= 0), "maxVel cannot be below zero"); + Debug.Assert((minVel >= 0), "minVel cannot be below zero"); + Debug.Assert((curVel >= 0), "curVel cannot be below zero"); + Debug.Assert((jumpPow >= 0), "jumpPow cannot be below zero"); + Debug.Assert((jumpNum >= 2), "jumpNum cannot be below zero"); + Debug.Assert((traction >= 0), "traction cannot be below zero"); + //Debug.Assert((kickPow >= 0), "Playerpoints cannot be below zero"); + Debug.Assert((recovTime >= 0), "recovTime cannot be below zero"); + Debug.Assert((playerGrav >= 0), "playerGrav cannot be below zero"); + Debug.Assert((playerPoints >= 0), "Playerpoints cannot be below zero"); + } } diff --git a/Assets/Scripts/SetInvScene/InvSceneSettings.cs b/Assets/Scripts/SetInvScene/InvSceneSettings.cs index cbb0bbb..7dc6646 100644 --- a/Assets/Scripts/SetInvScene/InvSceneSettings.cs +++ b/Assets/Scripts/SetInvScene/InvSceneSettings.cs @@ -6,6 +6,7 @@ using UnityEngine.SceneManagement; public class InvSceneSettings : MonoBehaviour { + GameObject pPar; GameObject player1; PlayerInventory pInv; public GameObject itemOptPrefab; @@ -18,12 +19,13 @@ public class InvSceneSettings : MonoBehaviour // Start is called before the first frame update void Awake(){ - player1 = GameObject.Find("PlayerPrefab"); + pPar = GameObject.Find("PlayerPrefab"); + player1 = pPar.transform.Find("PlayerModel").gameObject; pStats = player1.GetComponent(); pointText = GameObject.Find("PlayerPoints").GetComponentInChildren(); pInv = player1.GetComponent(); player1.GetComponent().enabled = false; - player1.transform.Find("PlayerCam").gameObject.SetActive(false); + pPar.transform.Find("PlayerCam").gameObject.SetActive(false); invMan = GetComponent(); } @@ -107,7 +109,7 @@ public class InvSceneSettings : MonoBehaviour public void nextScene(){ player1.GetComponent().enabled = true; player1.GetComponent().enabled = false; - player1.transform.GetChild(0).gameObject.SetActive(true); + pPar.transform.GetChild(0).gameObject.SetActive(true); SceneManager.LoadScene (SceneManager.GetActiveScene().buildIndex + 1); }