input system

This commit is contained in:
ntr committed 2023-07-10 21:05:54 +10:00
1 parent 548ffac255
commit 50bc30f292
9 files changed
+287 -21

No files matched your search

+156
View File
@@ -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:
+11 -2
View File
@@ -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;
+13
View File
@@ -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() {
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d3ff4f0cf19b24618b198416fbfe90f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+1
View File
@@ -6,6 +6,7 @@
"com.unity.ide.rider": "3.0.24",
"com.unity.ide.visualstudio": "2.0.18",
"com.unity.ide.vscode": "1.2.5",
"com.unity.inputsystem": "1.6.1",
"com.unity.render-pipelines.universal": "14.0.8",
"com.unity.test-framework": "1.1.33",
"com.unity.textmeshpro": "3.0.6",
+9
View File
@@ -78,6 +78,15 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.inputsystem": {
"version": "1.6.1",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.uielements": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.mathematics": {
"version": "1.2.6",
"depth": 1,
+70 -19
View File
@@ -3,7 +3,7 @@
--- !u!129 &1
PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 23
serializedVersion: 26
productGUID: e8795e705a844cb40a2e7df721e08855
AndroidProfiler: 0
AndroidFilterTouchesWhenObscured: 0
@@ -48,14 +48,15 @@ PlayerSettings:
defaultScreenHeightWeb: 600
m_StereoRenderingPath: 0
m_ActiveColorSpace: 0
m_SpriteBatchVertexThreshold: 300
m_MTRendering: 1
mipStripping: 0
numberOfMipsStripped: 0
numberOfMipsStrippedPerMipmapLimitGroup: {}
m_StackTraceTypes: 010000000100000001000000010000000100000001000000
iosShowActivityIndicatorOnLoading: -1
androidShowActivityIndicatorOnLoading: -1
iosUseCustomAppBackgroundBehavior: 0
iosAllowHTTPDownload: 1
allowedAutorotateToPortrait: 1
allowedAutorotateToPortraitUpsideDown: 1
allowedAutorotateToLandscapeRight: 1
@@ -119,8 +120,11 @@ PlayerSettings:
switchNVNShaderPoolsGranularity: 33554432
switchNVNDefaultPoolsGranularity: 16777216
switchNVNOtherPoolsGranularity: 16777216
switchGpuScratchPoolGranularity: 2097152
switchAllowGpuScratchShrinking: 0
switchNVNMaxPublicTextureIDCount: 0
switchNVNMaxPublicSamplerIDCount: 0
switchNVNGraphicsFirmwareMemory: 32
stadiaPresentMode: 0
stadiaTargetFramerate: 0
vulkanNumSwapchainBuffers: 3
@@ -128,12 +132,7 @@ PlayerSettings:
vulkanEnablePreTransform: 1
vulkanEnableLateAcquireNextImage: 0
vulkanEnableCommandBufferRecycling: 1
m_SupportedAspectRatios:
4:3: 1
5:4: 1
16:10: 1
16:9: 1
Others: 1
loadStoreDebugModeEnabled: 0
bundleVersion: 0.1
preloadedAssets: []
metroInputSource: 0
@@ -145,15 +144,18 @@ PlayerSettings:
enable360StereoCapture: 0
isWsaHolographicRemotingEnabled: 0
enableFrameTimingStats: 0
enableOpenGLProfilerGPURecorders: 1
useHDRDisplay: 0
D3DHDRBitDepth: 0
hdrBitDepth: 0
m_ColorGamuts: 00000000
targetPixelDensity: 30
resolutionScalingMode: 0
resetResolutionOnWindowResize: 0
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
applicationIdentifier: {}
buildNumber:
Bratwurst: 0
Standalone: 0
iPhone: 0
tvOS: 0
@@ -172,12 +174,15 @@ PlayerSettings:
APKExpansionFiles: 0
keepLoadedShadersAlive: 0
StripUnusedMeshComponents: 1
strictShaderVariantMatching: 0
VertexChannelCompressionMask: 4054
iPhoneSdkVersion: 988
iOSTargetOSVersionString: 11.0
iOSTargetOSVersionString: 12.0
tvOSSdkVersion: 0
tvOSRequireExtendedGameController: 0
tvOSTargetOSVersionString: 11.0
tvOSTargetOSVersionString: 12.0
bratwurstSdkVersion: 0
bratwurstTargetOSVersionString: 16.4
uIPrerenderedIcon: 0
uIRequiresPersistentWiFi: 0
uIRequiresFullScreen: 1
@@ -225,8 +230,10 @@ PlayerSettings:
appleDeveloperTeamID:
iOSManualSigningProvisioningProfileID:
tvOSManualSigningProvisioningProfileID:
bratwurstManualSigningProvisioningProfileID:
iOSManualSigningProvisioningProfileType: 0
tvOSManualSigningProvisioningProfileType: 0
bratwurstManualSigningProvisioningProfileType: 0
appleEnableAutomaticSigning: 0
iOSRequireARKit: 0
iOSAutomaticallyDetectAndAddCapabilities: 1
@@ -241,6 +248,7 @@ PlayerSettings:
useCustomLauncherGradleManifest: 0
useCustomBaseGradleTemplate: 0
useCustomGradlePropertiesTemplate: 0
useCustomGradleSettingsTemplate: 0
useCustomProguardFile: 0
AndroidTargetArchitectures: 1
AndroidTargetDevices: 0
@@ -248,6 +256,7 @@ PlayerSettings:
androidSplashScreen: {fileID: 0}
AndroidKeystoreName:
AndroidKeyaliasName:
AndroidEnableArmv9SecurityFeatures: 0
AndroidBuildApkPerCpuArchitecture: 0
AndroidTVCompatibility: 0
AndroidIsGame: 1
@@ -261,7 +270,6 @@ PlayerSettings:
banner: {fileID: 0}
androidGamepadSupportLevel: 0
chromeosInputEmulation: 1
AndroidMinifyWithR8: 0
AndroidMinifyRelease: 0
AndroidMinifyDebug: 0
AndroidValidateAppBundleSize: 1
@@ -376,6 +384,7 @@ PlayerSettings:
- m_BuildTarget: WebGL
m_StaticBatching: 0
m_DynamicBatching: 0
m_BuildTargetShaderSettings: []
m_BuildTargetGraphicsJobs:
- m_BuildTarget: MacStandaloneSupport
m_GraphicsJobs: 0
@@ -427,6 +436,8 @@ PlayerSettings:
m_Devices:
- Oculus
- OpenVR
m_DefaultShaderChunkSizeInMB: 16
m_DefaultShaderChunkCount: 0
openGLRequireES31: 0
openGLRequireES31AEP: 0
openGLRequireES32: 0
@@ -436,6 +447,13 @@ PlayerSettings:
iPhone: 1
tvOS: 1
m_BuildTargetGroupLightmapEncodingQuality:
- m_BuildTarget: Android
m_EncodingQuality: 1
- m_BuildTarget: iPhone
m_EncodingQuality: 1
- m_BuildTarget: tvOS
m_EncodingQuality: 1
m_BuildTargetGroupHDRCubemapEncodingQuality:
- m_BuildTarget: Android
m_EncodingQuality: 1
- m_BuildTarget: iPhone
@@ -443,6 +461,7 @@ PlayerSettings:
- m_BuildTarget: tvOS
m_EncodingQuality: 1
m_BuildTargetGroupLightmapSettings: []
m_BuildTargetGroupLoadStoreDebugModeSettings: []
m_BuildTargetNormalMapEncoding:
- m_BuildTarget: Android
m_Encoding: 1
@@ -463,6 +482,7 @@ PlayerSettings:
locationUsageDescription:
microphoneUsageDescription:
bluetoothUsageDescription:
macOSTargetOSVersion: 10.13.0
switchNMETAOverride:
switchNetLibKey:
switchSocketMemoryPoolSize: 6144
@@ -474,6 +494,7 @@ PlayerSettings:
switchLTOSetting: 0
switchApplicationID: 0x01004b9000490000
switchNSODependencies:
switchCompilerFlags:
switchTitleNames_0:
switchTitleNames_1:
switchTitleNames_2:
@@ -547,7 +568,6 @@ PlayerSettings:
switchReleaseVersion: 0
switchDisplayVersion: 1.0.0
switchStartupUserAccount: 0
switchTouchScreenUsage: 0
switchSupportedLanguagesMask: 0
switchLogoType: 0
switchApplicationErrorCodeCategory:
@@ -589,6 +609,7 @@ PlayerSettings:
switchNativeFsCacheSize: 32
switchIsHoldTypeHorizontal: 0
switchSupportedNpadCount: 8
switchEnableTouchScreen: 1
switchSocketConfigEnabled: 0
switchTcpInitialSendBufferSize: 32
switchTcpInitialReceiveBufferSize: 64
@@ -601,6 +622,7 @@ PlayerSettings:
switchNetworkInterfaceManagerInitializeEnabled: 1
switchPlayerConnectionEnabled: 1
switchUseNewStyleFilepaths: 0
switchUseLegacyFmodPriorities: 0
switchUseMicroSleepForYield: 1
switchEnableRamDiskSupport: 0
switchMicroSleepForYieldTime: 25
@@ -675,6 +697,7 @@ PlayerSettings:
ps4videoRecordingFeaturesUsed: 0
ps4contentSearchFeaturesUsed: 0
ps4CompatibilityPS5: 0
ps4AllowPS5Detection: 0
ps4GPU800MHz: 1
ps4attribEyeToEyeDistanceSettingVR: 0
ps4IncludedModules: []
@@ -687,6 +710,7 @@ PlayerSettings:
webGLMemorySize: 16
webGLExceptionSupport: 1
webGLNameFilesAsHashes: 0
webGLShowDiagnostics: 0
webGLDataCaching: 1
webGLDebugSymbols: 0
webGLEmscriptenArgs:
@@ -699,21 +723,41 @@ PlayerSettings:
webGLLinkerTarget: 1
webGLThreadsSupport: 0
webGLDecompressionFallback: 0
webGLInitialMemorySize: 32
webGLMaximumMemorySize: 2048
webGLMemoryGrowthMode: 2
webGLMemoryLinearGrowthStep: 16
webGLMemoryGeometricGrowthStep: 0.2
webGLMemoryGeometricGrowthCap: 96
webGLPowerPreference: 2
scriptingDefineSymbols: {}
additionalCompilerArguments: {}
platformArchitecture: {}
scriptingBackend: {}
il2cppCompilerConfiguration: {}
managedStrippingLevel: {}
il2cppCodeGeneration: {}
managedStrippingLevel:
Bratwurst: 1
EmbeddedLinux: 1
GameCoreScarlett: 1
GameCoreXboxOne: 1
Nintendo Switch: 1
PS4: 1
PS5: 1
QNX: 1
Stadia: 1
WebGL: 1
Windows Store Apps: 1
XboxOne: 1
iPhone: 1
tvOS: 1
incrementalIl2cppBuild: {}
suppressCommonWarnings: 1
allowUnsafeCode: 0
useDeterministicCompilation: 1
enableRoslynAnalyzers: 1
additionalIl2CppArgs:
scriptingRuntimeVersion: 1
gcIncremental: 1
assemblyVersionValidation: 1
gcWBarrierValidation: 0
apiCompatibilityLevelPerPlatform: {}
m_RenderingPath: 1
@@ -786,8 +830,14 @@ PlayerSettings:
luminVersion:
m_VersionCode: 1
m_VersionName:
hmiPlayerDataPath:
hmiForceSRGBBlit: 1
embeddedLinuxEnableGamepadInput: 1
hmiLogStartupTiming: 0
hmiCpuConfiguration:
apiCompatibilityLevel: 6
activeInputHandler: 0
activeInputHandler: 2
windowsGamepadBackendHint: 0
cloudProjectId:
framebufferDepthMemorylessMode: 0
qualitySettingsNames: []
@@ -795,6 +845,7 @@ PlayerSettings:
organizationId:
cloudEnabled: 0
legacyClampBlendShapeWeights: 0
playerDataPath:
forceSRGBBlit: 1
hmiLoadingImage: {fileID: 0}
platformRequiresReadableAssets: 0
virtualTexturingSupportEnabled: 0
insecureHttpOption: 0
+2
View File
@@ -4,6 +4,8 @@
- orientation
- velocity
- controller binds
- sector and lap times
- ux