Added sliding

This commit is contained in:
2025-03-26 14:02:47 +00:00
parent 315327aac4
commit a3f5108ec7
6 changed files with 630 additions and 32 deletions

View File

@@ -0,0 +1,14 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!134 &13400000
PhysicMaterial:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: DefaultPhysicsMat
dynamicFriction: 0
staticFriction: 0
bounciness: 0
frictionCombine: 0
bounceCombine: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b0f3be75a3393cc40bd5a8ffa48458a3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 13400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -409,11 +409,21 @@ MonoBehaviour:
m_PlayerHeight: 2 m_PlayerHeight: 2
m_GroundMask: m_GroundMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 1024 m_Bits: 3072
m_SlopeMask:
serializedVersion: 2
m_Bits: 2048
m_SlideRequiredSpeed: 1
m_SlideScaler: 0.6
m_SlideDrag: 3
m_SlideSpeed: 10
m_JumpForce: 10 m_JumpForce: 10
m_JumpKey: 32 m_JumpKey: 32
m_SlideKey: 99
m_Body: {fileID: 1174770952} m_Body: {fileID: 1174770952}
m_Orientation: {fileID: 166780449} m_Orientation: {fileID: 166780449}
m_PlayerTransform: {fileID: 1174770951}
m_SpeedDisplay: {fileID: 140036474}
--- !u!1 &91982768 --- !u!1 &91982768
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -520,6 +530,85 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 2043134296} m_Father: {fileID: 2043134296}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &140036472
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 140036473}
- component: {fileID: 140036475}
- component: {fileID: 140036474}
m_Layer: 5
m_Name: Speed
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &140036473
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 140036472}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 236811070}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -79}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &140036474
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 140036472}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: New Text
--- !u!222 &140036475
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 140036472}
m_CullTransparentMesh: 1
--- !u!1 &165895537 --- !u!1 &165895537
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -869,6 +958,108 @@ MeshFilter:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 198569683} m_GameObject: {fileID: 198569683}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &236811066
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 236811070}
- component: {fileID: 236811069}
- component: {fileID: 236811068}
- component: {fileID: 236811067}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &236811067
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 236811066}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &236811068
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 236811066}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!223 &236811069
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 236811066}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 1
m_Camera: {fileID: 963194227}
m_PlaneDistance: 1
m_PixelPerfect: 1
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 1
m_AdditionalShaderChannelsFlag: 0
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &236811070
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 236811066}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 140036473}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &241925889 --- !u!1 &241925889
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -2565,6 +2756,112 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 2043134296} m_Father: {fileID: 2043134296}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &626624675
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 626624676}
- component: {fileID: 626624679}
- component: {fileID: 626624678}
- component: {fileID: 626624677}
m_Layer: 11
m_Name: Floor (50)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &626624676
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 626624675}
serializedVersion: 2
m_LocalRotation: {x: 0.38268343, y: 0, z: 0, w: 0.92387956}
m_LocalPosition: {x: 10, y: -17.76, z: 92.44}
m_LocalScale: {x: 1, y: 1, z: 10}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2043134296}
m_LocalEulerAnglesHint: {x: 45, y: 0, z: 0}
--- !u!64 &626624677
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 626624675}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 5
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &626624678
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 626624675}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: d68b4105a42c80a4ab173468c7256a55, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &626624679
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 626624675}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &705507993 --- !u!1 &705507993
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -4525,7 +4822,7 @@ Transform:
m_GameObject: {fileID: 963194225} m_GameObject: {fileID: 963194225}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 0} m_LocalPosition: {x: 0, y: 1.7, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@@ -4758,6 +5055,112 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 2043134296} m_Father: {fileID: 2043134296}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1033503149
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1033503150}
- component: {fileID: 1033503153}
- component: {fileID: 1033503152}
- component: {fileID: 1033503151}
m_Layer: 11
m_Name: Floor (49)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1033503150
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1033503149}
serializedVersion: 2
m_LocalRotation: {x: 0.38268343, y: 0, z: 0, w: 0.92387956}
m_LocalPosition: {x: 0, y: -17.66, z: 92.44}
m_LocalScale: {x: 1, y: 1, z: 5}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2043134296}
m_LocalEulerAnglesHint: {x: 45, y: 0, z: 0}
--- !u!64 &1033503151
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1033503149}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 5
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &1033503152
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1033503149}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: d68b4105a42c80a4ab173468c7256a55, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &1033503153
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1033503149}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1038274277 --- !u!1 &1038274277
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -5420,7 +5823,7 @@ Transform:
m_GameObject: {fileID: 1174770950} m_GameObject: {fileID: 1174770950}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 34.6, y: 0, z: 35.27}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
@@ -5437,7 +5840,7 @@ Rigidbody:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1174770950} m_GameObject: {fileID: 1174770950}
serializedVersion: 4 serializedVersion: 4
m_Mass: 1 m_Mass: 50
m_Drag: 0 m_Drag: 0
m_AngularDrag: 0.05 m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0} m_CenterOfMass: {x: 0, y: 0, z: 0}
@@ -7046,6 +7449,74 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 2043134296} m_Father: {fileID: 2043134296}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1971092433
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1971092436}
- component: {fileID: 1971092435}
- component: {fileID: 1971092434}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1971092434
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1971092433}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1971092435
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1971092433}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1971092436
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1971092433}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, 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!1 &1998218710 --- !u!1 &1998218710
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -7190,6 +7661,8 @@ Transform:
- {fileID: 543919275} - {fileID: 543919275}
- {fileID: 198569684} - {fileID: 198569684}
- {fileID: 801446441} - {fileID: 801446441}
- {fileID: 1033503150}
- {fileID: 626624676}
- {fileID: 1337688184} - {fileID: 1337688184}
- {fileID: 1038274278} - {fileID: 1038274278}
- {fileID: 1998218711} - {fileID: 1998218711}
@@ -7466,3 +7939,5 @@ SceneRoots:
- {fileID: 705507995} - {fileID: 705507995}
- {fileID: 1174770951} - {fileID: 1174770951}
- {fileID: 2043134296} - {fileID: 2043134296}
- {fileID: 236811070}
- {fileID: 1971092436}

