Skip to content

Commit 7b23638

Browse files
added platform drop through
1 parent b502bd3 commit 7b23638

File tree

6 files changed

+333
-4
lines changed

6 files changed

+333
-4
lines changed

Assets/Input/PlayerInputActions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ public @PlayerInputActions()
145145
""isComposite"": false,
146146
""isPartOfComposite"": true
147147
},
148+
{
149+
""name"": ""Down"",
150+
""id"": ""08ffc039-448e-4ff3-a9cd-22f49415e537"",
151+
""path"": ""<Keyboard>/s"",
152+
""interactions"": """",
153+
""processors"": """",
154+
""groups"": "";Keyboard&Mouse"",
155+
""action"": ""Move"",
156+
""isComposite"": false,
157+
""isPartOfComposite"": true
158+
},
148159
{
149160
""name"": """",
150161
""id"": ""136cc420-588a-4b1e-8282-29fca40aa6d5"",

Assets/Input/PlayerInputActions.inputactions

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@
5959
"isComposite": false,
6060
"isPartOfComposite": true
6161
},
62+
{
63+
"name": "Down",
64+
"id": "08ffc039-448e-4ff3-a9cd-22f49415e537",
65+
"path": "<Keyboard>/s",
66+
"interactions": "",
67+
"processors": "",
68+
"groups": ";Keyboard&Mouse",
69+
"action": "Move",
70+
"isComposite": false,
71+
"isPartOfComposite": true
72+
},
6273
{
6374
"name": "",
6475
"id": "136cc420-588a-4b1e-8282-29fca40aa6d5",

Assets/Scenes/SampleScene.unity

Lines changed: 279 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,280 @@ Transform:
211211
m_Children: []
212212
m_Father: {fileID: 0}
213213
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
214+
--- !u!1 &1409261625
215+
GameObject:
216+
m_ObjectHideFlags: 0
217+
m_CorrespondingSourceObject: {fileID: 0}
218+
m_PrefabInstance: {fileID: 0}
219+
m_PrefabAsset: {fileID: 0}
220+
serializedVersion: 6
221+
m_Component:
222+
- component: {fileID: 1409261628}
223+
- component: {fileID: 1409261627}
224+
- component: {fileID: 1409261626}
225+
m_Layer: 7
226+
m_Name: Platform (3)
227+
m_TagString: Platform
228+
m_Icon: {fileID: 0}
229+
m_NavMeshLayer: 0
230+
m_StaticEditorFlags: 0
231+
m_IsActive: 1
232+
--- !u!61 &1409261626
233+
BoxCollider2D:
234+
m_ObjectHideFlags: 0
235+
m_CorrespondingSourceObject: {fileID: 0}
236+
m_PrefabInstance: {fileID: 0}
237+
m_PrefabAsset: {fileID: 0}
238+
m_GameObject: {fileID: 1409261625}
239+
m_Enabled: 1
240+
serializedVersion: 3
241+
m_Density: 1
242+
m_Material: {fileID: 0}
243+
m_IncludeLayers:
244+
serializedVersion: 2
245+
m_Bits: 0
246+
m_ExcludeLayers:
247+
serializedVersion: 2
248+
m_Bits: 0
249+
m_LayerOverridePriority: 0
250+
m_ForceSendLayers:
251+
serializedVersion: 2
252+
m_Bits: 4294967295
253+
m_ForceReceiveLayers:
254+
serializedVersion: 2
255+
m_Bits: 4294967295
256+
m_ContactCaptureLayers:
257+
serializedVersion: 2
258+
m_Bits: 4294967295
259+
m_CallbackLayers:
260+
serializedVersion: 2
261+
m_Bits: 4294967295
262+
m_IsTrigger: 0
263+
m_UsedByEffector: 0
264+
m_CompositeOperation: 0
265+
m_CompositeOrder: 0
266+
m_Offset: {x: 0, y: 0}
267+
m_SpriteTilingProperty:
268+
border: {x: 0, y: 0, z: 0, w: 0}
269+
pivot: {x: 0.5, y: 0.5}
270+
oldSize: {x: 1, y: 1}
271+
newSize: {x: 1, y: 1}
272+
adaptiveTilingThreshold: 0.5
273+
drawMode: 0
274+
adaptiveTiling: 0
275+
m_AutoTiling: 0
276+
m_Size: {x: 1, y: 1}
277+
m_EdgeRadius: 0
278+
--- !u!212 &1409261627
279+
SpriteRenderer:
280+
m_ObjectHideFlags: 0
281+
m_CorrespondingSourceObject: {fileID: 0}
282+
m_PrefabInstance: {fileID: 0}
283+
m_PrefabAsset: {fileID: 0}
284+
m_GameObject: {fileID: 1409261625}
285+
m_Enabled: 1
286+
m_CastShadows: 0
287+
m_ReceiveShadows: 0
288+
m_DynamicOccludee: 1
289+
m_StaticShadowCaster: 0
290+
m_MotionVectors: 1
291+
m_LightProbeUsage: 1
292+
m_ReflectionProbeUsage: 1
293+
m_RayTracingMode: 0
294+
m_RayTraceProcedural: 0
295+
m_RayTracingAccelStructBuildFlagsOverride: 0
296+
m_RayTracingAccelStructBuildFlags: 1
297+
m_SmallMeshCulling: 1
298+
m_ForceMeshLod: -1
299+
m_MeshLodSelectionBias: 0
300+
m_RenderingLayerMask: 1
301+
m_RendererPriority: 0
302+
m_Materials:
303+
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
304+
m_StaticBatchInfo:
305+
firstSubMesh: 0
306+
subMeshCount: 0
307+
m_StaticBatchRoot: {fileID: 0}
308+
m_ProbeAnchor: {fileID: 0}
309+
m_LightProbeVolumeOverride: {fileID: 0}
310+
m_ScaleInLightmap: 1
311+
m_ReceiveGI: 1
312+
m_PreserveUVs: 0
313+
m_IgnoreNormalsForChartDetection: 0
314+
m_ImportantGI: 0
315+
m_StitchLightmapSeams: 1
316+
m_SelectedEditorRenderState: 0
317+
m_MinimumChartSize: 4
318+
m_AutoUVMaxDistance: 0.5
319+
m_AutoUVMaxAngle: 89
320+
m_LightmapParameters: {fileID: 0}
321+
m_GlobalIlluminationMeshLod: 0
322+
m_SortingLayerID: 0
323+
m_SortingLayer: 0
324+
m_SortingOrder: 0
325+
m_Sprite: {fileID: -9092796987687139173, guid: bdd5a8b6a286442c9a32bd79d6982783, type: 3}
326+
m_Color: {r: 0.509434, g: 0.4559959, b: 0.3532396, a: 1}
327+
m_FlipX: 0
328+
m_FlipY: 0
329+
m_DrawMode: 0
330+
m_Size: {x: 1, y: 1}
331+
m_AdaptiveModeThreshold: 0.5
332+
m_SpriteTileMode: 0
333+
m_WasSpriteAssigned: 1
334+
m_MaskInteraction: 0
335+
m_SpriteSortPoint: 0
336+
--- !u!4 &1409261628
337+
Transform:
338+
m_ObjectHideFlags: 0
339+
m_CorrespondingSourceObject: {fileID: 0}
340+
m_PrefabInstance: {fileID: 0}
341+
m_PrefabAsset: {fileID: 0}
342+
m_GameObject: {fileID: 1409261625}
343+
serializedVersion: 2
344+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
345+
m_LocalPosition: {x: -5.25, y: 2.45, z: 0}
346+
m_LocalScale: {x: 4.78, y: 1, z: 1}
347+
m_ConstrainProportionsScale: 0
348+
m_Children: []
349+
m_Father: {fileID: 0}
350+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
351+
--- !u!1 &1447408134
352+
GameObject:
353+
m_ObjectHideFlags: 0
354+
m_CorrespondingSourceObject: {fileID: 0}
355+
m_PrefabInstance: {fileID: 0}
356+
m_PrefabAsset: {fileID: 0}
357+
serializedVersion: 6
358+
m_Component:
359+
- component: {fileID: 1447408137}
360+
- component: {fileID: 1447408136}
361+
- component: {fileID: 1447408135}
362+
m_Layer: 7
363+
m_Name: Platform (2)
364+
m_TagString: Platform
365+
m_Icon: {fileID: 0}
366+
m_NavMeshLayer: 0
367+
m_StaticEditorFlags: 0
368+
m_IsActive: 1
369+
--- !u!61 &1447408135
370+
BoxCollider2D:
371+
m_ObjectHideFlags: 0
372+
m_CorrespondingSourceObject: {fileID: 0}
373+
m_PrefabInstance: {fileID: 0}
374+
m_PrefabAsset: {fileID: 0}
375+
m_GameObject: {fileID: 1447408134}
376+
m_Enabled: 1
377+
serializedVersion: 3
378+
m_Density: 1
379+
m_Material: {fileID: 0}
380+
m_IncludeLayers:
381+
serializedVersion: 2
382+
m_Bits: 0
383+
m_ExcludeLayers:
384+
serializedVersion: 2
385+
m_Bits: 0
386+
m_LayerOverridePriority: 0
387+
m_ForceSendLayers:
388+
serializedVersion: 2
389+
m_Bits: 4294967295
390+
m_ForceReceiveLayers:
391+
serializedVersion: 2
392+
m_Bits: 4294967295
393+
m_ContactCaptureLayers:
394+
serializedVersion: 2
395+
m_Bits: 4294967295
396+
m_CallbackLayers:
397+
serializedVersion: 2
398+
m_Bits: 4294967295
399+
m_IsTrigger: 0
400+
m_UsedByEffector: 0
401+
m_CompositeOperation: 0
402+
m_CompositeOrder: 0
403+
m_Offset: {x: 0, y: 0}
404+
m_SpriteTilingProperty:
405+
border: {x: 0, y: 0, z: 0, w: 0}
406+
pivot: {x: 0.5, y: 0.5}
407+
oldSize: {x: 1, y: 1}
408+
newSize: {x: 1, y: 1}
409+
adaptiveTilingThreshold: 0.5
410+
drawMode: 0
411+
adaptiveTiling: 0
412+
m_AutoTiling: 0
413+
m_Size: {x: 1, y: 1}
414+
m_EdgeRadius: 0
415+
--- !u!212 &1447408136
416+
SpriteRenderer:
417+
m_ObjectHideFlags: 0
418+
m_CorrespondingSourceObject: {fileID: 0}
419+
m_PrefabInstance: {fileID: 0}
420+
m_PrefabAsset: {fileID: 0}
421+
m_GameObject: {fileID: 1447408134}
422+
m_Enabled: 1
423+
m_CastShadows: 0
424+
m_ReceiveShadows: 0
425+
m_DynamicOccludee: 1
426+
m_StaticShadowCaster: 0
427+
m_MotionVectors: 1
428+
m_LightProbeUsage: 1
429+
m_ReflectionProbeUsage: 1
430+
m_RayTracingMode: 0
431+
m_RayTraceProcedural: 0
432+
m_RayTracingAccelStructBuildFlagsOverride: 0
433+
m_RayTracingAccelStructBuildFlags: 1
434+
m_SmallMeshCulling: 1
435+
m_ForceMeshLod: -1
436+
m_MeshLodSelectionBias: 0
437+
m_RenderingLayerMask: 1
438+
m_RendererPriority: 0
439+
m_Materials:
440+
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
441+
m_StaticBatchInfo:
442+
firstSubMesh: 0
443+
subMeshCount: 0
444+
m_StaticBatchRoot: {fileID: 0}
445+
m_ProbeAnchor: {fileID: 0}
446+
m_LightProbeVolumeOverride: {fileID: 0}
447+
m_ScaleInLightmap: 1
448+
m_ReceiveGI: 1
449+
m_PreserveUVs: 0
450+
m_IgnoreNormalsForChartDetection: 0
451+
m_ImportantGI: 0
452+
m_StitchLightmapSeams: 1
453+
m_SelectedEditorRenderState: 0
454+
m_MinimumChartSize: 4
455+
m_AutoUVMaxDistance: 0.5
456+
m_AutoUVMaxAngle: 89
457+
m_LightmapParameters: {fileID: 0}
458+
m_GlobalIlluminationMeshLod: 0
459+
m_SortingLayerID: 0
460+
m_SortingLayer: 0
461+
m_SortingOrder: 0
462+
m_Sprite: {fileID: -9092796987687139173, guid: bdd5a8b6a286442c9a32bd79d6982783, type: 3}
463+
m_Color: {r: 0.509434, g: 0.4559959, b: 0.3532396, a: 1}
464+
m_FlipX: 0
465+
m_FlipY: 0
466+
m_DrawMode: 0
467+
m_Size: {x: 1, y: 1}
468+
m_AdaptiveModeThreshold: 0.5
469+
m_SpriteTileMode: 0
470+
m_WasSpriteAssigned: 1
471+
m_MaskInteraction: 0
472+
m_SpriteSortPoint: 0
473+
--- !u!4 &1447408137
474+
Transform:
475+
m_ObjectHideFlags: 0
476+
m_CorrespondingSourceObject: {fileID: 0}
477+
m_PrefabInstance: {fileID: 0}
478+
m_PrefabAsset: {fileID: 0}
479+
m_GameObject: {fileID: 1447408134}
480+
serializedVersion: 2
481+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
482+
m_LocalPosition: {x: 2.75, y: 1.2, z: 0}
483+
m_LocalScale: {x: 4.78, y: 1, z: 1}
484+
m_ConstrainProportionsScale: 0
485+
m_Children: []
486+
m_Father: {fileID: 0}
487+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
214488
--- !u!1 &1684821264
215489
GameObject:
216490
m_ObjectHideFlags: 0
@@ -222,9 +496,9 @@ GameObject:
222496
- component: {fileID: 1684821267}
223497
- component: {fileID: 1684821266}
224498
- component: {fileID: 1684821265}
225-
m_Layer: 6
499+
m_Layer: 7
226500
m_Name: Platform (1)
227-
m_TagString: Ground
501+
m_TagString: Platform
228502
m_Icon: {fileID: 0}
229503
m_NavMeshLayer: 0
230504
m_StaticEditorFlags: 0
@@ -669,7 +943,7 @@ MonoBehaviour:
669943
_jumpStrength: 6.5
670944
_groundMask:
671945
serializedVersion: 2
672-
m_Bits: 64
946+
m_Bits: 192
673947
--- !u!1660057539 &9223372036854775807
674948
SceneRoots:
675949
m_ObjectHideFlags: 0
@@ -678,3 +952,5 @@ SceneRoots:
678952
- {fileID: 1986650176}
679953
- {fileID: 1904460580}
680954
- {fileID: 1684821267}
955+
- {fileID: 1447408137}
956+
- {fileID: 1409261628}

Assets/Scripts/ControllerUtils.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
using UnityEngine;
12
using UnityEngine.InputSystem;
23
using UnityEngine.InputSystem.Controls;
34
using UnityEngine.InputSystem.Utilities;
45

56
public static class ControllerUtils {
67

8+
private const int PlayerLayer = 3;
9+
10+
public const int PlatformLayer = 7;
11+
12+
public static void IgnorePlatformCollision(bool ignore = true) {
13+
Physics2D.IgnoreLayerCollision(PlayerLayer, PlatformLayer, ignore);
14+
}
15+
716
public static ButtonControl[] InitializeButtonControls(ReadOnlyArray<InputControl> controls) {
817
ButtonControl[] buttonControls = new ButtonControl[controls.Count];
918

0 commit comments

Comments
 (0)