diff --git a/Assets/Games/Platformer/Platformer Player.prefab b/Assets/Games/Platformer/Platformer Player.prefab index 907e81b..5f6f5dc 100644 --- a/Assets/Games/Platformer/Platformer Player.prefab +++ b/Assets/Games/Platformer/Platformer Player.prefab @@ -87,6 +87,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 627266363752542778} + - component: {fileID: 5205514565969078994} - component: {fileID: 4323437100190106747} - component: {fileID: 9112988359646506999} - component: {fileID: 2791557175355662981} @@ -115,6 +116,36 @@ Transform: - {fileID: 317069132541983608} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &5205514565969078994 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6546762253351562952} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Actions: {fileID: -944628639613478452, guid: 6cbaae0ad99590d468c8b501c0452c36, 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} --- !u!212 &4323437100190106747 SpriteRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Games/Platformer/Platformer.unity b/Assets/Games/Platformer/Platformer.unity index 5e39b19..4d9150e 100644 --- a/Assets/Games/Platformer/Platformer.unity +++ b/Assets/Games/Platformer/Platformer.unity @@ -251,11 +251,6 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!1 &56161603 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 6546762253351562952, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - m_PrefabInstance: {fileID: 2115507663656225473} - m_PrefabAsset: {fileID: 0} --- !u!1 &292682714 GameObject: m_ObjectHideFlags: 0 @@ -435,72 +430,96 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!1001 &543363806 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalPosition.x - value: 12 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalPosition.y - value: 6.5 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6546762253351562952, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_Name - value: Player 2 - objectReference: {fileID: 0} - - target: {fileID: 9112988359646506999, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: player - value: 2 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} ---- !u!1 &543363807 stripped +--- !u!1 &640873643 GameObject: - m_CorrespondingSourceObject: {fileID: 6546762253351562952, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - m_PrefabInstance: {fileID: 543363806} + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 640873645} + - component: {fileID: 640873644} + - component: {fileID: 640873646} + m_Layer: 0 + m_Name: Input + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &640873644 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 640873643} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 621567455fd1c4ceb811cc8a00b6a1a5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_NotificationBehavior: 0 + m_MaxPlayerCount: 4 + m_AllowJoining: 1 + m_JoinBehavior: 0 + m_PlayerJoinedEvent: + m_PersistentCalls: + m_Calls: [] + m_PlayerLeftEvent: + m_PersistentCalls: + m_Calls: [] + m_JoinAction: + m_UseReference: 0 + m_Action: + m_Name: Join + m_Type: 0 + m_ExpectedControlType: + m_Id: 1fb2e718-d8c9-40be-b4fe-4e9aca62a4e0 + m_Processors: + m_Interactions: + m_SingletonActionBindings: [] + m_Flags: 0 + m_Reference: {fileID: 0} + m_PlayerPrefab: {fileID: 6546762253351562952, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} + m_SplitScreen: 0 + m_MaintainAspectRatioInSplitScreen: 0 + m_FixedNumberOfSplitScreens: -1 + m_SplitScreenRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 +--- !u!4 &640873645 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 640873643} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -2.2500002, y: 16, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &640873646 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 640873643} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 33e0fad1e452e0140bc99e780d4dda4f, type: 3} + m_Name: + m_EditorClassIdentifier: + spawnPosition: {x: -2.25, y: 16} --- !u!1 &1178732237 GameObject: m_ObjectHideFlags: 0 @@ -12717,67 +12736,6 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!1001 &2115507663656225473 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalPosition.x - value: -23.5 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalPosition.y - value: -4.5 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 627266363752542778, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6546762253351562952, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: m_Name - value: Player 1 - objectReference: {fileID: 0} - - target: {fileID: 9112988359646506999, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} - propertyPath: player - value: 1 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: ebfcd0c20e648c041b2f37e0de297d69, type: 3} --- !u!1001 &8682934954266721942 PrefabInstance: m_ObjectHideFlags: 0 @@ -12789,19 +12747,7 @@ PrefabInstance: - target: {fileID: 1277363986118001863, guid: e659ce6dc4d58ff4f9726fa05e1bab20, type: 3} propertyPath: player value: - objectReference: {fileID: 56161603} - - target: {fileID: 1277363986118001863, guid: e659ce6dc4d58ff4f9726fa05e1bab20, type: 3} - propertyPath: players.Array.size - value: 2 objectReference: {fileID: 0} - - target: {fileID: 1277363986118001863, guid: e659ce6dc4d58ff4f9726fa05e1bab20, type: 3} - propertyPath: 'players.Array.data[0]' - value: - objectReference: {fileID: 56161603} - - target: {fileID: 1277363986118001863, guid: e659ce6dc4d58ff4f9726fa05e1bab20, type: 3} - propertyPath: 'players.Array.data[1]' - value: - objectReference: {fileID: 543363807} - target: {fileID: 2927715701766480068, guid: e659ce6dc4d58ff4f9726fa05e1bab20, type: 3} propertyPath: m_Name value: Platformer Camera @@ -12857,7 +12803,6 @@ SceneRoots: m_Roots: - {fileID: 8682934954266721942} - {fileID: 322321} - - {fileID: 2115507663656225473} - - {fileID: 543363806} - {fileID: 1758254989} - {fileID: 1355961160} + - {fileID: 640873645} diff --git a/Assets/Games/Platformer/PlatformerCameraMovement.cs b/Assets/Games/Platformer/PlatformerCameraMovement.cs index a78a70c..71741b9 100644 --- a/Assets/Games/Platformer/PlatformerCameraMovement.cs +++ b/Assets/Games/Platformer/PlatformerCameraMovement.cs @@ -17,6 +17,8 @@ public class PlatformerCameraMovement : MonoBehaviour private void Update() { + if (players.Count == 0) return; + Vector3 playerAverage = Vector3.zero; foreach (GameObject player in players) { diff --git a/Assets/Games/Platformer/PlatformerPlayerMovement.cs b/Assets/Games/Platformer/PlatformerPlayerMovement.cs index c183157..7cc70ff 100644 --- a/Assets/Games/Platformer/PlatformerPlayerMovement.cs +++ b/Assets/Games/Platformer/PlatformerPlayerMovement.cs @@ -30,6 +30,7 @@ public class PlayerMovement : MonoBehaviour private Rigidbody2D body; private BoxCollider2D collide; + private PlayerInput input; private Vector2 spawnPosition; @@ -52,6 +53,7 @@ public class PlayerMovement : MonoBehaviour body = GetComponent(); collide = GetComponent(); + input = GetComponent(); } private void Update() @@ -137,7 +139,7 @@ public class PlayerMovement : MonoBehaviour body.linearVelocityX *= walkSmooth; //} - if (transform.position == positionLastFrame && (InputSystem.actions.FindAction($"Player {player} Move").ReadValue().x == 0)) + if (transform.position == positionLastFrame && (input.actions.FindAction("Move").ReadValue().x == 0)) { virtualAxisX = 0; } @@ -147,36 +149,13 @@ public class PlayerMovement : MonoBehaviour private void UpdateVirtualAxis() { - virtualButtonJump = InputSystem.actions.FindAction($"Player {player} Action").ReadValue(); - virtualButtonJumpLastFrame = InputSystem.actions.FindAction($"Player {player} Action").WasPressedThisFrame() ? 1 : 0; + virtualButtonJump = input.actions.FindAction("Action").ReadValue(); + virtualButtonJumpLastFrame = input.actions.FindAction("Action").WasPressedThisFrame() ? 1 : 0; - virtualAxisX = InputSystem.actions.FindAction($"Player {player} Move").ReadValue().x; + virtualAxisX = input.actions.FindAction("Move").ReadValue().x; return; - - // From https://discussions.unity.com/t/manually-smooth-input-getaxisraw/225141/4 - float basicallyRawAxis = InputSystem.actions.FindAction($"Player {player} Move").ReadValue().x; - float sensitivity = 3; - float gravity = 3; - float time = Time.deltaTime; - - if (basicallyRawAxis != 0) - { - virtualAxisX = Mathf.Clamp(virtualAxisX + basicallyRawAxis * sensitivity * time * turnaroundMultiplier, -1f, 1f); - } - else - { - virtualAxisX = Mathf.Clamp01(Mathf.Abs(virtualAxisX) - gravity * time) * Mathf.Sign(virtualAxisX); - } - - if ((basicallyRawAxis > 0f && virtualAxisX < 0f) || (basicallyRawAxis < 0f && virtualAxisX > 0f)) - { - turnaroundMultiplier = 2; - } - else - { - turnaroundMultiplier = 1; - } } + private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Platformer Hazard")) diff --git a/Assets/Games/Platformer/Player Actions.inputactions b/Assets/Games/Platformer/Player Actions.inputactions new file mode 100644 index 0000000..5d8da6a --- /dev/null +++ b/Assets/Games/Platformer/Player Actions.inputactions @@ -0,0 +1,719 @@ +{ + "name": "Player Actions", + "maps": [ + { + "name": "Player", + "id": "df70fa95-8a34-4494-b137-73ab6b9c7d37", + "actions": [ + { + "name": "Move", + "type": "Value", + "id": "351f2ccd-1f9f-44bf-9bec-d62ac5c5f408", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": true + }, + { + "name": "Action", + "type": "Button", + "id": "6c333d17-3450-4446-b7e0-a49595f68ba7", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false + } + ], + "bindings": [ + { + "name": "", + "id": "978bfe49-cc26-4a3d-ab7b-7d7a29327403", + "path": "/leftStick", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Move", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "1635d3fe-58b6-4ba9-a4e2-f4b964f6b5c8", + "path": "/{Primary2DAxis}", + "interactions": "", + "processors": "", + "groups": "XR", + "action": "Move", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "9bcccf09-afdb-481c-80ec-fc1f2cb11ae3", + "path": "/dpad", + "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": "/w", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "320bffee-a40b-4347-ac70-c210eb8bc73a", + "path": "/s", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "d2581a9b-1d11-4566-b27d-b92aff5fabbc", + "path": "/a", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "fcfe95b8-67b9-4526-84b5-5d0bc98d6400", + "path": "/d", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "", + "id": "6f8632d2-312f-4559-8fdd-d17a3c226436", + "path": "/e", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Action", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "d5711f4f-d742-4cb9-ac9f-f3d91107e38a", + "path": "/buttonSouth", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Action", + "isComposite": false, + "isPartOfComposite": false + } + ] + }, + { + "name": "UI", + "id": "272f6d14-89ba-496f-b7ff-215263d3219f", + "actions": [ + { + "name": "Navigate", + "type": "PassThrough", + "id": "c95b2375-e6d9-4b88-9c4c-c5e76515df4b", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "Submit", + "type": "Button", + "id": "7607c7b6-cd76-4816-beef-bd0341cfe950", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "Cancel", + "type": "Button", + "id": "15cef263-9014-4fd5-94d9-4e4a6234a6ef", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "Point", + "type": "PassThrough", + "id": "32b35790-4ed0-4e9a-aa41-69ac6d629449", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": true + }, + { + "name": "Click", + "type": "PassThrough", + "id": "3c7022bf-7922-4f7c-a998-c437916075ad", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": true + }, + { + "name": "RightClick", + "type": "PassThrough", + "id": "44b200b1-1557-4083-816c-b22cbdf77ddf", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "MiddleClick", + "type": "PassThrough", + "id": "dad70c86-b58c-4b17-88ad-f5e53adf419e", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "ScrollWheel", + "type": "PassThrough", + "id": "0489e84a-4833-4c40-bfae-cea84b696689", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "TrackedDevicePosition", + "type": "PassThrough", + "id": "24908448-c609-4bc3-a128-ea258674378a", + "expectedControlType": "Vector3", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "TrackedDeviceOrientation", + "type": "PassThrough", + "id": "9caa3d8a-6b2f-4e8e-8bad-6ede561bd9be", + "expectedControlType": "Quaternion", + "processors": "", + "interactions": "", + "initialStateCheck": false + } + ], + "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": "/leftStick/up", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "up", + "id": "9144cbe6-05e1-4687-a6d7-24f99d23dd81", + "path": "/rightStick/up", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "2db08d65-c5fb-421b-983f-c71163608d67", + "path": "/leftStick/down", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "58748904-2ea9-4a80-8579-b500e6a76df8", + "path": "/rightStick/down", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "8ba04515-75aa-45de-966d-393d9bbd1c14", + "path": "/leftStick/left", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "712e721c-bdfb-4b23-a86c-a0d9fcfea921", + "path": "/rightStick/left", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "fcd248ae-a788-4676-a12e-f4d81205600b", + "path": "/leftStick/right", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "1f04d9bc-c50b-41a1-bfcc-afb75475ec20", + "path": "/rightStick/right", + "interactions": "", + "processors": "", + "groups": ";Gamepad", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "", + "id": "fb8277d4-c5cd-4663-9dc7-ee3f0b506d90", + "path": "/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": "/stick/up", + "interactions": "", + "processors": "", + "groups": "Joystick", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "0cb3e13e-3d90-4178-8ae6-d9c5501d653f", + "path": "/stick/down", + "interactions": "", + "processors": "", + "groups": "Joystick", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "0392d399-f6dd-4c82-8062-c1e9c0d34835", + "path": "/stick/left", + "interactions": "", + "processors": "", + "groups": "Joystick", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "942a66d9-d42f-43d6-8d70-ecb4ba5363bc", + "path": "/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": "/w", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "up", + "id": "eb480147-c587-4a33-85ed-eb0ab9942c43", + "path": "/upArrow", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "2bf42165-60bc-42ca-8072-8c13ab40239b", + "path": "/s", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "85d264ad-e0a0-4565-b7ff-1a37edde51ac", + "path": "/downArrow", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "74214943-c580-44e4-98eb-ad7eebe17902", + "path": "/a", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "cea9b045-a000-445b-95b8-0c171af70a3b", + "path": "/leftArrow", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "8607c725-d935-4808-84b1-8354e29bab63", + "path": "/d", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "4cda81dc-9edd-4e03-9d7c-a71a14345d0b", + "path": "/rightArrow", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Navigate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "", + "id": "9e92bb26-7e3b-4ec4-b06b-3c8f8e498ddc", + "path": "*/{Submit}", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse;Gamepad;Touch;Joystick;XR", + "action": "Submit", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "82627dcc-3b13-4ba9-841d-e4b746d6553e", + "path": "*/{Cancel}", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse;Gamepad;Touch;Joystick;XR", + "action": "Cancel", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "c52c8e0b-8179-41d3-b8a1-d149033bbe86", + "path": "/position", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Point", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "e1394cbc-336e-44ce-9ea8-6007ed6193f7", + "path": "/position", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Point", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "5693e57a-238a-46ed-b5ae-e64e6e574302", + "path": "/touch*/position", + "interactions": "", + "processors": "", + "groups": "Touch", + "action": "Point", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "4faf7dc9-b979-4210-aa8c-e808e1ef89f5", + "path": "/leftButton", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Click", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "8d66d5ba-88d7-48e6-b1cd-198bbfef7ace", + "path": "/tip", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "Click", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "47c2a644-3ebc-4dae-a106-589b7ca75b59", + "path": "/touch*/press", + "interactions": "", + "processors": "", + "groups": "Touch", + "action": "Click", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "bb9e6b34-44bf-4381-ac63-5aa15d19f677", + "path": "/trigger", + "interactions": "", + "processors": "", + "groups": "XR", + "action": "Click", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "38c99815-14ea-4617-8627-164d27641299", + "path": "/scroll", + "interactions": "", + "processors": "", + "groups": ";Keyboard&Mouse", + "action": "ScrollWheel", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "4c191405-5738-4d4b-a523-c6a301dbf754", + "path": "/rightButton", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "RightClick", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "24066f69-da47-44f3-a07e-0015fb02eb2e", + "path": "/middleButton", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "MiddleClick", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "7236c0d9-6ca3-47cf-a6ee-a97f5b59ea77", + "path": "/devicePosition", + "interactions": "", + "processors": "", + "groups": "XR", + "action": "TrackedDevicePosition", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "23e01e3a-f935-4948-8d8b-9bcac77714fb", + "path": "/deviceRotation", + "interactions": "", + "processors": "", + "groups": "XR", + "action": "TrackedDeviceOrientation", + "isComposite": false, + "isPartOfComposite": false + } + ] + } + ], + "controlSchemes": [ + { + "name": "Keyboard&Mouse", + "bindingGroup": "Keyboard&Mouse", + "devices": [ + { + "devicePath": "", + "isOptional": false, + "isOR": false + }, + { + "devicePath": "", + "isOptional": false, + "isOR": false + } + ] + }, + { + "name": "Gamepad", + "bindingGroup": "Gamepad", + "devices": [ + { + "devicePath": "", + "isOptional": false, + "isOR": false + } + ] + }, + { + "name": "Touch", + "bindingGroup": "Touch", + "devices": [ + { + "devicePath": "", + "isOptional": false, + "isOR": false + } + ] + }, + { + "name": "Joystick", + "bindingGroup": "Joystick", + "devices": [ + { + "devicePath": "", + "isOptional": false, + "isOR": false + } + ] + }, + { + "name": "XR", + "bindingGroup": "XR", + "devices": [ + { + "devicePath": "", + "isOptional": false, + "isOR": false + } + ] + } + ] +} \ No newline at end of file diff --git a/Assets/Games/Platformer/Player Actions.inputactions.meta b/Assets/Games/Platformer/Player Actions.inputactions.meta new file mode 100644 index 0000000..4bbc69d --- /dev/null +++ b/Assets/Games/Platformer/Player Actions.inputactions.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 6cbaae0ad99590d468c8b501c0452c36 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3} + generateWrapperCode: 0 + wrapperCodePath: + wrapperClassName: + wrapperCodeNamespace: diff --git a/Assets/PlayerManager.cs b/Assets/PlayerManager.cs new file mode 100644 index 0000000..81c1eb2 --- /dev/null +++ b/Assets/PlayerManager.cs @@ -0,0 +1,31 @@ +using UnityEngine; +using UnityEngine.InputSystem; + +public class PlayerManager : MonoBehaviour +{ + [SerializeField] private Vector2 spawnPosition; + + private PlatformerCameraMovement playerCamera; + + private void Start() + { + GetComponent().onPlayerJoined += OnPlayerJoined; + GetComponent().onPlayerLeft += OnPlayerLeft; + + playerCamera = FindFirstObjectByType(); + } + + private void OnPlayerJoined(PlayerInput playerInput) + { + playerInput.transform.position = spawnPosition; + playerCamera.players.Add(playerInput.gameObject); + print("Player joined"); + } + + private void OnPlayerLeft(PlayerInput playerInput) + { + Destroy(playerInput.gameObject); + playerCamera.players.Remove(playerInput.gameObject); + print("Player left"); + } +} diff --git a/Assets/PlayerManager.cs.meta b/Assets/PlayerManager.cs.meta new file mode 100644 index 0000000..0a48977 --- /dev/null +++ b/Assets/PlayerManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 33e0fad1e452e0140bc99e780d4dda4f \ No newline at end of file