View File

@@ -1,4 +1,6 @@
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
public class PlayerMovement : MonoBehaviour public class PlayerMovement : MonoBehaviour
{ {
@@ -10,6 +12,13 @@ public class PlayerMovement : MonoBehaviour
[Header("Ground Check")] [Header("Ground Check")]
[SerializeField] float m_PlayerHeight; [SerializeField] float m_PlayerHeight;
[SerializeField] LayerMask m_GroundMask; [SerializeField] LayerMask m_GroundMask;
[SerializeField] LayerMask m_SlopeMask;
[Header("Sliding Settings")]
[SerializeField] float m_SlideRequiredSpeed;
[SerializeField] float m_SlideScaler;
[SerializeField] float m_SlideDrag;
[SerializeField] float m_SlideSpeed;
[Header("Jump Settings")] [Header("Jump Settings")]
[SerializeField] float m_JumpForce; [SerializeField] float m_JumpForce;
@@ -21,6 +30,10 @@ public class PlayerMovement : MonoBehaviour
[Header("References")] [Header("References")]
[SerializeField] Rigidbody m_Body; [SerializeField] Rigidbody m_Body;
[SerializeField] Transform m_Orientation; [SerializeField] Transform m_Orientation;
[SerializeField] Transform m_PlayerTransform;
[Header("Debug Settings")]
[SerializeField] Text m_SpeedDisplay;
// //
Vector2 m_Input; Vector2 m_Input;
@@ -29,11 +42,16 @@ public class PlayerMovement : MonoBehaviour
Vector3 m_MoveDir; Vector3 m_MoveDir;
// Player state tracker // Player state tracker
bool m_Grounded; bool m_Grounded = false;
bool m_Sliding; bool m_OnSlope = false;
bool m_Sliding = false;
bool m_JumpKeyPressed; bool m_JumpKeyPressed = false;
bool m_SlidingKeyPressed; bool m_SlidingKeyPressed = false;
int m_TicksOfSlideBoostLeft = 0;
RaycastHit m_SlopeHit;
// Start is called before the first frame update // Start is called before the first frame update
private void Start() private void Start()
@@ -65,6 +83,12 @@ public class PlayerMovement : MonoBehaviour
m_Body.drag = m_GroundDrag; m_Body.drag = m_GroundDrag;
} }
// Applies sliding drag if sliding <- Very useful comment
if (m_Sliding)
{
m_Body.drag = m_SlideDrag;
}
// Else it applies the air drag to the player // Else it applies the air drag to the player
else else
{ {
@@ -75,24 +99,29 @@ public class PlayerMovement : MonoBehaviour
// Update is called once per frame // Update is called once per frame
private void Update() private void Update()
{ {
// Updates wether the player is touching the ground or not // Performs raycasts to see what the player is standing on
m_Grounded = Physics.Raycast(transform.position, Vector3.down, m_PlayerHeight * 0.5f + 0.2f, m_GroundMask); m_Grounded = Physics.Raycast(transform.position, Vector3.down, m_PlayerHeight * 0.5f + 0.3f, m_GroundMask);
m_OnSlope = Physics.Raycast(transform.position, Vector3.down, out m_SlopeHit, m_PlayerHeight * 0.5f + 0.3f, m_SlopeMask);
// Updates the state of the user input // Updates the state of the user input
UpdateInput(); UpdateInput();
// Applies drag to the player // Applies drag to the player
ApplyDrag(); ApplyDrag();
// Displays the speed of the player to the screen
m_SpeedDisplay.text = "Speed: " + m_Body.velocity.magnitude.ToString("0.00");
} }
// Updates basic movement and player jumping // Updates basic movement and player jumping
private void UpdatePlayerPosition() private void UpdatePlayerPosition()
{ {
// Calculates the movement direction // Sliding has its own movement code so the force being applied here is not needed
m_MoveDir = (m_Orientation.forward * m_Input.y) + (m_Orientation.right * m_Input.x); if (m_Sliding == false)
{
// Adds the force to the rigid body // Adds the force to the rigid body
m_Body.AddForce(m_MoveDir.normalized * m_MoveSpeed * 10.0f, ForceMode.Force); m_Body.AddForce(m_MoveDir.normalized * m_MoveSpeed * m_Body.mass * 10.0f, ForceMode.Force);
}
// Jumps if the jump key has been pressed // Jumps if the jump key has been pressed
if (m_JumpKeyPressed) if (m_JumpKeyPressed)
@@ -104,30 +133,70 @@ public class PlayerMovement : MonoBehaviour
// Handles the logic for starting to slide // Handles the logic for starting to slide
private void StartSlide() private void StartSlide()
{ } {
// Shrinks the player to give appearance of sliding
m_PlayerTransform.localScale = new Vector3(1.0f, m_SlideScaler, 1.0f);
// Applies a downward force as shrinking the player scale causes them to float
m_Body.AddForce(Vector3.down * m_Body.mass * 5.0f, ForceMode.Impulse);
// Applies a boost of a force at the beginning of a slide
m_TicksOfSlideBoostLeft = 10;
}
// Handles the logic for ending the slide // Handles the logic for ending the slide
private void StopSlide() private void StopSlide()
{ } {
// Grows the player back to normal scale
m_PlayerTransform.localScale = Vector3.one;
// Removes any of the slide boost that may be left
m_TicksOfSlideBoostLeft = 0;
}
// Function to manage the sliding of the player // Function to manage the sliding of the player
private void UpdateSlidingState() private void UpdateSlidingState()
{ {
// Checks wether the key state is valid for starting a slide // Works out wether the player's velocity is high enough to slide
if (m_SlidingKeyPressed == true && m_Sliding == false) Vector3 vel = m_Body.velocity;
{ bool canSlide =
m_Sliding = true; // Updates the sliding state !(
Mathf.Abs(vel.x) < m_SlideRequiredSpeed &&
StartSlide(); Mathf.Abs(vel.z) < m_SlideRequiredSpeed
} );
// Checks wether the key state is valid for starting a slide // Checks wether the key state is valid for starting a slide
else if (m_SlidingKeyPressed == false && m_Sliding == true) if (m_SlidingKeyPressed == true && m_Sliding == false)
{
// Checks player is moving in a direction
if (canSlide)
{
m_Sliding = true; // Updates the sliding state
StartSlide();
}
}
// Checks wether the player has stopped a slide or
// the player sliding if they are moving too slow
else if ((m_SlidingKeyPressed == false && m_Sliding == true) || (canSlide == false && m_Sliding == true))
{ {
m_Sliding = false; // Updates the sliding state m_Sliding = false; // Updates the sliding state
StopSlide(); StopSlide();
} }
// Applies a downward force during the player slide
if (m_Sliding)
{
m_Body.AddForce(Vector3.down * m_Body.mass * 5.0f, ForceMode.Force);
}
// If at the start of a slide provides a boost to the player or if the player is on a slope
if (m_TicksOfSlideBoostLeft != 0 || (m_OnSlope && m_Sliding))
{
m_Body.AddForce(m_MoveDir.normalized * m_SlideSpeed * m_Body.mass * 10, ForceMode.Force);
}
} }
// Function to make the player jump // Function to make the player jump
@@ -139,17 +208,43 @@ public class PlayerMovement : MonoBehaviour
if (m_Grounded || force) if (m_Grounded || force)
{ {
// Applies an upwards force simulating a jump // Applies an upwards force simulating a jump
m_Body.AddForce(transform.up * m_JumpForce, ForceMode.Impulse); m_Body.AddForce(transform.up * m_JumpForce * m_Body.mass, ForceMode.Impulse);
} }
} }
// Fixed Update is called once per physics update // Fixed Update is called once per physics update
private void FixedUpdate() private void FixedUpdate()
{ {
// Calculates the movement direction
m_MoveDir = (m_Orientation.forward * m_Input.y) + (m_Orientation.right * m_Input.x);
// Does additional calculations on the movement direction if on a slope
if (m_OnSlope)
{
m_MoveDir = Vector3.ProjectOnPlane(m_MoveDir, m_SlopeHit.normal).normalized;
m_Body.useGravity = false; // Disables gravity on slopes
}
else
{
m_Body.useGravity = true; // Renables gravity to stop errors
}
// Updates the player sliding state // Updates the player sliding state
UpdateSlidingState(); UpdateSlidingState();
// Updates the position of the player // Updates the position of the player
UpdatePlayerPosition(); UpdatePlayerPosition();
// Updates the counter for slide boost updates left
m_TicksOfSlideBoostLeft = (int)Mathf.Clamp(m_TicksOfSlideBoostLeft - 1, 0, Mathf.Infinity);
// Remvoes tiny ammounts of velocity because it was annoying me
Vector3 v = m_Body.velocity;
if (Mathf.Abs(v.x) < 0.1f) { v.x = 0.0f; }
if (Mathf.Abs(v.y) < 0.1f) { v.y = 0.0f; }
if (Mathf.Abs(v.z) < 0.1f) { v.z = 0.0f; }
m_Body.velocity = v;
} }
} }

