Skip to content

Commit d2d321e

Browse files
author
Rene Damm
authored
FIX: PlayerInputManager joining not working with kb&mouse schemes (#1023, #1037).
1 parent c2dbec3 commit d2d321e

23 files changed

+3132
-38
lines changed

Assets/Samples/SimpleMultiplayer.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"displayName": "Simple Multiplayer",
3+
"description": "Demonstrates how to set up a simple local multiplayer scenario."
4+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1 &5062027600983921548
4+
GameObject:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
serializedVersion: 6
10+
m_Component:
11+
- component: {fileID: 5062027600983921537}
12+
- component: {fileID: 5062027600983921550}
13+
- component: {fileID: 3984910858365239293}
14+
- component: {fileID: -4472597160913118672}
15+
m_Layer: 0
16+
m_Name: Player
17+
m_TagString: MainCamera
18+
m_Icon: {fileID: 0}
19+
m_NavMeshLayer: 0
20+
m_StaticEditorFlags: 0
21+
m_IsActive: 1
22+
--- !u!4 &5062027600983921537
23+
Transform:
24+
m_ObjectHideFlags: 0
25+
m_CorrespondingSourceObject: {fileID: 0}
26+
m_PrefabInstance: {fileID: 0}
27+
m_PrefabAsset: {fileID: 0}
28+
m_GameObject: {fileID: 5062027600983921548}
29+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
30+
m_LocalPosition: {x: 0, y: 1, z: -10}
31+
m_LocalScale: {x: 1, y: 1, z: 1}
32+
m_Children: []
33+
m_Father: {fileID: 0}
34+
m_RootOrder: 0
35+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
36+
--- !u!20 &5062027600983921550
37+
Camera:
38+
m_ObjectHideFlags: 0
39+
m_CorrespondingSourceObject: {fileID: 0}
40+
m_PrefabInstance: {fileID: 0}
41+
m_PrefabAsset: {fileID: 0}
42+
m_GameObject: {fileID: 5062027600983921548}
43+
m_Enabled: 1
44+
serializedVersion: 2
45+
m_ClearFlags: 1
46+
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
47+
m_projectionMatrixMode: 1
48+
m_GateFitMode: 2
49+
m_FOVAxisMode: 0
50+
m_SensorSize: {x: 36, y: 24}
51+
m_LensShift: {x: 0, y: 0}
52+
m_FocalLength: 50
53+
m_NormalizedViewPortRect:
54+
serializedVersion: 2
55+
x: 0
56+
y: 0
57+
width: 1
58+
height: 1
59+
near clip plane: 0.3
60+
far clip plane: 1000
61+
field of view: 60
62+
orthographic: 0
63+
orthographic size: 5
64+
m_Depth: -1
65+
m_CullingMask:
66+
serializedVersion: 2
67+
m_Bits: 4294967295
68+
m_RenderingPath: -1
69+
m_TargetTexture: {fileID: 0}
70+
m_TargetDisplay: 0
71+
m_TargetEye: 3
72+
m_HDR: 1
73+
m_AllowMSAA: 1
74+
m_AllowDynamicResolution: 0
75+
m_ForceIntoRT: 0
76+
m_OcclusionCulling: 1
77+
m_StereoConvergence: 10
78+
m_StereoSeparation: 0.022
79+
--- !u!114 &3984910858365239293
80+
MonoBehaviour:
81+
m_ObjectHideFlags: 0
82+
m_CorrespondingSourceObject: {fileID: 0}
83+
m_PrefabInstance: {fileID: 0}
84+
m_PrefabAsset: {fileID: 0}
85+
m_GameObject: {fileID: 5062027600983921548}
86+
m_Enabled: 1
87+
m_EditorHideFlags: 0
88+
m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3}
89+
m_Name:
90+
m_EditorClassIdentifier:
91+
m_Actions: {fileID: -944628639613478452, guid: 9547001c61582724894ebf550c5b4921,
92+
type: 3}
93+
m_NotificationBehavior: 0
94+
m_UIInputModule: {fileID: 0}
95+
m_DeviceLostEvent:
96+
m_PersistentCalls:
97+
m_Calls: []
98+
m_TypeName: UnityEngine.InputSystem.PlayerInput+DeviceLostEvent, Unity.InputSystem,
99+
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
100+
m_DeviceRegainedEvent:
101+
m_PersistentCalls:
102+
m_Calls: []
103+
m_TypeName: UnityEngine.InputSystem.PlayerInput+DeviceRegainedEvent, Unity.InputSystem,
104+
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
105+
m_ControlsChangedEvent:
106+
m_PersistentCalls:
107+
m_Calls: []
108+
m_TypeName: UnityEngine.InputSystem.PlayerInput+ControlsChangedEvent, Unity.InputSystem,
109+
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
110+
m_ActionEvents: []
111+
m_NeverAutoSwitchControlSchemes: 0
112+
m_DefaultControlScheme:
113+
m_DefaultActionMap: Player
114+
m_SplitScreenIndex: -1
115+
m_Camera: {fileID: 5062027600983921550}
116+
--- !u!114 &-4472597160913118672
117+
MonoBehaviour:
118+
m_ObjectHideFlags: 0
119+
m_CorrespondingSourceObject: {fileID: 0}
120+
m_PrefabInstance: {fileID: 0}
121+
m_PrefabAsset: {fileID: 0}
122+
m_GameObject: {fileID: 5062027600983921548}
123+
m_Enabled: 1
124+
m_EditorHideFlags: 0
125+
m_Script: {fileID: 11500000, guid: 4674e99101c1ae941b6a293e43c2af7a, type: 3}
126+
m_Name:
127+
m_EditorClassIdentifier:

Assets/Samples/SimpleMultiplayer/Player.prefab.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Simple Multiplayer Demo
2+
3+
This demo shows a simple local multiplayer setup. Players can join by pressing buttons on the supported devices. As players join, the screen is subdivided in split-screen fashion.
4+
5+
Joining is handled by the `PlayerManager` GameObject in the scene which has the `PlayerInputManager` component added to it. The component references [`Player.prefab`](./Player.prefab) which is instantiated for each player that joins the game.
6+
7+
The prefab contains a GameObject that has a `PlayerInput` component added to it. The component references the [actions](./SimpleMultiplayerControls.inputactions) available to each player which, by means of the control schemes defined in the asset, also determine the devices (and combinations of devices) supported by the game.
8+
9+
The actions available to each player are intentionally kept simple for this demonstration in order to not add irrelevant details. The only action available to players is `Teleport` which players can trigger through a button on their device. When trigger, they will be teleported to a random position within the game area. This serves to demonstrate that player inputs are indeed separate.
10+
11+
Note that each `PlayerInput` also references a `Camera` which is specific to each player. This is used by `PlayerInputManager` to configure the split-screen setup.

Assets/Samples/SimpleMultiplayer/README.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{
2+
"name": "SimpleMultiplayerControls",
3+
"maps": [
4+
{
5+
"name": "Player",
6+
"id": "fb8d6404-ed77-4dcb-9196-b47c736924a7",
7+
"actions": [
8+
{
9+
"name": "Teleport",
10+
"type": "Button",
11+
"id": "da5efce7-0b41-45bb-9a3c-2c57823845bf",
12+
"expectedControlType": "Button",
13+
"processors": "",
14+
"interactions": ""
15+
}
16+
],
17+
"bindings": [
18+
{
19+
"name": "",
20+
"id": "143bb1cd-cc10-4eca-a2f0-a3664166fe91",
21+
"path": "<Gamepad>/rightTrigger",
22+
"interactions": "",
23+
"processors": "",
24+
"groups": ";Gamepad",
25+
"action": "Teleport",
26+
"isComposite": false,
27+
"isPartOfComposite": false
28+
},
29+
{
30+
"name": "",
31+
"id": "05f6913d-c316-48b2-a6bb-e225f14c7960",
32+
"path": "<Mouse>/leftButton",
33+
"interactions": "",
34+
"processors": "",
35+
"groups": ";Keyboard&Mouse",
36+
"action": "Teleport",
37+
"isComposite": false,
38+
"isPartOfComposite": false
39+
},
40+
{
41+
"name": "",
42+
"id": "886e731e-7071-4ae4-95c0-e61739dad6fd",
43+
"path": "<Touchscreen>/primaryTouch/tap",
44+
"interactions": "",
45+
"processors": "",
46+
"groups": ";Touch",
47+
"action": "Teleport",
48+
"isComposite": false,
49+
"isPartOfComposite": false
50+
},
51+
{
52+
"name": "",
53+
"id": "ee3d0cd2-254e-47a7-a8cb-bc94d9658c54",
54+
"path": "<Joystick>/trigger",
55+
"interactions": "",
56+
"processors": "",
57+
"groups": "Joystick",
58+
"action": "Teleport",
59+
"isComposite": false,
60+
"isPartOfComposite": false
61+
},
62+
{
63+
"name": "",
64+
"id": "8255d333-5683-4943-a58a-ccb207ff1dce",
65+
"path": "<XRController>/{PrimaryAction}",
66+
"interactions": "",
67+
"processors": "",
68+
"groups": "XR",
69+
"action": "Teleport",
70+
"isComposite": false,
71+
"isPartOfComposite": false
72+
}
73+
]
74+
}
75+
],
76+
"controlSchemes": [
77+
{
78+
"name": "Keyboard&Mouse",
79+
"bindingGroup": "Keyboard&Mouse",
80+
"devices": [
81+
{
82+
"devicePath": "<Keyboard>",
83+
"isOptional": false,
84+
"isOR": false
85+
},
86+
{
87+
"devicePath": "<Mouse>",
88+
"isOptional": false,
89+
"isOR": false
90+
}
91+
]
92+
},
93+
{
94+
"name": "Gamepad",
95+
"bindingGroup": "Gamepad",
96+
"devices": [
97+
{
98+
"devicePath": "<Gamepad>",
99+
"isOptional": false,
100+
"isOR": false
101+
}
102+
]
103+
},
104+
{
105+
"name": "Touch",
106+
"bindingGroup": "Touch",
107+
"devices": [
108+
{
109+
"devicePath": "<Touchscreen>",
110+
"isOptional": false,
111+
"isOR": false
112+
}
113+
]
114+
},
115+
{
116+
"name": "Joystick",
117+
"bindingGroup": "Joystick",
118+
"devices": [
119+
{
120+
"devicePath": "<Joystick>",
121+
"isOptional": false,
122+
"isOR": false
123+
}
124+
]
125+
},
126+
{
127+
"name": "XR",
128+
"bindingGroup": "XR",
129+
"devices": [
130+
{
131+
"devicePath": "<XRController>",
132+
"isOptional": false,
133+
"isOR": false
134+
}
135+
]
136+
}
137+
]
138+
}

Assets/Samples/SimpleMultiplayer/SimpleMultiplayerControls.inputactions.meta

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)