input system
This commit is contained in:
1 parent
548ffac255
commit
50bc30f292
9 files changed
+287
-21
No files matched your search
@@ -0,0 +1,156 @@
|
||||
{
|
||||
"name": "ShipControls",
|
||||
"maps": [
|
||||
{
|
||||
"name": "Ship",
|
||||
"id": "f52df5ad-4b20-4a0e-a4c8-bbf76c26b2c5",
|
||||
"actions": [
|
||||
{
|
||||
"name": "accelerate",
|
||||
"type": "Value",
|
||||
"id": "3d5d2223-bd99-4486-a95d-cefe220e0257",
|
||||
"expectedControlType": "Axis",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "decelerate",
|
||||
"type": "Value",
|
||||
"id": "a27ee77d-59bd-4935-9a7b-961c2da0faf7",
|
||||
"expectedControlType": "Axis",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "strafe",
|
||||
"type": "Value",
|
||||
"id": "d8d4baa2-2812-45af-99f6-eab49bef6b61",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "look",
|
||||
"type": "Value",
|
||||
"id": "f705d9c6-7be0-40e0-95ba-990e6892d4dc",
|
||||
"expectedControlType": "Axis",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "respawn",
|
||||
"type": "Button",
|
||||
"id": "2ced6ae8-aba2-4cd7-882e-6e6473308812",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "quit",
|
||||
"type": "Button",
|
||||
"id": "cea65125-c42e-40e9-bc97-966522e16691",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "",
|
||||
"id": "5e57f603-6e0e-4288-a67e-57c8a8068092",
|
||||
"path": "<Mouse>/leftButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "accelerate",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "f1ab715c-3909-449b-a5b9-0abc49bf8008",
|
||||
"path": "<Gamepad>/rightTrigger",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "accelerate",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "43eea80c-a658-4eee-b6be-2f0124f2785d",
|
||||
"path": "<Mouse>/rightButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "decelerate",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "72aff4e4-d43a-4865-8ce5-42a26fb8270d",
|
||||
"path": "<Gamepad>/leftTrigger",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "decelerate",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "d8bfc5bc-3673-4825-874c-c42f24765ce6",
|
||||
"path": "<Keyboard>/space",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "respawn",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "ff02b06d-2805-46a1-9834-1d3be43bcea3",
|
||||
"path": "<Keyboard>/f10",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "quit",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "6eca2679-7a64-4e8e-ade3-9ad4d7eafa82",
|
||||
"path": "<Gamepad>/leftStick",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "strafe",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "0cf09bea-ed32-4103-b41e-9d502060b36f",
|
||||
"path": "",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "strafe",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"controlSchemes": []
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f7b6d79e6b54ecee85d2214b5375aa5
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||
generateWrapperCode: 0
|
||||
wrapperCodePath:
|
||||
wrapperClassName:
|
||||
wrapperCodeNamespace:
|
||||
@@ -21,6 +21,8 @@ public class ShipControls : MonoBehaviour {
|
||||
// Camera Controls
|
||||
float mouseSenseY = 1.0f;
|
||||
float mouseSenseX = 1.0f;
|
||||
float gamepadSenseY = 2.0f;
|
||||
float gamepadSenseX = 2.0f;
|
||||
float camPitch;
|
||||
float camYaw;
|
||||
|
||||
@@ -116,7 +118,8 @@ public class ShipControls : MonoBehaviour {
|
||||
}
|
||||
|
||||
void processInput() {
|
||||
updateCamera();
|
||||
updateCameraMouse();
|
||||
updateCameraGamepad();
|
||||
|
||||
// don't just spam respawn
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
@@ -145,12 +148,18 @@ public class ShipControls : MonoBehaviour {
|
||||
|
||||
}
|
||||
|
||||
void updateCamera() {
|
||||
void updateCameraMouse() {
|
||||
camPitch -= mouseSenseY * Input.GetAxis("Mouse Y");
|
||||
camYaw += mouseSenseX * Input.GetAxis("Mouse X");
|
||||
aim.transform.eulerAngles = new Vector3(camPitch, camYaw, 0.0f);
|
||||
}
|
||||
|
||||
void updateCameraGamepad() {
|
||||
camPitch -= mouseSenseY * Input.GetAxis("Vertical");
|
||||
camYaw += mouseSenseX * Input.GetAxis("Horizontal");
|
||||
// aim.transform.eulerAngles = new Vector3(camPitch, camYaw, 0.0f);
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected() {
|
||||
if (Application.isPlaying == false)
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ShipInput : MonoBehaviour {
|
||||
public InputAction accelerate;
|
||||
public InputAction decelerate;
|
||||
public InputAction look;
|
||||
public InputAction respawn;
|
||||
public InputAction quit;
|
||||
|
||||
void Start() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3ff4f0cf19b24618b198416fbfe90f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user