View File

@@ -3,10 +3,11 @@
--- !u!55 &1 --- !u!55 &1
PhysicsManager: PhysicsManager:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 11 serializedVersion: 14
m_Gravity: {x: 0, y: -9.81, z: 0} m_Gravity: {x: 0, y: -20, z: 0}
m_DefaultMaterial: {fileID: 0} m_DefaultMaterial: {fileID: 13400000, guid: b0f3be75a3393cc40bd5a8ffa48458a3, type: 2}
m_BounceThreshold: 2 m_BounceThreshold: 2
m_DefaultMaxDepenetrationVelocity: 10
m_SleepThreshold: 0.005 m_SleepThreshold: 0.005
m_DefaultContactOffset: 0.01 m_DefaultContactOffset: 0.01
m_DefaultSolverIterations: 6 m_DefaultSolverIterations: 6
@@ -18,10 +19,12 @@ PhysicsManager:
m_ClothInterCollisionStiffness: 0 m_ClothInterCollisionStiffness: 0
m_ContactsGeneration: 1 m_ContactsGeneration: 1
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_AutoSimulation: 1 m_SimulationMode: 0
m_AutoSyncTransforms: 0 m_AutoSyncTransforms: 0
m_ReuseCollisionCallbacks: 1 m_ReuseCollisionCallbacks: 1
m_InvokeCollisionCallbacks: 1
m_ClothInterCollisionSettingsToggle: 0 m_ClothInterCollisionSettingsToggle: 0
m_ClothGravity: {x: 0, y: -9.81, z: 0}
m_ContactPairsMode: 0 m_ContactPairsMode: 0
m_BroadphaseType: 0 m_BroadphaseType: 0
m_WorldBounds: m_WorldBounds:
@@ -31,4 +34,7 @@ PhysicsManager:
m_FrictionType: 0 m_FrictionType: 0
m_EnableEnhancedDeterminism: 0 m_EnableEnhancedDeterminism: 0
m_EnableUnifiedHeightmaps: 1 m_EnableUnifiedHeightmaps: 1
m_DefaultMaxAngluarSpeed: 7 m_ImprovedPatchFriction: 0
m_SolverType: 0
m_DefaultMaxAngularSpeed: 7
m_FastMotionThreshold: 3.4028235e+38

View File

@@ -16,7 +16,7 @@ TagManager:
- -
- -
- Ground - Ground
- - Slope
- -
- -
- -