From bd36986887f4df50e03d2311d7080c38583bc0d8 Mon Sep 17 00:00:00 2001 From: Melbyj1125 <60886701+Melbyj1125@users.noreply.github.com> Date: Mon, 6 Dec 2021 14:16:41 -0600 Subject: [PATCH 1/5] Reworked Jumping slightly Added Coyote Jump Fixed Wallrun Again Fixed Glider --- .../Prefabs/Player/DebugPlayerPrefab.prefab | 22 +++++- Assets/Scenes/Demos/MovementScene.unity | 20 +++++- .../DebugPlayer/dPlayerMovement.cs | 63 ++++++++++------- .../Scripts/PlayerScripts/PlayerMovement.cs | 67 ++++++++++++------- Assets/Scripts/PlayerScripts/PlayerStats.cs | 4 +- ProjectSettings/TagManager.asset | 2 +- UserSettings/EditorUserSettings.asset | 10 +-- 7 files changed, 126 insertions(+), 62 deletions(-) diff --git a/Assets/Prefabs/Player/DebugPlayerPrefab.prefab b/Assets/Prefabs/Player/DebugPlayerPrefab.prefab index 31c580f..8ff0def 100644 --- a/Assets/Prefabs/Player/DebugPlayerPrefab.prefab +++ b/Assets/Prefabs/Player/DebugPlayerPrefab.prefab @@ -216,7 +216,7 @@ GameObject: - component: {fileID: 1818923263116056088} m_Layer: 3 m_Name: PlayerModel - m_TagString: Untagged + m_TagString: Player m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -297,6 +297,23 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: addc2e37ff81c1b4989ec34b6150b4f7, type: 3} m_Name: m_EditorClassIdentifier: + maxVel: 25 + minVel: 2 + curVel: 0 + acc: 0.1 + jumpPow: 500 + jumpNum: 2 + traction: 3 + kickPow: 150 + recovTime: 3 + playerGrav: 35 + hasBlink: 0 + hasGlider: 0 + hasGrapple: 0 + hasWallrun: 0 + hasNitro: 0 + hasDash: 0 + playerPoints: 15 --- !u!114 &7097691538269713306 MonoBehaviour: m_ObjectHideFlags: 0 @@ -311,7 +328,6 @@ MonoBehaviour: m_EditorClassIdentifier: networkItemList: [] pStats: {fileID: 0} - invMan: {fileID: 0} --- !u!54 &7058615058147771192 Rigidbody: m_ObjectHideFlags: 0 @@ -422,6 +438,7 @@ MonoBehaviour: m_EditorClassIdentifier: pStats: {fileID: 0} vel: {x: 0, y: 0, z: 0} + curJumpNum: 0 isGrounded: 0 groundCheckDistance: 0.05 cam: {fileID: 4654986889578046791} @@ -469,6 +486,7 @@ MonoBehaviour: moveDirection: {x: 0, y: 0, z: 0} dashDistance: 10 dashStoppingSpeed: 0.1 + dashItem: {fileID: 0} --- !u!114 &1818923263116056088 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Demos/MovementScene.unity b/Assets/Scenes/Demos/MovementScene.unity index d915af7..167ef7b 100644 --- a/Assets/Scenes/Demos/MovementScene.unity +++ b/Assets/Scenes/Demos/MovementScene.unity @@ -940,6 +940,10 @@ PrefabInstance: propertyPath: wallMaxDistance value: 0.8 objectReference: {fileID: 0} + - target: {fileID: 2782774462923692506, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 3607330906377400225, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: m_TagString value: Player @@ -948,6 +952,10 @@ PrefabInstance: propertyPath: m_Name value: DebugPlayerPrefab objectReference: {fileID: 0} + - target: {fileID: 6743056025486776975, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: groundCheckHitbox.m_Bits + value: 8 + objectReference: {fileID: 0} - target: {fileID: 6926740475113451123, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: m_RootOrder value: 4 @@ -958,7 +966,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6926740475113451123, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: m_LocalPosition.y - value: 7.4 + value: 57.5 objectReference: {fileID: 0} - target: {fileID: 6926740475113451123, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: m_LocalPosition.z @@ -992,13 +1000,21 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: jumpPow + value: 25 + objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: kickPow value: 150 objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: hasWallrun - value: 1 + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: playerGrav + value: 50 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs index 355cc27..caa5f11 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs @@ -18,6 +18,7 @@ public class dPlayerMovement : NetworkBehaviour private Vector3 moveZ; private Vector3 moveX; private Vector3 driftVel; + private Vector3 lerpY; //Player prefab private GameObject parentObj; @@ -27,9 +28,11 @@ public class dPlayerMovement : NetworkBehaviour //Jump value public int curJumpNum; - private bool jumpPressed; + private bool jumpHeld; bool tempSet = false; float tempTraction = 0.0f; + float jumpTimer = 0.2f; + float curJumpTimer; //Jump physics private float mass = 5.0F; // defines the character mass @@ -49,7 +52,6 @@ public class dPlayerMovement : NetworkBehaviour private RaycastHit groundHit; //Camera Variables - private LayerMask ignoreP; private Vector3 camRotation; public Camera cam; @@ -97,6 +99,8 @@ public class dPlayerMovement : NetworkBehaviour blink = gameObject.GetComponent(); up = this.gameObject.GetComponentInParent().up; + + curJumpTimer = jumpTimer; } void Start() @@ -194,19 +198,22 @@ public class dPlayerMovement : NetworkBehaviour //player vector should be under the circumstances vel = moveX + moveZ; + Jump(); //Gravity Gravity(); - driftVel = Vector3.Lerp(driftVel, vel, pStats.Traction * Time.deltaTime); - //Moving outside basic wasd //Jump Function - Jump(); + //Slide Function Slide(); - + Vector3 moveXZ = new Vector3(vel.x, 0, vel.z); + driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime); + + Vector3 moveY = new Vector3(0,vel.y,0); + lerpY = Vector3.Lerp(lerpY, moveY, 3 * Time.deltaTime); //Move Player - moveController.Move(driftVel); + moveController.Move(driftVel + lerpY); } @@ -259,36 +266,41 @@ public class dPlayerMovement : NetworkBehaviour private void Jump() { //If space/south gamepad button is pressed apply an upwards force to the player - if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding) + if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && !isSliding) { if(wallRun.IsWallRunning()){ - AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 1.3f); - AddImpact(transform.up, pStats.JumpPow); + AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 20f); + vel.y = pStats.JumpPow; } else{ - AddImpact(transform.up, pStats.JumpPow); + vel.y = pStats.JumpPow; } curJumpNum++; - jumpPressed = true; + jumpHeld = true; } lastTimeJumped = Time.time; //If grounded no jumps have been used - if(isGrounded){ + if(isGrounded) curJumpTimer = jumpTimer; + else curJumpTimer -= Time.deltaTime; + + if(jumpHeld) curJumpTimer = 0; + + if(curJumpTimer == jumpTimer){ curJumpNum = 0; } //If space/south face gamepad button isn't being pressed then jump is false - if (Input.GetAxis("Jump") == 0) jumpPressed = false; + if (Input.GetAxis("Jump") == 0) jumpHeld = false; } //PlayerScript public bool GetJumpPressed(){ - return jumpPressed; + return jumpHeld; } public Camera GetPlayerCamera() @@ -356,31 +368,33 @@ public class dPlayerMovement : NetworkBehaviour private void Gravity(){ //Gliding - if(jumpPressed && pStats.HasGlider){ - - vel.y -= (pStats.PlayerGrav-18) * Time.deltaTime; + if(jumpHeld && pStats.HasGlider){ + Debug.Log("x"); + vel.y -= (pStats.PlayerGrav-40) * Time.deltaTime; if(tempSet == false){ tempTraction = pStats.Traction; pStats.Traction = 1.0f; tempSet = true; } } - else if(!jumpPressed && pStats.HasGlider){ - + else if(!jumpHeld && pStats.HasGlider){ + Debug.Log("y"); if(tempSet == true){ pStats.Traction = tempTraction; tempSet = false; } //Normal Gravity - vel.y -= pStats.PlayerGrav * Time.deltaTime; + //if coyoteJump is over fall + if(curJumpTimer <= 0) vel.y -= pStats.PlayerGrav * Time.deltaTime; } //Wallrunning else if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning else{ - vel.y -= pStats.PlayerGrav * Time.deltaTime; + //if coyoteJump is over fall + if(curJumpTimer <= 0) vel.y -= pStats.PlayerGrav * Time.deltaTime; } } @@ -393,7 +407,8 @@ public class dPlayerMovement : NetworkBehaviour // reset values before the ground check isGrounded = false; groundRay = new Ray(moveController.transform.position, Vector3.down); - if (Physics.Raycast(groundRay, out groundHit, moveController.height + groundCheckDistance)) //&& Time.time >= lastTimeJumped + jumpGroundingPreventionTime) // only try to detect ground if it's been a short amount of time since last jump; otherwise we may snap to the ground instantly after we try jumping + + if (Physics.Raycast(groundRay, out groundHit, moveController.height + groundCheckDistance) && !jumpHeld ) //&& Time.time >= lastTimeJumped + jumpGroundingPreventionTime) // only try to detect ground if it's been a short amount of time since last jump; otherwise we may snap to the ground instantly after we try jumping { // Only consider this a valid ground hit if the ground normal goes in the same direction as the character up if (Vector3.Dot(groundHit.normal, transform.up) > 0f) @@ -402,7 +417,7 @@ public class dPlayerMovement : NetworkBehaviour // handle snapping to the ground if (groundHit.distance > moveController.skinWidth) { - moveController.Move(Vector3.down * groundHit.distance); + //moveController.Move(Vector3.down * groundHit.distance); } } } diff --git a/Assets/Scripts/PlayerScripts/PlayerMovement.cs b/Assets/Scripts/PlayerScripts/PlayerMovement.cs index 03189ee..fa144ce 100644 --- a/Assets/Scripts/PlayerScripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerScripts/PlayerMovement.cs @@ -18,6 +18,7 @@ public class PlayerMovement : NetworkBehaviour private Vector3 moveZ; private Vector3 moveX; private Vector3 driftVel; + private Vector3 lerpY; //Player prefab private GameObject parentObj; @@ -27,9 +28,11 @@ public class PlayerMovement : NetworkBehaviour //Jump value public int curJumpNum; - private bool jumpPressed; + private bool jumpHeld; bool tempSet = false; float tempTraction = 0.0f; + float jumpTimer = 0.2f; + float curJumpTimer; //Jump physics private float mass = 5.0F; // defines the character mass @@ -49,7 +52,6 @@ public class PlayerMovement : NetworkBehaviour private RaycastHit groundHit; //Camera Variables - private LayerMask ignoreP; private Vector3 camRotation; public Camera cam; @@ -95,6 +97,8 @@ public class PlayerMovement : NetworkBehaviour //Wallrun wallRun = gameObject.GetComponent(); up = this.gameObject.GetComponentInParent().up; + + curJumpTimer = jumpTimer; } void Start() @@ -174,20 +178,22 @@ public class PlayerMovement : NetworkBehaviour //player vector should be under the circumstances vel = moveX + moveZ; + Jump(); //Gravity Gravity(); - //Adds persisting momentum to player - driftVel = Vector3.Lerp(driftVel, vel, pStats.Traction * Time.deltaTime); - //Moving outside basic wasd //Jump Function - Jump(); + //Slide Function Slide(); - + Vector3 moveXZ = new Vector3(vel.x, 0, vel.z); + driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime); + + Vector3 moveY = new Vector3(0,vel.y,0); + lerpY = Vector3.Lerp(lerpY, moveY, 3 * Time.deltaTime); //Move Player - moveController.Move(driftVel); + moveController.Move(driftVel + lerpY); } //Calculates speed current player needs to be going @@ -236,36 +242,42 @@ public class PlayerMovement : NetworkBehaviour //Jump Function private void Jump() { - //If space is pressed apply an upwards force to the player - if ((Input.GetAxis("Jump") != 0) && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding) + //If space/south gamepad button is pressed apply an upwards force to the player + if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && !isSliding) { if(wallRun.IsWallRunning()){ AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 1.3f); - AddImpact(transform.up, pStats.JumpPow); + vel.y = pStats.JumpPow; } else{ - AddImpact(transform.up, pStats.JumpPow); + vel.y = pStats.JumpPow; } + curJumpNum++; - jumpPressed = true; + jumpHeld = true; } lastTimeJumped = Time.time; //If grounded no jumps have been used - if(isGrounded){ + if(isGrounded) curJumpTimer = jumpTimer; + else curJumpTimer -= Time.deltaTime; + + if(jumpHeld) curJumpTimer = 0; + + if(curJumpTimer == jumpTimer){ curJumpNum = 0; } - //If space isn't being pressed then jump is false - if (Input.GetAxis("Jump") == 0) jumpPressed = false; + //If space/south face gamepad button isn't being pressed then jump is false + if (Input.GetAxis("Jump") == 0) jumpHeld = false; } //PlayerScript public bool GetJumpPressed(){ - return jumpPressed; + return jumpHeld; } public Camera GetPlayerCamera() @@ -342,31 +354,33 @@ public class PlayerMovement : NetworkBehaviour private void Gravity(){ //Gliding - if(jumpPressed && pStats.HasGlider){ - - vel.y -= (pStats.PlayerGrav-18) * Time.deltaTime; + if(jumpHeld && pStats.HasGlider){ + Debug.Log("x"); + vel.y -= (pStats.PlayerGrav-40) * Time.deltaTime; if(tempSet == false){ tempTraction = pStats.Traction; pStats.Traction = 1.0f; tempSet = true; } } - else if(!jumpPressed && pStats.HasGlider){ - + else if(!jumpHeld && pStats.HasGlider){ + Debug.Log("y"); if(tempSet == true){ pStats.Traction = tempTraction; tempSet = false; } //Normal Gravity - vel.y -= pStats.PlayerGrav * Time.deltaTime; + //if coyoteJump is over fall + if(curJumpTimer <= 0) vel.y -= pStats.PlayerGrav * Time.deltaTime; } //Wallrunning else if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning else{ - vel.y -= pStats.PlayerGrav * Time.deltaTime; + //if coyoteJump is over fall + if(curJumpTimer <= 0) vel.y -= pStats.PlayerGrav * Time.deltaTime; } } @@ -379,7 +393,8 @@ public class PlayerMovement : NetworkBehaviour // reset values before the ground check isGrounded = false; groundRay = new Ray(moveController.transform.position, Vector3.down); - if (Physics.Raycast(groundRay, out groundHit, moveController.height + groundCheckDistance)) //&& Time.time >= lastTimeJumped + jumpGroundingPreventionTime) // only try to detect ground if it's been a short amount of time since last jump; otherwise we may snap to the ground instantly after we try jumping + + if (Physics.Raycast(groundRay, out groundHit, moveController.height + groundCheckDistance) && !jumpHeld ) //&& Time.time >= lastTimeJumped + jumpGroundingPreventionTime) // only try to detect ground if it's been a short amount of time since last jump; otherwise we may snap to the ground instantly after we try jumping { // Only consider this a valid ground hit if the ground normal goes in the same direction as the character up if (Vector3.Dot(groundHit.normal, transform.up) > 0f) @@ -388,7 +403,7 @@ public class PlayerMovement : NetworkBehaviour // handle snapping to the ground if (groundHit.distance > moveController.skinWidth) { - moveController.Move(Vector3.down * groundHit.distance); + //moveController.Move(Vector3.down * groundHit.distance); } } } diff --git a/Assets/Scripts/PlayerScripts/PlayerStats.cs b/Assets/Scripts/PlayerScripts/PlayerStats.cs index fdcd55a..db7eee2 100644 --- a/Assets/Scripts/PlayerScripts/PlayerStats.cs +++ b/Assets/Scripts/PlayerScripts/PlayerStats.cs @@ -34,7 +34,7 @@ public class PlayerStats : MonoBehaviour } //Player Jump power - [SerializeField] private float jumpPow = 300.0f; + [SerializeField] private float jumpPow = 25.0f; public float JumpPow{ get{ return jumpPow; } set{ jumpPow = value; } @@ -69,7 +69,7 @@ public class PlayerStats : MonoBehaviour } //Gravity Affecting the player - [SerializeField] private float playerGrav = 20.0f; + [SerializeField] private float playerGrav = 50.0f; public float PlayerGrav{ get{ return playerGrav; } set{ playerGrav = value; } diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 0298d27..43f9fbc 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -10,6 +10,7 @@ TagManager: - HookPoint - Floor - Weather + - GroundCheck layers: - Default - TransparentFX @@ -43,7 +44,6 @@ TagManager: - - - - - m_SortingLayers: - name: UI_Backgrounds uniqueID: 378093239 diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index f476c18..096c149 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -15,25 +15,25 @@ EditorUserSettings: value: 22424703114646680e0b0227036c7b151b180b650d262f3d192c0e27d1e33136e7a923e7ee2e26 flags: 0 RecentlyUsedScenePath-3: - value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26 + value: 22424703114646680e0b0227036c7b151b180b6519016b0515163936efef2776f7e93ffdfe flags: 0 RecentlyUsedScenePath-4: - value: 22424703114646680e0b0227036c7b151b180b6519016b0515163936efef2776f7e93ffdfe + value: 22424703114646680e0b0227036c731f1415016439262f2434 flags: 0 RecentlyUsedScenePath-5: value: 22424703114646680e0b0227036c731f1415016439262f2434 flags: 0 RecentlyUsedScenePath-6: - value: 22424703114646680e0b0227036c731f1415016439262f2434 + value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb flags: 0 RecentlyUsedScenePath-7: - value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb + value: 22424703114646680e0b0227036c7b151b180b652b3a27292f260573f1e33136e7a923e7ee2e26 flags: 0 RecentlyUsedScenePath-8: value: 22424703114646680e0b0227036c7b151b180b652b3a27292f260573f1e33136e7a923e7ee2e26 flags: 0 RecentlyUsedScenePath-9: - value: 22424703114646680e0b0227036c7b151b180b652b3a27292f260573f1e33136e7a923e7ee2e26 + value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26 flags: 0 UnityRemoteCompression: value: 337f73 From c44afd50a8ce74224a4fdbe973d0905b8a3fa4c0 Mon Sep 17 00:00:00 2001 From: Melbyj1125 <60886701+Melbyj1125@users.noreply.github.com> Date: Fri, 10 Dec 2021 06:52:59 -0600 Subject: [PATCH 2/5] Jump has been reworked again but it works now Glide has been fixed again Wallrun has been fixed again player can now short hop --- Assets/Scenes/Demos/MovementScene.unity | 24 +- .../DebugPlayer/DebugItems/dWallRun.cs | 2 - .../DebugPlayer/dPlayerMovement.cs | 275 +++++++++++------- .../PlayerItems/ItemScripts/WallRun.cs | 2 - .../Resources/ItemObjects/Springs.asset | 2 +- .../Resources/ItemObjects/TripleJump.asset | 2 +- .../Scripts/PlayerScripts/PlayerMovement.cs | 234 +++++++++------ Assets/Scripts/PlayerScripts/PlayerStats.cs | 8 +- 8 files changed, 336 insertions(+), 213 deletions(-) diff --git a/Assets/Scenes/Demos/MovementScene.unity b/Assets/Scenes/Demos/MovementScene.unity index 167ef7b..109f4bc 100644 --- a/Assets/Scenes/Demos/MovementScene.unity +++ b/Assets/Scenes/Demos/MovementScene.unity @@ -952,6 +952,14 @@ PrefabInstance: propertyPath: m_Name value: DebugPlayerPrefab objectReference: {fileID: 0} + - target: {fileID: 6743056025486776975, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: fallMultiplier + value: 1.5 + objectReference: {fileID: 0} + - target: {fileID: 6743056025486776975, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: lowJumpMultiplier + value: 0.3 + objectReference: {fileID: 0} - target: {fileID: 6743056025486776975, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: groundCheckHitbox.m_Bits value: 8 @@ -1000,9 +1008,21 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: acc + value: 0.1 + objectReference: {fileID: 0} + - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: maxVel + value: 30 + objectReference: {fileID: 0} + - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: minVel + value: 5 + objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: jumpPow - value: 25 + value: 63 objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: kickPow @@ -1014,7 +1034,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: playerGrav - value: 50 + value: 200 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dWallRun.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dWallRun.cs index 3c849cd..766cc58 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dWallRun.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dWallRun.cs @@ -112,13 +112,11 @@ public class dWallRun : NetworkBehaviour { elapsedTimeSinceWallDetatch = 0; elapsedTimeSinceWallAttach += Time.deltaTime; - playerMovementController.AddPlayerVelocity((Vector3.down * wallGravityDownForce * Time.deltaTime)); } else { elapsedTimeSinceWallAttach = 0; elapsedTimeSinceWallDetatch += Time.deltaTime; - playerMovementController.AddPlayerVelocity((Vector3.down * playerMovementController.pStats.PlayerGrav * Time.deltaTime)); } } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs index caa5f11..618f151 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs @@ -27,14 +27,19 @@ public class dPlayerMovement : NetworkBehaviour private CharacterController moveController; //Jump value - public int curJumpNum; - private bool jumpHeld; + public int curJumpNum; // current Jumps used + private bool jumpHeld; // Is jump being held + float coyJumpTimer = 0.2f; // Default Coyote Jump time + float curCoyJumpTimer; // current Coyote Jump time + public float lowJumpMultiplier; // Short jump multiplier + public float fallMultiplier; // High Jump Multiplier + private float g = 0; // the y velocity + + //Glide Values bool tempSet = false; float tempTraction = 0.0f; - float jumpTimer = 0.2f; - float curJumpTimer; - //Jump physics + //Impact physics private float mass = 5.0F; // defines the character mass private Vector3 impact = Vector3.zero; private float distToGround; @@ -85,22 +90,23 @@ public class dPlayerMovement : NetworkBehaviour void Awake() { - //Initialize Components - moveController = GetComponent(); - rB = GetComponent(); - capCol = GetComponent(); - pStats = GetComponent(); + //Initialize Player Components + moveController = GetComponent(); // Character Controller + rB = GetComponent(); //Rigid Body + capCol = GetComponent(); // Capsule Collider + capCol.enabled = false; parentObj = transform.parent.gameObject; - capCol.enabled = false; - //Wallrun - wallRun = gameObject.GetComponent(); + //Initialize Scripts + pStats = GetComponent(); // PlayerStats + wallRun = GetComponent(); //Wallrun + blink = GetComponent(); //Blink - blink = gameObject.GetComponent(); + //Get parents up direction + up = GetComponentInParent().up; - up = this.gameObject.GetComponentInParent().up; - - curJumpTimer = jumpTimer; + //Coyote Timer Initialization + curCoyJumpTimer = coyJumpTimer; } void Start() @@ -125,40 +131,21 @@ public class dPlayerMovement : NetworkBehaviour // Otherwise we let the server handle moving us //if (!IsLocalPlayer) { return; } - //Controls for camera - if(cam.enabled){ - Rotation(); - } + if(cam.enabled) Rotation(); else Debug.Log("Cam Disabled"); - //Allow Movement when moveController is enabled if(moveController.enabled == true){ - //input controls for movement InputController(); - //if suffiecient impact magnitude is applied then move player + //if suffiecient impact magnitude is applied then move player if (impact.magnitude > 0.2F) moveController.Move(impact * Time.deltaTime); // consumes the impact energy each cycle: impact = Vector3.Lerp(impact, Vector3.zero, 5*Time.deltaTime); } - else{ - - if (RagdollTimer() == 0){ - - firstHit = false; - DisableRagdoll(); - } - - //Gravity without moveController - vel.y -= pStats.PlayerGrav * Time.deltaTime; - rB.AddForce(new Vector3(0,vel.y,0)); - - //Debug.LogWarning("MoveController is either Disabled or wasn't retrieved correctly"); - } //TEMP FOR TESTING RAGDOLL //Right Click to ragdoll the player @@ -189,7 +176,6 @@ public class dPlayerMovement : NetworkBehaviour GroundCheck(); //Keyboard inputs - //Checks if movement keys have been pressed and calculates correct vector moveX = transform.right * Input.GetAxis("Horizontal") * Time.deltaTime * PlayerSpeed(); moveZ = transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * PlayerSpeed(); @@ -197,23 +183,19 @@ public class dPlayerMovement : NetworkBehaviour //Adds vectors based on movement keys and other conditions to check what the //player vector should be under the circumstances vel = moveX + moveZ; - - Jump(); - //Gravity - Gravity(); - - //Moving outside basic wasd - //Jump Function - - //Slide Function - Slide(); Vector3 moveXZ = new Vector3(vel.x, 0, vel.z); driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime); - Vector3 moveY = new Vector3(0,vel.y,0); - lerpY = Vector3.Lerp(lerpY, moveY, 3 * Time.deltaTime); + //Gravity and Jump calculations + UpdateGravity(); + Jump(); + Vector3 moveY = new Vector3(0,g,0); + + //Slide Function + Slide(); + //Move Player - moveController.Move(driftVel + lerpY); + moveController.Move(driftVel + (moveY * Time.deltaTime)); } @@ -252,9 +234,9 @@ public class dPlayerMovement : NetworkBehaviour //Apply Impact for when force needs to be applied without ragdolling public void AddImpact(Vector3 dir, float force) { - //if (!IsLocalPlayer) { return; } + //Normalize direction multiply by force and add it to the impact dir.Normalize(); if (dir.y < 0) dir.y = -dir.y; // reflect down force on the ground impact += dir.normalized * force / mass; @@ -270,83 +252,98 @@ public class dPlayerMovement : NetworkBehaviour { if(wallRun.IsWallRunning()){ AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 20f); - vel.y = pStats.JumpPow; + g = pStats.JumpPow; } + else{ - vel.y = pStats.JumpPow; + g = pStats.JumpPow; } curJumpNum++; jumpHeld = true; } + //Last time Jumped lastTimeJumped = Time.time; - //If grounded no jumps have been used - if(isGrounded) curJumpTimer = jumpTimer; - else curJumpTimer -= Time.deltaTime; + //If grounded no jumps have been used and coyote Timer is refreshed + if(isGrounded && g == 0){ + curCoyJumpTimer = coyJumpTimer; + curJumpNum = 0; + } + //else start the coyote timer + else curCoyJumpTimer -= Time.deltaTime; - if(jumpHeld) curJumpTimer = 0; - - if(curJumpTimer == jumpTimer){ - curJumpNum = 0; - } + //if jump is being held coyote timer is zero + if(jumpHeld) curCoyJumpTimer = 0; //If space/south face gamepad button isn't being pressed then jump is false - if (Input.GetAxis("Jump") == 0) jumpHeld = false; + if (Input.GetAxis("Jump") == 0){ + jumpHeld = false; + } } - - - //PlayerScript + //Get and update PlayerValues for other scripts + //Get jumpHeld public bool GetJumpPressed(){ return jumpHeld; } + //Get player cam public Camera GetPlayerCamera() { return cam; } + //Update Player Velocity public void AddPlayerVelocity(Vector3 additiveVelocity) { vel += additiveVelocity; } + //Set Player Velocity public void SetPlayerVelocity(Vector3 newVelocity) { vel = newVelocity; } + //Reduce player Jump + public void decrementCurrentJumpNumber() + { + curJumpNum--; + } - //Camera and Player Rotation + + //Camera and player rotation private void Rotation() { - //if input is received from Mouse X - if (Input.GetAxis("Mouse X") != 0) - { - transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X")); - } - //if input is received from right analog stick (horizontal) - else if (Input.GetAxis("HorizontalCam") != 0) - { - transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("HorizontalCam")); - } + //If moveController is enabled allow Camera control + if(moveController.enabled){ + //if input is received from Mouse X + if (Input.GetAxis("Mouse X") != 0){ + transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X")); + } - //if input is if input is received from Mouse Y - if (Input.GetAxis("Mouse Y") != 0) - { - camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime; - camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle); - cam.transform.localEulerAngles = camRotation; - } - //if input is received from right analog stick (vertical) - else if (Input.GetAxis("VerticalTurn") != 0) - { - camRotation.x -= Input.GetAxis("VerticalTurn") * sensitivity * Time.deltaTime; - camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle); - cam.transform.localEulerAngles = camRotation; + //if input is received from right analog stick (horizontal) + else if(Input.GetAxis("HorizontalCam") != 0){ + transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("HorizontalCam")); + } + + //if input is if input is received from Mouse Y + if (Input.GetAxis("Mouse Y") != 0) + { + camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime; + camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle); + cam.transform.localEulerAngles = camRotation; + } + + //if input is received from right analog stick (vertical) + else if (Input.GetAxis("VerticalTurn") != 0){ + camRotation.x -= Input.GetAxis("VerticalTurn") * sensitivity * Time.deltaTime; + camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle); + cam.transform.localEulerAngles = camRotation; + } } } @@ -356,7 +353,7 @@ public class dPlayerMovement : NetworkBehaviour //Respawns player if they fall below a certain point private void Respawn() { - if (transform.position.y < -1) + if (transform.position.y < -5) { transform.position = new Vector3(1f, 3f, 1f); } @@ -364,37 +361,71 @@ public class dPlayerMovement : NetworkBehaviour - //Gravity Function for adjusting y-vel due to wallrun/glide/etc - private void Gravity(){ + //Gravity Function for adjusting y-vel due to wallrun/glide/etc + private void UpdateGravity(){ //Gliding - if(jumpHeld && pStats.HasGlider){ - Debug.Log("x"); - vel.y -= (pStats.PlayerGrav-40) * Time.deltaTime; + if(pStats.HasGlider && g < 0 && jumpHeld){ + //Gravity with glider + GravityCalculation(10); + + //Set temp values to put traction back to normal if(tempSet == false){ tempTraction = pStats.Traction; pStats.Traction = 1.0f; tempSet = true; } } - else if(!jumpHeld && pStats.HasGlider){ - Debug.Log("y"); + + //Wallrunning + else if (pStats.HasWallrun) { + //Run wall run script + wallRun.WallRunRoutine(); + + //if wallrunning apply different gravity + if(wallRun.IsWallRunning()){ + GravityCalculation(4); + } + + //Normal gravity if not wallrunning + else{ + GravityCalculation(pStats.PlayerGrav); + } + } + + else{ + + //if temporary values have been set restore them back to the normal values if(tempSet == true){ pStats.Traction = tempTraction; tempSet = false; } - //Normal Gravity - //if coyoteJump is over fall - if(curJumpTimer <= 0) vel.y -= pStats.PlayerGrav * Time.deltaTime; + //Normal gravity + GravityCalculation(pStats.PlayerGrav); + } + } + + //Uses Given gravity to apply a downwards force while allowing coyote Jump and short hops + private void GravityCalculation(float grav){ + //apply slight upwards force for jump smoothing when g < 0 + if(g < 0){ + g += grav * (fallMultiplier - 1) * Time.deltaTime; } - //Wallrunning - else if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning + //apply smaller upwards force if jump is released early when jumping creating a short jump + else if (g > 0 && !Input.GetButton("Jump")){ + g += grav * (lowJumpMultiplier - 1) * Time.deltaTime; + } + //apply gravity if not grounded and coyote timer is less than 0 + if(isGrounded == false && curCoyJumpTimer <= 0){ + g -= grav * Time.deltaTime; + } + + //else don't apply gravity else{ - //if coyoteJump is over fall - if(curJumpTimer <= 0) vel.y -= pStats.PlayerGrav * Time.deltaTime; + g = 0; } } @@ -404,6 +435,7 @@ public class dPlayerMovement : NetworkBehaviour { // Make sure that the ground check distance while already in air is very small, to prevent suddenly snapping to ground float chosenGroundCheckDistance = isGrounded ? (moveController.skinWidth + groundCheckDistance) : groundCheckDistanceInAir; + // reset values before the ground check isGrounded = false; groundRay = new Ray(moveController.transform.position, Vector3.down); @@ -417,7 +449,7 @@ public class dPlayerMovement : NetworkBehaviour // handle snapping to the ground if (groundHit.distance > moveController.skinWidth) { - //moveController.Move(Vector3.down * groundHit.distance); + moveController.Move(Vector3.down * groundHit.distance); } } } @@ -480,6 +512,7 @@ public class dPlayerMovement : NetworkBehaviour pStats.Traction = 0.01f; } + transform.Rotate(Vector3.forward * -sensitivity * Time.deltaTime * Input.GetAxis("Mouse X")); pStats.Traction += .004f; } else{ @@ -487,20 +520,40 @@ public class dPlayerMovement : NetworkBehaviour } //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 nothing is above the object, stop sliding 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); + this.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0); isSliding = false; moveController.height = 2.0f; pStats.Traction = originalTraction; - } else{ Debug.Log("Object above you"); - + } } } + public void CancelMomentum() + { + pStats.CurVel = 0; + vel = Vector3.zero; + moveX = Vector3.zero; + moveZ = Vector3.zero; + moveController.enabled = false; + } + + private IEnumerator RespawnTimer() + { + float duration = 2f; + float normalizedTime = 0; + while (normalizedTime <= 1f) + { + normalizedTime += Time.deltaTime / duration; + yield return null; + } + moveController.enabled = true; + } + } diff --git a/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/WallRun.cs b/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/WallRun.cs index 0a1efe4..f248191 100644 --- a/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/WallRun.cs +++ b/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/WallRun.cs @@ -112,13 +112,11 @@ public class WallRun : NetworkBehaviour { elapsedTimeSinceWallDetatch = 0; elapsedTimeSinceWallAttach += Time.deltaTime; - playerMovementController.AddPlayerVelocity((Vector3.down * wallGravityDownForce * Time.deltaTime)); } else { elapsedTimeSinceWallAttach = 0; elapsedTimeSinceWallDetatch += Time.deltaTime; - playerMovementController.AddPlayerVelocity((Vector3.down * playerMovementController.pStats.PlayerGrav * Time.deltaTime)); } } diff --git a/Assets/Scripts/PlayerScripts/PlayerItems/Resources/ItemObjects/Springs.asset b/Assets/Scripts/PlayerScripts/PlayerItems/Resources/ItemObjects/Springs.asset index e5a2f2e..bce437b 100644 --- a/Assets/Scripts/PlayerScripts/PlayerItems/Resources/ItemObjects/Springs.asset +++ b/Assets/Scripts/PlayerScripts/PlayerItems/Resources/ItemObjects/Springs.asset @@ -19,7 +19,7 @@ MonoBehaviour: minVelM: 0 curVelM: 0 accM: 0 - jumpPowM: 100 + jumpPowM: 10 jumpNumM: 0 tractionM: 0 kickPowM: 0 diff --git a/Assets/Scripts/PlayerScripts/PlayerItems/Resources/ItemObjects/TripleJump.asset b/Assets/Scripts/PlayerScripts/PlayerItems/Resources/ItemObjects/TripleJump.asset index 8c90d61..8adde35 100644 --- a/Assets/Scripts/PlayerScripts/PlayerItems/Resources/ItemObjects/TripleJump.asset +++ b/Assets/Scripts/PlayerScripts/PlayerItems/Resources/ItemObjects/TripleJump.asset @@ -19,7 +19,7 @@ MonoBehaviour: minVelM: 0 curVelM: 0 accM: 0 - jumpPowM: -50 + jumpPowM: -5 jumpNumM: 1 tractionM: 0 kickPowM: 0 diff --git a/Assets/Scripts/PlayerScripts/PlayerMovement.cs b/Assets/Scripts/PlayerScripts/PlayerMovement.cs index fa144ce..74bb5ae 100644 --- a/Assets/Scripts/PlayerScripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerScripts/PlayerMovement.cs @@ -27,18 +27,24 @@ public class PlayerMovement : NetworkBehaviour private CharacterController moveController; //Jump value - public int curJumpNum; - private bool jumpHeld; + public int curJumpNum; // current Jumps used + private bool jumpHeld; // Is jump being held + float coyJumpTimer = 0.2f; // Default Coyote Jump time + float curCoyJumpTimer; // current Coyote Jump time + public float lowJumpMultiplier; // Short jump multiplier + public float fallMultiplier; // High Jump Multiplier + private float g = 0; // the y velocity + + //Glide Values bool tempSet = false; float tempTraction = 0.0f; - float jumpTimer = 0.2f; - float curJumpTimer; - //Jump physics + //Impact physics private float mass = 5.0F; // defines the character mass private Vector3 impact = Vector3.zero; private float distToGround; + //Wallrunning private WallRun wallRun; @@ -80,27 +86,32 @@ public class PlayerMovement : NetworkBehaviour private Vector3 up; private bool qDown; - //Kick Variables + //Blink + private Blink blink; void Awake() { - //Initialize Components - moveController = GetComponent(); - rB = GetComponent(); - capCol = GetComponent(); - pStats = GetComponent(); - parentObj = transform.parent.gameObject; - - - + //Initialize Player Components + moveController = GetComponent(); // Character Controller + rB = GetComponent(); //Rigid Body + capCol = GetComponent(); // Capsule Collider capCol.enabled = false; - //Wallrun - wallRun = gameObject.GetComponent(); - up = this.gameObject.GetComponentInParent().up; + parentObj = transform.parent.gameObject; - curJumpTimer = jumpTimer; + //Initialize Scripts + pStats = GetComponent(); // PlayerStats + wallRun = GetComponent(); //Wallrun + blink = GetComponent(); //Blink + + //Get parents up direction + up = GetComponentInParent().up; + + //Coyote Timer Initialization + curCoyJumpTimer = coyJumpTimer; } + + void Start() { distToGround = GetComponent().bounds.extents.y; @@ -115,6 +126,8 @@ public class PlayerMovement : NetworkBehaviour Cursor.lockState = CursorLockMode.Locked; } + + // Update is called once per frame void FixedUpdate() { @@ -122,46 +135,42 @@ public class PlayerMovement : NetworkBehaviour // Otherwise we let the server handle moving us if (!IsLocalPlayer) { return; } - //Controls for camera - if(cam.enabled){ - Rotation(); - } + if(cam.enabled) Rotation(); else Debug.Log("Cam Disabled"); - //Allow Movement when moveController is enabled if(moveController.enabled == true){ - //input controls for movement InputController(); - //if suffiecient impact magnitude is applied then move player + //if suffiecient impact magnitude is applied then move player if (impact.magnitude > 0.2F) moveController.Move(impact * Time.deltaTime); // consumes the impact energy each cycle: impact = Vector3.Lerp(impact, Vector3.zero, 5*Time.deltaTime); } - else{ - if (RagdollTimer() == 0){ - + //If Character controller is disabled use rigidbody calculations + else{ + //if ragdoll timer is over disable ragdolling + if (RagdollTimer() == 0){ firstHit = false; DisableRagdoll(); } //Gravity without moveController - vel.y -= pStats.PlayerGrav * Time.deltaTime; - rB.AddForce(new Vector3(0,vel.y,0)); - - //Debug.LogWarning("MoveController is either Disabled or wasn't retrieved correctly"); + g -= pStats.PlayerGrav * Time.deltaTime; + rB.AddForce(new Vector3(0,g,0)); } //TEMP FOR TESTING //Checks if player should respawn - Respawn(); + //Respawn(); } + + //Reads inputs and moves player private void InputController() { @@ -169,7 +178,6 @@ public class PlayerMovement : NetworkBehaviour GroundCheck(); //Keyboard inputs - //Checks if movement keys have been pressed and calculates correct vector moveX = transform.right * Input.GetAxis("Horizontal") * Time.deltaTime * PlayerSpeed(); moveZ = transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * PlayerSpeed(); @@ -177,25 +185,23 @@ public class PlayerMovement : NetworkBehaviour //Adds vectors based on movement keys and other conditions to check what the //player vector should be under the circumstances vel = moveX + moveZ; - - Jump(); - //Gravity - Gravity(); - - //Moving outside basic wasd - //Jump Function - - //Slide Function - Slide(); Vector3 moveXZ = new Vector3(vel.x, 0, vel.z); driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime); - Vector3 moveY = new Vector3(0,vel.y,0); - lerpY = Vector3.Lerp(lerpY, moveY, 3 * Time.deltaTime); + //Gravity and Jump calculations + UpdateGravity(); + Jump(); + Vector3 moveY = new Vector3(0,g,0); + + //Slide Function + Slide(); + //Move Player - moveController.Move(driftVel + lerpY); + moveController.Move(driftVel + (moveY * Time.deltaTime)); } + + //Calculates speed current player needs to be going public float PlayerSpeed() { @@ -205,18 +211,21 @@ public class PlayerMovement : NetworkBehaviour pStats.CurVel = 0.0f; return pStats.CurVel; } + //If current speed is below min when pressed set to minimum speed else if (pStats.CurVel < pStats.MinVel) { pStats.CurVel = pStats.MinVel; return pStats.MinVel; } + // while the speed is below max speed slowly increase it else if ((pStats.CurVel >= pStats.MinVel) && (pStats.CurVel < pStats.MaxVel)) { pStats.CurVel += pStats.Acc; return pStats.CurVel; } + //If the players speed is above or equal to max speed set speed to max else { @@ -232,6 +241,7 @@ public class PlayerMovement : NetworkBehaviour { if (!IsLocalPlayer) { return; } + //Normalize direction multiply by force and add it to the impact dir.Normalize(); if (dir.y < 0) dir.y = -dir.y; // reflect down force on the ground impact += dir.normalized * force / mass; @@ -246,75 +256,82 @@ public class PlayerMovement : NetworkBehaviour if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && !isSliding) { if(wallRun.IsWallRunning()){ - AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 1.3f); - vel.y = pStats.JumpPow; + AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 20f); + g = pStats.JumpPow; } + else{ - vel.y = pStats.JumpPow; + g = pStats.JumpPow; } curJumpNum++; jumpHeld = true; } + //Last time Jumped lastTimeJumped = Time.time; - //If grounded no jumps have been used - if(isGrounded) curJumpTimer = jumpTimer; - else curJumpTimer -= Time.deltaTime; + //If grounded no jumps have been used and coyote Timer is refreshed + if(isGrounded){ + curCoyJumpTimer = coyJumpTimer; + curJumpNum = 0; + } + //else start the coyote timer + else curCoyJumpTimer -= Time.deltaTime; - if(jumpHeld) curJumpTimer = 0; - - if(curJumpTimer == jumpTimer){ - curJumpNum = 0; - } + //if jump is being held coyote timer is zero + if(jumpHeld) curCoyJumpTimer = 0; //If space/south face gamepad button isn't being pressed then jump is false - if (Input.GetAxis("Jump") == 0) jumpHeld = false; + if (Input.GetAxis("Jump") == 0){ + jumpHeld = false; + } } - //PlayerScript + //Get and update PlayerValues for other scripts + //Get jumpHeld public bool GetJumpPressed(){ return jumpHeld; } + //Get player cam public Camera GetPlayerCamera() { return cam; } + //Update Player Velocity public void AddPlayerVelocity(Vector3 additiveVelocity) { vel += additiveVelocity; } + //Set Player Velocity public void SetPlayerVelocity(Vector3 newVelocity) { vel = newVelocity; } - - - //Camera and Player Rotation + //Reduce player Jump public void decrementCurrentJumpNumber() { curJumpNum--; } - //Camera + + + //Camera and player rotation private void Rotation() { - Vector3 lastCamPos = new Vector3(0,0,0); - Vector3 rotOffset = transform.localEulerAngles; + //If moveController is enabled allow Camera control if(moveController.enabled){ - - //if input is received from Mouse X if (Input.GetAxis("Mouse X") != 0){ transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X")); } + //if input is received from right analog stick (horizontal) else if(Input.GetAxis("HorizontalCam") != 0){ transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("HorizontalCam")); @@ -327,6 +344,7 @@ public class PlayerMovement : NetworkBehaviour camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle); cam.transform.localEulerAngles = camRotation; } + //if input is received from right analog stick (vertical) else if (Input.GetAxis("VerticalTurn") != 0){ camRotation.x -= Input.GetAxis("VerticalTurn") * sensitivity * Time.deltaTime; @@ -342,7 +360,7 @@ public class PlayerMovement : NetworkBehaviour //Respawns player if they fall below a certain point private void Respawn() { - if (transform.position.y < -1) + if (transform.position.y < -5) { transform.position = new Vector3(1f, 3f, 1f); } @@ -350,37 +368,71 @@ public class PlayerMovement : NetworkBehaviour - //Gravity Function for adjusting y-vel due to wallrun/glide/etc - private void Gravity(){ + //Gravity Function for adjusting y-vel due to wallrun/glide/etc + private void UpdateGravity(){ //Gliding - if(jumpHeld && pStats.HasGlider){ - Debug.Log("x"); - vel.y -= (pStats.PlayerGrav-40) * Time.deltaTime; + if(pStats.HasGlider && g < 0 && jumpHeld){ + //Gravity with glider + GravityCalculation(10); + + //Set temp values to put traction back to normal if(tempSet == false){ tempTraction = pStats.Traction; pStats.Traction = 1.0f; tempSet = true; } } - else if(!jumpHeld && pStats.HasGlider){ - Debug.Log("y"); + + //Wallrunning + else if (pStats.HasWallrun) { + //Run wall run script + wallRun.WallRunRoutine(); + + //if wallrunning apply different gravity + if(wallRun.IsWallRunning()){ + GravityCalculation(4); + } + + //Normal gravity if not wallrunning + else{ + GravityCalculation(pStats.PlayerGrav); + } + } + + else{ + + //if temporary values have been set restore them back to the normal values if(tempSet == true){ pStats.Traction = tempTraction; tempSet = false; } - //Normal Gravity - //if coyoteJump is over fall - if(curJumpTimer <= 0) vel.y -= pStats.PlayerGrav * Time.deltaTime; + //Normal gravity + GravityCalculation(pStats.PlayerGrav); + } + } + + //Uses Given gravity to apply a downwards force while allowing coyote Jump and short hops + private void GravityCalculation(float grav){ + //apply slight upwards force for jump smoothing when g < 0 + if(g < 0){ + g += grav * (fallMultiplier - 1) * Time.deltaTime; } - //Wallrunning - else if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning + //apply smaller upwards force if jump is released early when jumping creating a short jump + else if (g > 0 && !Input.GetButton("Jump")){ + g += grav * (lowJumpMultiplier - 1) * Time.deltaTime; + } + //apply gravity if not grounded and coyote timer is less than 0 + if(isGrounded == false && curCoyJumpTimer <= 0){ + g -= grav * Time.deltaTime; + } + + //else don't apply gravity else{ - //if coyoteJump is over fall - if(curJumpTimer <= 0) vel.y -= pStats.PlayerGrav * Time.deltaTime; + g = 0; } } @@ -390,6 +442,7 @@ public class PlayerMovement : NetworkBehaviour { // Make sure that the ground check distance while already in air is very small, to prevent suddenly snapping to ground float chosenGroundCheckDistance = isGrounded ? (moveController.skinWidth + groundCheckDistance) : groundCheckDistanceInAir; + // reset values before the ground check isGrounded = false; groundRay = new Ray(moveController.transform.position, Vector3.down); @@ -403,7 +456,7 @@ public class PlayerMovement : NetworkBehaviour // handle snapping to the ground if (groundHit.distance > moveController.skinWidth) { - //moveController.Move(Vector3.down * groundHit.distance); + moveController.Move(Vector3.down * groundHit.distance); } } } @@ -455,7 +508,8 @@ public class PlayerMovement : NetworkBehaviour //Slide Function private void Slide(){ - if (Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)){ + //if the q button or the east face button on gamepad is held down + if (Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) { qDown = true; if (isSliding == false){ originalTraction = pStats.Traction; @@ -465,6 +519,7 @@ public class PlayerMovement : NetworkBehaviour pStats.Traction = 0.01f; } + transform.Rotate(Vector3.forward * -sensitivity * Time.deltaTime * Input.GetAxis("Mouse X")); pStats.Traction += .004f; } else{ @@ -472,18 +527,17 @@ public class PlayerMovement : NetworkBehaviour } //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 nothing is above the object, stop sliding 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); + this.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0); 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 db7eee2..8d81d79 100644 --- a/Assets/Scripts/PlayerScripts/PlayerStats.cs +++ b/Assets/Scripts/PlayerScripts/PlayerStats.cs @@ -6,14 +6,14 @@ using UnityEngine.Assertions; public class PlayerStats : MonoBehaviour { //Maximum possible player speed - [SerializeField] private float maxVel = 25.0f; + [SerializeField] private float maxVel = 30.0f; public float MaxVel{ get{ return maxVel; } set{ maxVel = value; } } //Minimum possible player speed - [SerializeField] private float minVel = 2.0f; + [SerializeField] private float minVel = 5.0f; public float MinVel{ get{ return minVel; } set{ minVel = value; } @@ -34,7 +34,7 @@ public class PlayerStats : MonoBehaviour } //Player Jump power - [SerializeField] private float jumpPow = 25.0f; + [SerializeField] private float jumpPow = 63.0f; public float JumpPow{ get{ return jumpPow; } set{ jumpPow = value; } @@ -69,7 +69,7 @@ public class PlayerStats : MonoBehaviour } //Gravity Affecting the player - [SerializeField] private float playerGrav = 50.0f; + [SerializeField] private float playerGrav = 200.0f; public float PlayerGrav{ get{ return playerGrav; } set{ playerGrav = value; } From e91afb02f4c077046d354a0c740ac8d6137913fd Mon Sep 17 00:00:00 2001 From: Melbyj1125 <60886701+Melbyj1125@users.noreply.github.com> Date: Fri, 10 Dec 2021 12:34:13 -0600 Subject: [PATCH 3/5] Bumper has been fixed sort of You need to use 2 colliders one thats a trigger and one thats not and it will work properly --- Assets/Scenes/Demos/MovementScene.unity | 249 +++++++++++++++++- Assets/Scripts/KingAbilities/Bumper.cs | 16 +- .../DebugPlayer/DebugItems/dDash.cs | 6 + .../DebugPlayer/DebugItems/dGrapplingHook.cs | 4 +- .../DebugPlayer/dPlayerMovement.cs | 27 +- .../PlayerItems/ItemScripts/GrapplingHook.cs | 2 +- 6 files changed, 274 insertions(+), 30 deletions(-) diff --git a/Assets/Scenes/Demos/MovementScene.unity b/Assets/Scenes/Demos/MovementScene.unity index 109f4bc..e0ccd6a 100644 --- a/Assets/Scenes/Demos/MovementScene.unity +++ b/Assets/Scenes/Demos/MovementScene.unity @@ -929,6 +929,148 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1181153597 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1181153602} + - component: {fileID: 1181153601} + - component: {fileID: 1181153600} + - component: {fileID: 1181153599} + - component: {fileID: 1181153598} + - component: {fileID: 1181153604} + - component: {fileID: 1181153603} + m_Layer: 0 + m_Name: Bumper + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1181153598 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 204dc1e4ca638924caabaa45df29d9d1, type: 3} + m_Name: + m_EditorClassIdentifier: + bumpPower: 20 +--- !u!136 &1181153599 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.49 + m_Height: 0.1 + m_Direction: 1 + m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697} +--- !u!23 &1181153600 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1181153601 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1181153602 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 2.5, y: 1, z: 41.95} + m_LocalScale: {x: 5, y: 1, z: 5} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!136 &1181153603 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + m_Radius: 0.58 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697} +--- !u!54 &1181153604 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1181153597} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_UseGravity: 1 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 0 + m_CollisionDetection: 0 --- !u!1001 &1212970163 PrefabInstance: m_ObjectHideFlags: 0 @@ -952,6 +1094,10 @@ PrefabInstance: propertyPath: m_Name value: DebugPlayerPrefab objectReference: {fileID: 0} + - target: {fileID: 5784126162129930074, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} + propertyPath: dashItem + value: + objectReference: {fileID: 11400000, guid: 4399d7276b3edf446ac51c5145539a5e, type: 2} - target: {fileID: 6743056025486776975, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: fallMultiplier value: 1.5 @@ -1010,19 +1156,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: acc - value: 0.1 + value: 0.01 objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: maxVel - value: 30 + value: 40 objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: minVel - value: 5 + value: 15 objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: jumpPow - value: 63 + value: 60 objectReference: {fileID: 0} - target: {fileID: 8100520363622627413, guid: 362ca97b75c291a47ab81d628a81f440, type: 3} propertyPath: kickPow @@ -1228,6 +1374,101 @@ Transform: m_Father: {fileID: 1493944131} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1405946429 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1405946433} + - component: {fileID: 1405946432} + - component: {fileID: 1405946431} + - component: {fileID: 1405946430} + m_Layer: 0 + m_Name: Sphere + m_TagString: HookPoint + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!135 &1405946430 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405946429} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &1405946431 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405946429} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1405946432 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405946429} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1405946433 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405946429} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -1.5, y: 14.2, z: 10.3} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1493944130 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/KingAbilities/Bumper.cs b/Assets/Scripts/KingAbilities/Bumper.cs index 4e7002e..d1a82a0 100644 --- a/Assets/Scripts/KingAbilities/Bumper.cs +++ b/Assets/Scripts/KingAbilities/Bumper.cs @@ -4,15 +4,17 @@ using UnityEngine; public class Bumper : MonoBehaviour { + public float bumpPower = 80; + // Is called whenever something collides with the bumper - void OnTriggerEnter(Collider other) { - Debug.Log("Bump!"); - if (other.tag == "Player") {//Checks if the other object is the player - float DirBumpX = other.GetComponent().vel.x * -1;//Inverts the Player Velocity x - float DirBumpZ = other.GetComponent().vel.z * -1;//Inverts the Player Velocity y - Vector3 DirBump = new Vector3(DirBumpX, .01f, DirBumpZ);//Creates a direction to launch the player + void OnTriggerEnter(Collider objectHit) { + if (objectHit.tag == "Player") {//Checks if the other object is the player + dPlayerMovement playerMovement = objectHit.GetComponent(); + float DirBumpX = playerMovement.vel.x * -1;//Inverts the Player Velocity x + float DirBumpZ = playerMovement.vel.z * -1;//Inverts the Player Velocity y + Vector3 DirBump = new Vector3(DirBumpX, .1f, DirBumpZ);//Creates a direction to launch the player DirBump = Vector3.Normalize(DirBump);//Normalizes the vector to be used as a bump direction - other.GetComponent().GetHit(DirBump, 50); //Launches tthe player directly away from the bumper + playerMovement.GetHit(DirBump, bumpPower); //Launches tthe player directly away from the bumper } } } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dDash.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dDash.cs index a645ffc..43f45f4 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dDash.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dDash.cs @@ -16,13 +16,19 @@ public class dDash : NetworkBehaviour{ float dashSpeed = 12; CharacterController characterController; + dPlayerMovement pMove; void Start(){ characterController = this.gameObject.GetComponent(); + pMove = GetComponent(); } //UPDATE CHECK FOR MOVEMENT ONLY WHEN DASHING void FixedUpdate(){ + if(pMove.pStats.HasDash) Dash(); + } + + void Dash(){ //if (!IsLocalPlayer) { return; } if(characterController.enabled == true){ if (Input.GetKeyDown(KeyCode.E) && isOnCoolDown == false) diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs index daecd19..1591fd8 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dGrapplingHook.cs @@ -84,9 +84,9 @@ public class dGrapplingHook : NetworkBehaviour if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength) { //Impact Based - playerMovement.AddImpact((hookPoint.transform.position - gameObject.transform.position), pStats.PlayerGrav); + //playerMovement.AddImpact((hookPoint.transform.position - gameObject.transform.position), pStats.PlayerGrav*2); //Character controller move? - //movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * ropeLength*Time.deltaTime); + movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * ropeLength * 10 *Time.deltaTime); //Lerp? or another smoother way? Better physics? Wait until refinement to deal with } } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs index 618f151..fb4f9cc 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/dPlayerMovement.cs @@ -29,7 +29,7 @@ public class dPlayerMovement : NetworkBehaviour //Jump value public int curJumpNum; // current Jumps used private bool jumpHeld; // Is jump being held - float coyJumpTimer = 0.2f; // Default Coyote Jump time + float coyJumpTimer = 0.1f; // Default Coyote Jump time float curCoyJumpTimer; // current Coyote Jump time public float lowJumpMultiplier; // Short jump multiplier public float fallMultiplier; // High Jump Multiplier @@ -147,23 +147,18 @@ public class dPlayerMovement : NetworkBehaviour impact = Vector3.Lerp(impact, Vector3.zero, 5*Time.deltaTime); } - //TEMP FOR TESTING RAGDOLL - //Right Click to ragdoll the player - // if (Input.GetMouseButton(1) && heldDown == false){ - // getHit(new Vector3(vel.x, 0, vel.z), 30); - // heldDown = true; - // } - // if(!Input.GetMouseButton(1)){ - // heldDown = false; - // } + //If Character controller is disabled use rigidbody calculations + else{ + //if ragdoll timer is over disable ragdolling + if (RagdollTimer() == 0){ + firstHit = false; + DisableRagdoll(); + } - if(pStats.HasBlink == true){ - blink.BlinkMove(); + //Gravity without moveController + g -= pStats.PlayerGrav * Time.deltaTime; + rB.AddForce(new Vector3(0,g,0)); } - - //TEMP FOR TESTING - //Checks if player should respawn - //Respawn(); } diff --git a/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/GrapplingHook.cs b/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/GrapplingHook.cs index f8302e8..7282046 100644 --- a/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/GrapplingHook.cs +++ b/Assets/Scripts/PlayerScripts/PlayerItems/ItemScripts/GrapplingHook.cs @@ -32,7 +32,7 @@ public class GrapplingHook : NetworkBehaviour // Update is called once per frame void Update() { - //if (!IsLocalPlayer) { return; } + if (!IsLocalPlayer) { return; } if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit { From 7712e7ef4ac559fcc321b60e5036f1c5745db2e5 Mon Sep 17 00:00:00 2001 From: Melbyj1125 <60886701+Melbyj1125@users.noreply.github.com> Date: Fri, 10 Dec 2021 12:46:09 -0600 Subject: [PATCH 4/5] small modification --- Assets/Scenes/Demos/MovementScene.unity | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Scenes/Demos/MovementScene.unity b/Assets/Scenes/Demos/MovementScene.unity index e0ccd6a..2a01702 100644 --- a/Assets/Scenes/Demos/MovementScene.unity +++ b/Assets/Scenes/Demos/MovementScene.unity @@ -1066,8 +1066,8 @@ Rigidbody: m_Mass: 1 m_Drag: 0 m_AngularDrag: 0.05 - m_UseGravity: 1 - m_IsKinematic: 0 + m_UseGravity: 0 + m_IsKinematic: 1 m_Interpolate: 0 m_Constraints: 0 m_CollisionDetection: 0 From 1f5c7bce0d3382f0a107aea776ff5fcf516358d3 Mon Sep 17 00:00:00 2001 From: Melbyj1125 <60886701+Melbyj1125@users.noreply.github.com> Date: Fri, 10 Dec 2021 13:09:08 -0600 Subject: [PATCH 5/5] slight bumper adjustment --- Assets/Scripts/KingAbilities/Bumper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/KingAbilities/Bumper.cs b/Assets/Scripts/KingAbilities/Bumper.cs index d1a82a0..d6916ab 100644 --- a/Assets/Scripts/KingAbilities/Bumper.cs +++ b/Assets/Scripts/KingAbilities/Bumper.cs @@ -4,7 +4,7 @@ using UnityEngine; public class Bumper : MonoBehaviour { - public float bumpPower = 80; + public float bumpPower = 30; // Is called whenever something collides with the bumper void OnTriggerEnter(Collider objectHit) {