From a55788727572a40c83f0c2f7884ba4aff4a60bff Mon Sep 17 00:00:00 2001 From: Gregory Campbell Date: Sun, 5 Jan 2020 15:57:18 -0500 Subject: [PATCH 1/2] Implemented a universal input for PS4 and KBM as well as fixing a few movement bugs --- Assets/Scenes/Test Scene.unity | 4 +- Assets/Scripts/PlayerController.cs | 25 +++--- ProjectSettings/InputManager.asset | 122 ++++++++++++++++------------- 3 files changed, 84 insertions(+), 67 deletions(-) diff --git a/Assets/Scenes/Test Scene.unity b/Assets/Scenes/Test Scene.unity index 9501240..885a894 100644 --- a/Assets/Scenes/Test Scene.unity +++ b/Assets/Scenes/Test Scene.unity @@ -366,8 +366,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 203887784} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 200, y: -0.5, z: 6} - m_LocalScale: {x: 50, y: 0.5, z: 50} + m_LocalPosition: {x: 215, y: -0.5, z: 6} + m_LocalScale: {x: 75, y: 0.5, z: 75} m_Children: [] m_Father: {fileID: 833538478} m_RootOrder: 2 diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 7b40d04..83bcc38 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -93,15 +93,15 @@ public class PlayerController : MonoBehaviour if(maxSpeed > maxSpeedStore) { - maxSpeed -= acceleration/10; + maxSpeed -= acceleration/5; } - if(maxSpeed < maxSpeedStore && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftControl)) + if(maxSpeed < maxSpeedStore && !Input.GetButton("Walk") && !Input.GetButton("Crouch")) { maxSpeed += acceleration; } - if(Input.GetKey(KeyCode.LeftShift)) + if(Input.GetButton("Walk")) { if(maxSpeed > maxSpeedStore/2) { @@ -109,21 +109,21 @@ public class PlayerController : MonoBehaviour } } - if(Input.GetKey(KeyCode.LeftControl)) + if(Input.GetButton("Crouch")) { characterController.height /= 2; capsule.height /= 2; transform.localScale = new Vector3(transform.localScale.x, transformHeight/2, transform.localScale.z); - if(Input.GetKeyDown(KeyCode.LeftControl)) + if(Input.GetButtonDown("Crouch")) { - if((Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0)) + if((Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)) { - sliding = false; - } else { sliding = true; slideTime = Time.time; + } else { + sliding = false; } } @@ -160,7 +160,7 @@ public class PlayerController : MonoBehaviour } else { slideTime = Time.time; - if(Input.GetKey(KeyCode.LeftControl)) + if(Input.GetButton("Crouch")) { characterController.height /= 2; @@ -177,13 +177,14 @@ public class PlayerController : MonoBehaviour } //Might want to change move direction value to make triggering this speed up effect easier/harder - if(diving && moveDirection.y > 0.75 && Input.GetKeyDown(KeyCode.LeftControl)) + if(diving && moveDirection.y > 0.75 && Input.GetButtonDown("Crouch")) { dive++; if(dive == 1){ maxSpeed += 10; } - + sliding = true; + slideTime = Time.time; } } @@ -230,7 +231,7 @@ public class PlayerController : MonoBehaviour velocity.x += moveDirection.x; velocity.z += moveDirection.z; - if(Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0){ + if((Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0) || Input.GetButton("Stop")){ //Remove or "lower" friction to add an 'ice' effect velocity.x = Mathf.SmoothDamp(velocity.x, 0.0f, ref xVelocity, friction); diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index 788627b..362ea6c 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -38,13 +38,13 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Fire1 + m_Name: Crouch descriptiveName: descriptiveNegativeName: negativeButton: positiveButton: left ctrl altNegativeButton: - altPositiveButton: mouse 0 + altPositiveButton: gravity: 1000 dead: 0.001 sensitivity: 1000 @@ -54,29 +54,29 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Fire2 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: left alt - altNegativeButton: - altPositiveButton: mouse 1 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire3 + m_Name: Walk descriptiveName: descriptiveNegativeName: negativeButton: positiveButton: left shift altNegativeButton: - altPositiveButton: mouse 2 + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Stop + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: mouse 1 + altNegativeButton: + altPositiveButton: gravity: 1000 dead: 0.001 sensitivity: 1000 @@ -182,11 +182,11 @@ InputManager: axis: 1 joyNum: 0 - serializedVersion: 3 - m_Name: Fire1 + m_Name: Crouch descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: joystick button 0 + positiveButton: joystick button 7 altNegativeButton: altPositiveButton: gravity: 1000 @@ -198,23 +198,7 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Fire2 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 1 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire3 + m_Name: Walk descriptiveName: descriptiveNegativeName: negativeButton: @@ -230,11 +214,11 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Jump + m_Name: Stop descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: joystick button 3 + positiveButton: joystick button 6 altNegativeButton: altPositiveButton: gravity: 1000 @@ -246,13 +230,13 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Submit + m_Name: Jump descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: return + positiveButton: joystick button 1 altNegativeButton: - altPositiveButton: joystick button 0 + altPositiveButton: gravity: 1000 dead: 0.001 sensitivity: 1000 @@ -262,29 +246,61 @@ InputManager: axis: 0 joyNum: 0 - serializedVersion: 3 - m_Name: Submit + m_Name: Mouse X descriptiveName: descriptiveNegativeName: negativeButton: - positiveButton: enter + positiveButton: altNegativeButton: - altPositiveButton: space + altPositiveButton: gravity: 1000 - dead: 0.001 - sensitivity: 1000 + dead: 0.25 + sensitivity: 0.1 snap: 0 invert: 0 - type: 0 - axis: 0 + type: 2 + axis: 2 joyNum: 0 - serializedVersion: 3 - m_Name: Cancel + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.25 + sensitivity: 0.1 + snap: 0 + invert: 1 + type: 2 + axis: 3 + joyNum: 0 + - serializedVersion: 3 + m_Name: Pause descriptiveName: descriptiveNegativeName: negativeButton: positiveButton: escape altNegativeButton: - altPositiveButton: joystick button 1 + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Pause + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 9 + altNegativeButton: + altPositiveButton: gravity: 1000 dead: 0.001 sensitivity: 1000 From 93307022e4a774fa1f51d25615f71021afbd4286 Mon Sep 17 00:00:00 2001 From: Gregory Campbell Date: Sun, 5 Jan 2020 17:02:15 -0500 Subject: [PATCH 2/2] PS4 controller input working (but camera doesn't work without steam) --- ProjectSettings/EditorBuildSettings.asset | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index ebd098e..7545818 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -8,4 +8,6 @@ EditorBuildSettings: - enabled: 1 path: Assets/Scenes/Test Scene.unity guid: 9fc0d4010bbf28b4594072e72b8655ab - m_configObjects: {} + m_configObjects: + com.unity.input.settings: {fileID: 11400000, guid: 5dbe934aa009ccc4591ccf96f49a3d48, + type: 2}