From 3921306a894187a2adc6af0a79bb816319531112 Mon Sep 17 00:00:00 2001 From: Anna Matela <anmatela@gmail.com> Date: Thu, 21 Jan 2021 09:41:41 +0200 Subject: [PATCH] made script to make Player object move --- RollABall/Assets/Input.meta | 8 + .../Assets/Input/InputActions.inputactions | 825 ++++++++++++++++++ .../Input/InputActions.inputactions.meta | 14 + RollABall/Assets/Scenes/MiniGame.unity | 95 ++ RollABall/Assets/Scripts.meta | 8 + RollABall/Assets/Scripts/PlayerController.cs | 36 + .../Assets/Scripts/PlayerController.cs.meta | 11 + RollABall/Packages/manifest.json | 1 + RollABall/Packages/packages-lock.json | 7 + .../ProjectSettings/ProjectSettings.asset | 4 +- 10 files changed, 1007 insertions(+), 2 deletions(-) create mode 100644 RollABall/Assets/Input.meta create mode 100644 RollABall/Assets/Input/InputActions.inputactions create mode 100644 RollABall/Assets/Input/InputActions.inputactions.meta create mode 100644 RollABall/Assets/Scripts.meta create mode 100644 RollABall/Assets/Scripts/PlayerController.cs create mode 100644 RollABall/Assets/Scripts/PlayerController.cs.meta diff --git a/RollABall/Assets/Input.meta b/RollABall/Assets/Input.meta new file mode 100644 index 0000000..953fe60 --- /dev/null +++ b/RollABall/Assets/Input.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ffdb85055592196439be137ea566e7cc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RollABall/Assets/Input/InputActions.inputactions b/RollABall/Assets/Input/InputActions.inputactions new file mode 100644 index 0000000..363472d --- /dev/null +++ b/RollABall/Assets/Input/InputActions.inputactions @@ -0,0 +1,825 @@ +{ + "name": "RollABall", + "maps": [ + { + "name": "Player", + "id": "6809e193-050e-47b2-a193-769a7d2affb8", + "actions": [ + { + "name": "Move", + "type": "Value", + "id": "5d54ff2e-f7bd-4697-a4c5-d82ce1f9f4a3", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "" + }, + { + "name": "Look", + "type": "Value", + "id": "5e643195-6e6c-45a6-986b-7b9843c11a04", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "" + }, + { + "name": "Fire", + "type": "Button", + "id": "7a81b1a9-7fc1-442f-94b3-ccf90a367b03", + "expectedControlType": "Button", + "processors": "", + "interactions": "" + } + ], + "bindings": [ + { + "name": "", + "id": "978bfe49-cc26-4a3d-ab7b-7d7a29327403", + "path": "<Gamepad>/leftStick", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Move", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "WASD", + "id": "00ca640b-d935-4593-8157-c05846ea39b3", + "path": "Dpad", + "interactions": "", + "processors": "", + "groups": "", + "action": "Move", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "up", + "id": "e2062cb9-1b15-46a2-838c-2f8d72a0bdd9", + "path": "<Keyboard>/w", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "up", + "id": "8180e8bd-4097-4f4e-ab88-4523101a6ce9", + "path": "<Keyboard>/upArrow", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "320bffee-a40b-4347-ac70-c210eb8bc73a", + "path": "<Keyboard>/s", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "1c5327b5-f71c-4f60-99c7-4e737386f1d1", + "path": "<Keyboard>/downArrow", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "d2581a9b-1d11-4566-b27d-b92aff5fabbc", + "path": "<Keyboard>/a", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "2e46982e-44cc-431b-9f0b-c11910bf467a", + "path": "<Keyboard>/leftArrow", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "fcfe95b8-67b9-4526-84b5-5d0bc98d6400", + "path": "<Keyboard>/d", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "77bff152-3580-4b21-b6de-dcd0c7e41164", + "path": "<Keyboard>/rightArrow", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "", + "id": "1635d3fe-58b6-4ba9-a4e2-f4b964f6b5c8", + "path": "<XRController>/{Primary2DAxis}", + "interactions": "", + "processors": "", + "groups": "XR", + "action": "Move", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "3ea4d645-4504-4529-b061-ab81934c3752", + "path": "<Joystick>/stick", + "interactions": "", + "processors": "", + "groups": "Joystick", + "action": "Move", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "c1f7a91b-d0fd-4a62-997e-7fb9b69bf235", + "path": "<Gamepad>/rightStick", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Look", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "8c8e490b-c610-4785-884f-f04217b23ca4", + "path": "<Pointer>/delta", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse;Touch", + "action": "Look", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "3e5f5442-8668-4b27-a940-df99bad7e831", + "path": "<Joystick>/{Hatswitch}", + "interactions": "", + "processors": "", + "groups": "Joystick", + "action": "Look", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "143bb1cd-cc10-4eca-a2f0-a3664166fe91", + "path": "<Gamepad>/rightTrigger", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Fire", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "05f6913d-c316-48b2-a6bb-e225f14c7960", + "path": "<Mouse>/leftButton", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Fire", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "886e731e-7071-4ae4-95c0-e61739dad6fd", + "path": "<Touchscreen>/primaryTouch/tap", + "interactions": "", + "processors": "", + "groups": ";Touch", + "action": "Fire", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "ee3d0cd2-254e-47a7-a8cb-bc94d9658c54", + "path": "<Joystick>/trigger", + "interactions": "", + "processors": "", + "groups": "Joystick", + "action": "Fire", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "8255d333-5683-4943-a58a-ccb207ff1dce", + "path": "<XRController>/{PrimaryAction}", + "interactions": "", + "processors": "", + "groups": "XR", + "action": "Fire", + "isComposite": false, + "isPartOfComposite": false + } + ] + }, + { + "name": "UI", + "id": "f59d8024-78c6-4479-a469-8c758a90d802", + "actions": [ + { + "name": "Navigate", + "type": "Value", + "id": "e14e9c1f-ccbc-4de3-8814-88c0238ddcb4", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "" + }, + { + "name": "Submit", + "type": "Button", + "id": "5843552d-f206-4895-859d-55478c372241", + "expectedControlType": "Button", + "processors": "", + "interactions": "" + }, + { + "name": "Cancel", + "type": "Button", + "id": "b265ecca-c01d-454b-a570-746b8c9135b7", + "expectedControlType": "Button", + "processors": "", + "interactions": "" + }, + { + "name": "Point", + "type": "PassThrough", + "id": "0fbb7ceb-2452-4745-bbd5-c48220d8576e", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "" + }, + { + "name": "Click", + "type": "PassThrough", + "id": "053238eb-0aaf-433f-93ea-b10cc4253ed4", + "expectedControlType": "Button", + "processors": "", + "interactions": "" + }, + { + "name": "ScrollWheel", + "type": "PassThrough", + "id": "5633a93f-5498-4dc2-bff9-5cf2309af5ee", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "" + }, + { + "name": "MiddleClick", + "type": "PassThrough", + "id": "9a001cf9-0ac8-4d1e-8229-5d6e0b224ff4", + "expectedControlType": "", + "processors": "", + "interactions": "" + }, + { + "name": "RightClick", + "type": "PassThrough", + "id": "20ea43eb-7edc-4a8a-b9bb-a570b15d6d69", + "expectedControlType": "", + "processors": "", + "interactions": "" + }, + { + "name": "TrackedDevicePosition", + "type": "PassThrough", + "id": "c819fa79-017c-49fd-b372-f50c19722547", + "expectedControlType": "Vector3", + "processors": "", + "interactions": "" + }, + { + "name": "TrackedDeviceOrientation", + "type": "PassThrough", + "id": "9f54309a-9613-4965-864c-95b406b17e8d", + "expectedControlType": "Quaternion", + "processors": "", + "interactions": "" + } + ], + "bindings": [ + { + "name": "Gamepad", + "id": "809f371f-c5e2-4e7a-83a1-d867598f40dd", + "path": "2DVector", + "interactions": "", + "processors": "", + "groups": "", + "action": "Navigate", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "up", + "id": "14a5d6e8-4aaf-4119-a9ef-34b8c2c548bf", + "path": "<Gamepad>/leftStick/up", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "up", + "id": "9144cbe6-05e1-4687-a6d7-24f99d23dd81", + "path": "<Gamepad>/rightStick/up", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "2db08d65-c5fb-421b-983f-c71163608d67", + "path": "<Gamepad>/leftStick/down", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "58748904-2ea9-4a80-8579-b500e6a76df8", + "path": "<Gamepad>/rightStick/down", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "8ba04515-75aa-45de-966d-393d9bbd1c14", + "path": "<Gamepad>/leftStick/left", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "712e721c-bdfb-4b23-a86c-a0d9fcfea921", + "path": "<Gamepad>/rightStick/left", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "fcd248ae-a788-4676-a12e-f4d81205600b", + "path": "<Gamepad>/leftStick/right", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "1f04d9bc-c50b-41a1-bfcc-afb75475ec20", + "path": "<Gamepad>/rightStick/right", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "", + "id": "fb8277d4-c5cd-4663-9dc7-ee3f0b506d90", + "path": "<Gamepad>/dpad", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "Joystick", + "id": "e25d9774-381c-4a61-b47c-7b6b299ad9f9", + "path": "2DVector", + "interactions": "", + "processors": "", + "groups": "", + "action": "Navigate", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "up", + "id": "3db53b26-6601-41be-9887-63ac74e79d19", + "path": "<Joystick>/stick/up", + "interactions": "", + "processors": "", + "groups": "Joystick", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "0cb3e13e-3d90-4178-8ae6-d9c5501d653f", + "path": "<Joystick>/stick/down", + "interactions": "", + "processors": "", + "groups": "Joystick", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "0392d399-f6dd-4c82-8062-c1e9c0d34835", + "path": "<Joystick>/stick/left", + "interactions": "", + "processors": "", + "groups": "Joystick", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "942a66d9-d42f-43d6-8d70-ecb4ba5363bc", + "path": "<Joystick>/stick/right", + "interactions": "", + "processors": "", + "groups": "Joystick", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "Keyboard", + "id": "ff527021-f211-4c02-933e-5976594c46ed", + "path": "2DVector", + "interactions": "", + "processors": "", + "groups": "", + "action": "Navigate", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "up", + "id": "563fbfdd-0f09-408d-aa75-8642c4f08ef0", + "path": "<Keyboard>/w", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "up", + "id": "eb480147-c587-4a33-85ed-eb0ab9942c43", + "path": "<Keyboard>/upArrow", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "2bf42165-60bc-42ca-8072-8c13ab40239b", + "path": "<Keyboard>/s", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "85d264ad-e0a0-4565-b7ff-1a37edde51ac", + "path": "<Keyboard>/downArrow", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "74214943-c580-44e4-98eb-ad7eebe17902", + "path": "<Keyboard>/a", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "cea9b045-a000-445b-95b8-0c171af70a3b", + "path": "<Keyboard>/leftArrow", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "8607c725-d935-4808-84b1-8354e29bab63", + "path": "<Keyboard>/d", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "4cda81dc-9edd-4e03-9d7c-a71a14345d0b", + "path": "<Keyboard>/rightArrow", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "", + "id": "9e92bb26-7e3b-4ec4-b06b-3c8f8e498ddc", + "path": "*/{Submit}", + "interactions": "", + "processors": "", + "groups": "", + "action": "Submit", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "82627dcc-3b13-4ba9-841d-e4b746d6553e", + "path": "*/{Cancel}", + "interactions": "", + "processors": "", + "groups": "", + "action": "Cancel", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "c52c8e0b-8179-41d3-b8a1-d149033bbe86", + "path": "<Mouse>/position", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Point", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "e1394cbc-336e-44ce-9ea8-6007ed6193f7", + "path": "<Pen>/position", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Point", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "5693e57a-238a-46ed-b5ae-e64e6e574302", + "path": "<Touchscreen>/touch*/position", + "interactions": "", + "processors": "", + "groups": "Touch", + "action": "Point", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "4faf7dc9-b979-4210-aa8c-e808e1ef89f5", + "path": "<Mouse>/leftButton", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Click", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "8d66d5ba-88d7-48e6-b1cd-198bbfef7ace", + "path": "<Pen>/tip", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Click", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "47c2a644-3ebc-4dae-a106-589b7ca75b59", + "path": "<Touchscreen>/touch*/press", + "interactions": "", + "processors": "", + "groups": "Touch", + "action": "Click", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "bb9e6b34-44bf-4381-ac63-5aa15d19f677", + "path": "<XRController>/trigger", + "interactions": "", + "processors": "", + "groups": "XR", + "action": "Click", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "38c99815-14ea-4617-8627-164d27641299", + "path": "<Mouse>/scroll", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "ScrollWheel", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "24066f69-da47-44f3-a07e-0015fb02eb2e", + "path": "<Mouse>/middleButton", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "MiddleClick", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "4c191405-5738-4d4b-a523-c6a301dbf754", + "path": "<Mouse>/rightButton", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "RightClick", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "7236c0d9-6ca3-47cf-a6ee-a97f5b59ea77", + "path": "<XRController>/devicePosition", + "interactions": "", + "processors": "", + "groups": "XR", + "action": "TrackedDevicePosition", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "23e01e3a-f935-4948-8d8b-9bcac77714fb", + "path": "<XRController>/deviceRotation", + "interactions": "", + "processors": "", + "groups": "XR", + "action": "TrackedDeviceOrientation", + "isComposite": false, + "isPartOfComposite": false + } + ] + } + ], + "controlSchemes": [ + { + "name": "Keyboard&Mouse", + "bindingGroup": "Keyboard&Mouse", + "devices": [ + { + "devicePath": "<Keyboard>", + "isOptional": false, + "isOR": false + }, + { + "devicePath": "<Mouse>", + "isOptional": false, + "isOR": false + } + ] + }, + { + "name": "Gamepad", + "bindingGroup": "Gamepad", + "devices": [ + { + "devicePath": "<Gamepad>", + "isOptional": false, + "isOR": false + } + ] + }, + { + "name": "Touch", + "bindingGroup": "Touch", + "devices": [ + { + "devicePath": "<Touchscreen>", + "isOptional": false, + "isOR": false + } + ] + }, + { + "name": "Joystick", + "bindingGroup": "Joystick", + "devices": [ + { + "devicePath": "<Joystick>", + "isOptional": false, + "isOR": false + } + ] + }, + { + "name": "XR", + "bindingGroup": "XR", + "devices": [ + { + "devicePath": "<XRController>", + "isOptional": false, + "isOR": false + } + ] + } + ] +} \ No newline at end of file diff --git a/RollABall/Assets/Input/InputActions.inputactions.meta b/RollABall/Assets/Input/InputActions.inputactions.meta new file mode 100644 index 0000000..5a945b3 --- /dev/null +++ b/RollABall/Assets/Input/InputActions.inputactions.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 157c5ba907a5b6543b85e1925086af8d +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3} + generateWrapperCode: 0 + wrapperCodePath: + wrapperClassName: + wrapperCodeNamespace: diff --git a/RollABall/Assets/Scenes/MiniGame.unity b/RollABall/Assets/Scenes/MiniGame.unity index 5d48af7..2d46d25 100644 --- a/RollABall/Assets/Scenes/MiniGame.unity +++ b/RollABall/Assets/Scenes/MiniGame.unity @@ -226,6 +226,7 @@ GameObject: - component: {fileID: 1640422003} - component: {fileID: 1640422002} - component: {fileID: 1640422001} + - component: {fileID: 1640422004} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -298,6 +299,37 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1640422004 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1640422000} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 --- !u!1 &2060902285 GameObject: m_ObjectHideFlags: 0 @@ -402,6 +434,9 @@ GameObject: - component: {fileID: 2082349479} - component: {fileID: 2082349478} - component: {fileID: 2082349477} + - component: {fileID: 2082349481} + - component: {fileID: 2082349483} + - component: {fileID: 2082349482} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -483,3 +518,63 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!54 &2082349481 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2082349476} + 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!114 &2082349482 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2082349476} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 578eeed732cf0e74198ecf19b3c86552, type: 3} + m_Name: + m_EditorClassIdentifier: + speed: 10 +--- !u!114 &2082349483 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2082349476} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Actions: {fileID: -944628639613478452, guid: 157c5ba907a5b6543b85e1925086af8d, + type: 3} + m_NotificationBehavior: 0 + m_UIInputModule: {fileID: 0} + m_DeviceLostEvent: + m_PersistentCalls: + m_Calls: [] + m_DeviceRegainedEvent: + m_PersistentCalls: + m_Calls: [] + m_ControlsChangedEvent: + m_PersistentCalls: + m_Calls: [] + m_ActionEvents: [] + m_NeverAutoSwitchControlSchemes: 0 + m_DefaultControlScheme: + m_DefaultActionMap: Player + m_SplitScreenIndex: -1 + m_Camera: {fileID: 0} diff --git a/RollABall/Assets/Scripts.meta b/RollABall/Assets/Scripts.meta new file mode 100644 index 0000000..a9a56c7 --- /dev/null +++ b/RollABall/Assets/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cfcac7381353aba4f943a56cb92f7607 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RollABall/Assets/Scripts/PlayerController.cs b/RollABall/Assets/Scripts/PlayerController.cs new file mode 100644 index 0000000..1c8c3f5 --- /dev/null +++ b/RollABall/Assets/Scripts/PlayerController.cs @@ -0,0 +1,36 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.InputSystem; + +public class PlayerController : MonoBehaviour +{ + public float speed = 0; + + private Rigidbody rb; + private float movementX; + private float movementY; + + // Start is called before the first frame update + void Start() + { + rb = GetComponent<Rigidbody>(); + } + + // kerää näppisdataa Player-objektin ohjaamista varten + void OnMove(InputValue movementValue) + { + Vector2 movementVector = movementValue.Get<Vector2>(); + + movementX = movementVector.x; + movementY = movementVector.y; + } + + // välittää näppisdatan Player-objektin rigidbody-komponentille + void FixedUpdate() + { + // 0.0f = 0.0 float value + Vector3 movement = new Vector3(movementX, 0.0f, movementY); + rb.AddForce(movement * speed); + } +} diff --git a/RollABall/Assets/Scripts/PlayerController.cs.meta b/RollABall/Assets/Scripts/PlayerController.cs.meta new file mode 100644 index 0000000..37d54fb --- /dev/null +++ b/RollABall/Assets/Scripts/PlayerController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 578eeed732cf0e74198ecf19b3c86552 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RollABall/Packages/manifest.json b/RollABall/Packages/manifest.json index 9e189d5..ff97cb5 100644 --- a/RollABall/Packages/manifest.json +++ b/RollABall/Packages/manifest.json @@ -3,6 +3,7 @@ "com.unity.collab-proxy": "1.2.16", "com.unity.ide.rider": "1.1.4", "com.unity.ide.vscode": "1.2.3", + "com.unity.inputsystem": "1.0.1", "com.unity.render-pipelines.universal": "7.3.1", "com.unity.test-framework": "1.1.19", "com.unity.textmeshpro": "2.1.1", diff --git a/RollABall/Packages/packages-lock.json b/RollABall/Packages/packages-lock.json index fca3e4b..1806b1a 100644 --- a/RollABall/Packages/packages-lock.json +++ b/RollABall/Packages/packages-lock.json @@ -30,6 +30,13 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.inputsystem": { + "version": "1.0.1", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, "com.unity.render-pipelines.core": { "version": "7.3.1", "depth": 1, diff --git a/RollABall/ProjectSettings/ProjectSettings.asset b/RollABall/ProjectSettings/ProjectSettings.asset index a688e9c..fd9d430 100644 --- a/RollABall/ProjectSettings/ProjectSettings.asset +++ b/RollABall/ProjectSettings/ProjectSettings.asset @@ -677,6 +677,6 @@ PlayerSettings: projectName: organizationId: cloudEnabled: 0 - enableNativePlatformBackendsForNewInputSystem: 0 - disableOldInputManagerSupport: 0 + enableNativePlatformBackendsForNewInputSystem: 1 + disableOldInputManagerSupport: 1 legacyClampBlendShapeWeights: 0 -- GitLab