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