Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.

Commit c1f8d72

Browse files
Fix/Simulated Players (#22)
* New level prefab changes * reduce simulated players interest radius * Added ai logic. Attempt to get back onto navmesh if fallen off, pick random destination within world bounds
1 parent e966eca commit c1f8d72

File tree

11 files changed

+194
-90
lines changed

11 files changed

+194
-90
lines changed

workers/unity/Assets/Fps/Prefabs/GameLogicWorker.prefab

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Transform:
3434
m_PrefabInternal: {fileID: 100100000}
3535
m_GameObject: {fileID: 1455626031769568}
3636
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
37-
m_LocalPosition: {x: 0, y: -1000, z: 0}
37+
m_LocalPosition: {x: 500, y: 0, z: 0}
3838
m_LocalScale: {x: 1, y: 1, z: 1}
3939
m_Children: []
4040
m_Father: {fileID: 0}
@@ -53,6 +53,7 @@ MonoBehaviour:
5353
m_EditorClassIdentifier:
5454
MaxConnectionAttempts: 3
5555
UseExternalIp: 0
56+
TargetFrameRate: 30
5657
SmallLevelPrefab: {fileID: 1613497914398450, guid: e4a3eb8590344604db1e998db676a211,
5758
type: 2}
5859
LargeLevelPrefab: {fileID: 1620385508151754, guid: 1d177d0ca1e95c646a6a7b9b84364f9b,

workers/unity/Assets/Fps/Prefabs/SimulatedPlayerCoordinatorWorker.prefab

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ MonoBehaviour:
5353
m_EditorClassIdentifier:
5454
MaxConnectionAttempts: 3
5555
UseExternalIp: 0
56-
TargetFrameRate: 60
56+
TargetFrameRate: 30
5757
SmallLevelPrefab: {fileID: 1613497914398450, guid: e4a3eb8590344604db1e998db676a211,
5858
type: 2}
5959
LargeLevelPrefab: {fileID: 1620385508151754, guid: 1d177d0ca1e95c646a6a7b9b84364f9b,
6060
type: 2}
6161
SimulatedPlayerWorkerConnector: {fileID: 1673159791827972, guid: 416b79ec2ab48a14b94f5d11fe45403f,
6262
type: 2}
63-
SimulatedPlayerCount: 1
64-
SimulatedPlayerCreationInterval: 5
63+
DefaultSimulatedPlayerCount: 1
64+
DefaultSimulatedPlayerCreationInterval: 5

workers/unity/Assets/Fps/Resources/Prefabs/SimulatedPlayer/SimulatedPlayer.prefab

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ GameObject:
2626
- component: {fileID: 114774703231759244}
2727
- component: {fileID: 114077868185640900}
2828
- component: {fileID: 114349539066892404}
29+
- component: {fileID: 114678850838096714}
30+
- component: {fileID: 114779873026297234}
2931
m_Layer: 10
3032
m_Name: SimulatedPlayer
3133
m_TagString: Untagged
@@ -157,6 +159,21 @@ MonoBehaviour:
157159
m_Script: {fileID: 11500000, guid: 3c2a62b7f39e5cc4ebc9cc90b4243763, type: 3}
158160
m_Name:
159161
m_EditorClassIdentifier:
162+
--- !u!114 &114678850838096714
163+
MonoBehaviour:
164+
m_ObjectHideFlags: 1
165+
m_CorrespondingSourceObject: {fileID: 0}
166+
m_PrefabInternal: {fileID: 100100000}
167+
m_GameObject: {fileID: 1266140103605188}
168+
m_Enabled: 1
169+
m_EditorHideFlags: 0
170+
m_Script: {fileID: 11500000, guid: 3205d6d2e2108eb478ab467af2c0fc81, type: 3}
171+
m_Name:
172+
m_EditorClassIdentifier:
173+
nearToGroundDistance: 2
174+
walkableLayer:
175+
serializedVersion: 2
176+
m_Bits: 4294967295
160177
--- !u!114 &114774703231759244
161178
MonoBehaviour:
162179
m_ObjectHideFlags: 1
@@ -193,6 +210,18 @@ MonoBehaviour:
193210
groundLayerMask:
194211
serializedVersion: 2
195212
m_Bits: 1
213+
--- !u!114 &114779873026297234
214+
MonoBehaviour:
215+
m_ObjectHideFlags: 1
216+
m_CorrespondingSourceObject: {fileID: 0}
217+
m_PrefabInternal: {fileID: 100100000}
218+
m_GameObject: {fileID: 1266140103605188}
219+
m_Enabled: 1
220+
m_EditorHideFlags: 0
221+
m_Script: {fileID: 11500000, guid: 6a26382f57abcf24aa8b96ce9bf51d71, type: 3}
222+
m_Name:
223+
m_EditorClassIdentifier:
224+
slideFriction: 0.8
196225
--- !u!114 &114780642311106078
197226
MonoBehaviour:
198227
m_ObjectHideFlags: 1
@@ -249,7 +278,7 @@ NavMeshAgent:
249278
m_AngularSpeed: 120
250279
m_StoppingDistance: 0
251280
m_AutoTraverseOffMeshLink: 1
252-
m_AutoBraking: 1
281+
m_AutoBraking: 0
253282
m_AutoRepath: 1
254283
m_Height: 1.75
255284
m_BaseOffset: 0

workers/unity/Assets/Fps/Scenes/FPS-Development.unity

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ NavMeshSettings:
9898
m_BuildSettings:
9999
serializedVersion: 2
100100
agentTypeID: 0
101-
agentRadius: 0.5
102-
agentHeight: 2
101+
agentRadius: 0.25
102+
agentHeight: 1.75
103103
agentSlope: 45
104104
agentClimb: 0.6
105105
ledgeDropHeight: 0
106106
maxJumpAcrossDistance: 0
107107
minRegionArea: 2
108108
manualCellSize: 0
109-
cellSize: 0.16666667
109+
cellSize: 0.083333336
110110
manualTileSize: 0
111111
tileSize: 256
112112
accuratePlacement: 0
@@ -786,6 +786,52 @@ Transform:
786786
m_Father: {fileID: 0}
787787
m_RootOrder: 1
788788
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
789+
--- !u!1001 &915625527
790+
Prefab:
791+
m_ObjectHideFlags: 0
792+
serializedVersion: 2
793+
m_Modification:
794+
m_TransformParent: {fileID: 0}
795+
m_Modifications:
796+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
797+
propertyPath: m_LocalPosition.x
798+
value: 5000
799+
objectReference: {fileID: 0}
800+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
801+
propertyPath: m_LocalPosition.y
802+
value: 200
803+
objectReference: {fileID: 0}
804+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
805+
propertyPath: m_LocalPosition.z
806+
value: 0
807+
objectReference: {fileID: 0}
808+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
809+
propertyPath: m_LocalRotation.x
810+
value: 0
811+
objectReference: {fileID: 0}
812+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
813+
propertyPath: m_LocalRotation.y
814+
value: 0
815+
objectReference: {fileID: 0}
816+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
817+
propertyPath: m_LocalRotation.z
818+
value: 0
819+
objectReference: {fileID: 0}
820+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
821+
propertyPath: m_LocalRotation.w
822+
value: 1
823+
objectReference: {fileID: 0}
824+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
825+
propertyPath: m_RootOrder
826+
value: 14
827+
objectReference: {fileID: 0}
828+
- target: {fileID: 1620385508151754, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
829+
propertyPath: m_IsActive
830+
value: 0
831+
objectReference: {fileID: 0}
832+
m_RemovedComponents: []
833+
m_SourcePrefab: {fileID: 100100000, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
834+
m_IsPrefabAsset: 0
789835
--- !u!4 &946697438
790836
Transform:
791837
m_ObjectHideFlags: 0
@@ -1382,16 +1428,16 @@ MonoBehaviour:
13821428
edgeLeakFixup: 1
13831429
edgeToleranceNormal: 1
13841430
edgeTolerance: 1
1385-
shadowCascadeCount: 4
1431+
shadowCascadeCount: 3
13861432
shadowCascadeRatios:
13871433
- 0.05
1388-
- 0.15
1434+
- 0.2
13891435
- 0.3
13901436
shadowCascadeBorders:
13911437
- 0
13921438
- 0
1393-
- 0
13941439
- 0.2
1440+
- 0
13951441
shadowAlgorithm: 0
13961442
shadowVariant: 3
13971443
shadowPrecision: 0
@@ -1583,11 +1629,11 @@ Prefab:
15831629
m_Modifications:
15841630
- target: {fileID: 4593588597980260, guid: e4a3eb8590344604db1e998db676a211, type: 2}
15851631
propertyPath: m_LocalPosition.x
1586-
value: 1000
1632+
value: 5000
15871633
objectReference: {fileID: 0}
15881634
- target: {fileID: 4593588597980260, guid: e4a3eb8590344604db1e998db676a211, type: 2}
15891635
propertyPath: m_LocalPosition.y
1590-
value: 0
1636+
value: 200
15911637
objectReference: {fileID: 0}
15921638
- target: {fileID: 4593588597980260, guid: e4a3eb8590344604db1e998db676a211, type: 2}
15931639
propertyPath: m_LocalPosition.z
@@ -1659,7 +1705,7 @@ Prefab:
16591705
objectReference: {fileID: 0}
16601706
- target: {fileID: 4527984774241536, guid: a18c738cbcda9914591d9af24a618907, type: 2}
16611707
propertyPath: m_LocalPosition.y
1662-
value: 100
1708+
value: 200
16631709
objectReference: {fileID: 0}
16641710
- target: {fileID: 4527984774241536, guid: a18c738cbcda9914591d9af24a618907, type: 2}
16651711
propertyPath: m_LocalPosition.z
@@ -1685,6 +1731,11 @@ Prefab:
16851731
propertyPath: m_RootOrder
16861732
value: 12
16871733
objectReference: {fileID: 0}
1734+
- target: {fileID: 114510834623507516, guid: a18c738cbcda9914591d9af24a618907,
1735+
type: 2}
1736+
propertyPath: DefaultSimulatedPlayerCount
1737+
value: 10
1738+
objectReference: {fileID: 0}
16881739
m_RemovedComponents: []
16891740
m_SourcePrefab: {fileID: 100100000, guid: a18c738cbcda9914591d9af24a618907, type: 2}
16901741
m_IsPrefabAsset: 0
-6.86 MB
Binary file not shown.

workers/unity/Assets/Fps/Scenes/FPS-GameLogic.unity

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,6 @@ Prefab:
234234
propertyPath: m_RootOrder
235235
value: 2
236236
objectReference: {fileID: 0}
237-
- target: {fileID: 114219126016241412, guid: 75d29a39b8a626e42bdfc2e1d7af6746,
238-
type: 2}
239-
propertyPath: TargetFrameRate
240-
value: 30
241-
objectReference: {fileID: 0}
242237
m_RemovedComponents: []
243238
m_SourcePrefab: {fileID: 100100000, guid: 75d29a39b8a626e42bdfc2e1d7af6746, type: 2}
244239
m_IsPrefabAsset: 0

workers/unity/Assets/Fps/Scenes/FPS-SimulatedPlayerCoordinator.unity

Lines changed: 49 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -98,71 +98,21 @@ NavMeshSettings:
9898
m_BuildSettings:
9999
serializedVersion: 2
100100
agentTypeID: 0
101-
agentRadius: 0.5
102-
agentHeight: 2
101+
agentRadius: 0.25
102+
agentHeight: 1.75
103103
agentSlope: 45
104104
agentClimb: 0.6
105105
ledgeDropHeight: 0
106106
maxJumpAcrossDistance: 0
107107
minRegionArea: 2
108108
manualCellSize: 0
109-
cellSize: 0.16666667
109+
cellSize: 0.083333336
110110
manualTileSize: 0
111111
tileSize: 256
112112
accuratePlacement: 0
113113
debug:
114114
m_Flags: 0
115115
m_NavMeshData: {fileID: 23800000, guid: 3daa9e7d489573e4daebd2ed80d44aa6, type: 2}
116-
--- !u!1001 &143090536
117-
Prefab:
118-
m_ObjectHideFlags: 0
119-
serializedVersion: 2
120-
m_Modification:
121-
m_TransformParent: {fileID: 0}
122-
m_Modifications:
123-
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
124-
propertyPath: m_LocalPosition.x
125-
value: 0
126-
objectReference: {fileID: 0}
127-
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
128-
propertyPath: m_LocalPosition.y
129-
value: 0
130-
objectReference: {fileID: 0}
131-
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
132-
propertyPath: m_LocalPosition.z
133-
value: 0
134-
objectReference: {fileID: 0}
135-
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
136-
propertyPath: m_LocalRotation.x
137-
value: 0
138-
objectReference: {fileID: 0}
139-
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
140-
propertyPath: m_LocalRotation.y
141-
value: 0
142-
objectReference: {fileID: 0}
143-
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
144-
propertyPath: m_LocalRotation.z
145-
value: 0
146-
objectReference: {fileID: 0}
147-
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
148-
propertyPath: m_LocalRotation.w
149-
value: 1
150-
objectReference: {fileID: 0}
151-
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
152-
propertyPath: m_RootOrder
153-
value: 3
154-
objectReference: {fileID: 0}
155-
- target: {fileID: 1620385508151754, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
156-
propertyPath: m_StaticEditorFlags
157-
value: 4294967295
158-
objectReference: {fileID: 0}
159-
- target: {fileID: 1620385508151754, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
160-
propertyPath: m_IsActive
161-
value: 0
162-
objectReference: {fileID: 0}
163-
m_RemovedComponents: []
164-
m_SourcePrefab: {fileID: 100100000, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
165-
m_IsPrefabAsset: 0
166116
--- !u!1 &229366279
167117
GameObject:
168118
m_ObjectHideFlags: 0
@@ -284,11 +234,52 @@ Prefab:
284234
propertyPath: m_RootOrder
285235
value: 2
286236
objectReference: {fileID: 0}
287-
- target: {fileID: 114510834623507516, guid: a18c738cbcda9914591d9af24a618907,
288-
type: 2}
289-
propertyPath: TargetFrameRate
290-
value: 30
291-
objectReference: {fileID: 0}
292237
m_RemovedComponents: []
293238
m_SourcePrefab: {fileID: 100100000, guid: a18c738cbcda9914591d9af24a618907, type: 2}
294239
m_IsPrefabAsset: 0
240+
--- !u!1001 &1860465035
241+
Prefab:
242+
m_ObjectHideFlags: 0
243+
serializedVersion: 2
244+
m_Modification:
245+
m_TransformParent: {fileID: 0}
246+
m_Modifications:
247+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
248+
propertyPath: m_LocalPosition.x
249+
value: 0
250+
objectReference: {fileID: 0}
251+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
252+
propertyPath: m_LocalPosition.y
253+
value: 0
254+
objectReference: {fileID: 0}
255+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
256+
propertyPath: m_LocalPosition.z
257+
value: 0
258+
objectReference: {fileID: 0}
259+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
260+
propertyPath: m_LocalRotation.x
261+
value: 0
262+
objectReference: {fileID: 0}
263+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
264+
propertyPath: m_LocalRotation.y
265+
value: 0
266+
objectReference: {fileID: 0}
267+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
268+
propertyPath: m_LocalRotation.z
269+
value: 0
270+
objectReference: {fileID: 0}
271+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
272+
propertyPath: m_LocalRotation.w
273+
value: 1
274+
objectReference: {fileID: 0}
275+
- target: {fileID: 4977616286773460, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
276+
propertyPath: m_RootOrder
277+
value: 3
278+
objectReference: {fileID: 0}
279+
- target: {fileID: 1620385508151754, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
280+
propertyPath: m_IsActive
281+
value: 0
282+
objectReference: {fileID: 0}
283+
m_RemovedComponents: []
284+
m_SourcePrefab: {fileID: 100100000, guid: 1d177d0ca1e95c646a6a7b9b84364f9b, type: 2}
285+
m_IsPrefabAsset: 0
Binary file not shown.

workers/unity/Assets/Fps/Scripts/SetupLogic/SimulatedPlayerCoordinatorWorkerConnector.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public class SimulatedPlayerCoordinatorWorkerConnector : WorkerConnectorBase
1212
private const string FlagClientCount = "fps_simulated_players_per_coordinator";
1313
private const string FlagCreationInterval = "fps_simulated_players_creation_interval";
1414

15+
private static readonly Vector3 SmallWorldSize = new Vector3(148f, 100f, 148f);
16+
private static readonly Vector3 LargeWorldSize = new Vector3(1156f, 100f, 1156f);
17+
1518
public GameObject SimulatedPlayerWorkerConnector;
1619
public int DefaultSimulatedPlayerCount = 1;
1720
public int DefaultSimulatedPlayerCreationInterval = 5;
@@ -171,4 +174,10 @@ public void UnregisterLocalSimulatedPlayer(EntityId entityId, GameObject prefab)
171174
entityProxies[0].SetActive(true);
172175
}
173176
}
177+
178+
public Bounds GetWorldBounds()
179+
{
180+
var isSmall = Worker.Connection.GetWorkerFlag("world_size") == "small";
181+
return new Bounds(Worker.Origin, isSmall ? SmallWorldSize : LargeWorldSize);
182+
}
174183
}

0 commit comments

Comments
 (0)