рефакторю управление игроком

This commit is contained in:
vladislav 2026-09-22 20:51:51 +03:00
parent 2746850727
commit f632508497
18 changed files with 1044 additions and 66 deletions

139
Assets/New Material.mat Normal file
View File

@ -0,0 +1,139 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: New Material
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap:
RenderType: Opaque
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _ScreenSpaceReflections: 1
- _ScreenSpaceReflectionsContributeTransparent: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _XRMotionVectorsPass: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0, g: 0.9248903, b: 1, a: 1}
- _Color: {r: 0, g: 0.9248903, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!114 &4052475867165565193
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
version: 10

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 56b30cdacaf22092d8de30ad2434986c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1011,6 +1011,134 @@ PrefabInstance:
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a08f59b910c8446a681d1932a4ffe269, type: 3} m_SourcePrefab: {fileID: 100100000, guid: a08f59b910c8446a681d1932a4ffe269, type: 3}
--- !u!1 &47866425
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 47866430}
- component: {fileID: 47866429}
- component: {fileID: 47866428}
- component: {fileID: 47866427}
- component: {fileID: 47866426}
m_Layer: 0
m_Name: Capsule (4)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &47866426
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 47866425}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d7a447e6bc04aec8bf4805369d10a05, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::TargetDummy
health: 100
--- !u!136 &47866427
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 47866425}
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: 2
m_Radius: 0.5
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &47866428
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 47866425}
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_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 56b30cdacaf22092d8de30ad2434986c, 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_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_MaskInteraction: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &47866429
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 47866425}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &47866430
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 47866425}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 29.48676, y: 0.73, z: 8.52}
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 &56642862 --- !u!1 &56642862
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -11761,12 +11889,12 @@ GameObject:
- component: {fileID: 642913451} - component: {fileID: 642913451}
- component: {fileID: 642913450} - component: {fileID: 642913450}
m_Layer: 5 m_Layer: 5
m_Name: Image m_Name: Image(ColorChanging)
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!224 &642913449 --- !u!224 &642913449
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -11793,7 +11921,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 642913448} m_GameObject: {fileID: 642913448}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8cf1795fc21943f48878d4a8f1b0a792, type: 3} m_Script: {fileID: 11500000, guid: 8cf1795fc21943f48878d4a8f1b0a792, type: 3}
m_Name: m_Name:
@ -11801,6 +11929,7 @@ MonoBehaviour:
target: {fileID: 642913448} target: {fileID: 642913448}
TimeForChange: 100 TimeForChange: 100
isStarted: 0 isStarted: 0
isLooped: 0
--- !u!114 &642913451 --- !u!114 &642913451
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -12023,6 +12152,134 @@ Transform:
m_CorrespondingSourceObject: {fileID: 1672666446545052606, guid: 51510de34f82041149d25090ec962e10, type: 3} m_CorrespondingSourceObject: {fileID: 1672666446545052606, guid: 51510de34f82041149d25090ec962e10, type: 3}
m_PrefabInstance: {fileID: 659322491} m_PrefabInstance: {fileID: 659322491}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1 &659897083
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 659897088}
- component: {fileID: 659897087}
- component: {fileID: 659897086}
- component: {fileID: 659897085}
- component: {fileID: 659897084}
m_Layer: 0
m_Name: Capsule (3)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &659897084
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 659897083}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d7a447e6bc04aec8bf4805369d10a05, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::TargetDummy
health: 100
--- !u!136 &659897085
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 659897083}
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: 2
m_Radius: 0.5
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &659897086
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 659897083}
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_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 56b30cdacaf22092d8de30ad2434986c, 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_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_MaskInteraction: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &659897087
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 659897083}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &659897088
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 659897083}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 29.48676, y: 0.73, z: 14.35}
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!1001 &660946063 --- !u!1001 &660946063
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -35649,6 +35906,134 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.RectMask2D m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.RectMask2D
m_Padding: {x: -8, y: -5, z: -8, w: -5} m_Padding: {x: -8, y: -5, z: -8, w: -5}
m_Softness: {x: 0, y: 0} m_Softness: {x: 0, y: 0}
--- !u!1 &1903221282
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1903221286}
- component: {fileID: 1903221285}
- component: {fileID: 1903221284}
- component: {fileID: 1903221283}
- component: {fileID: 1903221287}
m_Layer: 0
m_Name: Capsule (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!136 &1903221283
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1903221282}
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: 2
m_Radius: 0.5
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &1903221284
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1903221282}
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_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 56b30cdacaf22092d8de30ad2434986c, 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_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_MaskInteraction: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &1903221285
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1903221282}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1903221286
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1903221282}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 29.48676, y: 0.73, z: 22.71796}
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 &1903221287
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1903221282}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d7a447e6bc04aec8bf4805369d10a05, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::TargetDummy
health: 100
--- !u!1001 &1906484309 --- !u!1001 &1906484309
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -37607,6 +37992,134 @@ PrefabInstance:
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 81044204068d943dd8e46160655d2108, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 81044204068d943dd8e46160655d2108, type: 3}
--- !u!1 &2002573462
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2002573467}
- component: {fileID: 2002573466}
- component: {fileID: 2002573465}
- component: {fileID: 2002573464}
- component: {fileID: 2002573463}
m_Layer: 0
m_Name: Capsule (2)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2002573463
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2002573462}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d7a447e6bc04aec8bf4805369d10a05, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::TargetDummy
health: 100
--- !u!136 &2002573464
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2002573462}
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: 2
m_Radius: 0.5
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &2002573465
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2002573462}
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_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 56b30cdacaf22092d8de30ad2434986c, 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_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_MaskInteraction: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &2002573466
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2002573462}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &2002573467
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2002573462}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 29.48676, y: 0.73, z: 19.07}
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!1001 &2003839527 --- !u!1001 &2003839527
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -42465,6 +42978,17 @@ MonoBehaviour:
cameraPosition: {fileID: 5685763764745351606} cameraPosition: {fileID: 5685763764745351606}
mouseSensitivity: 0.1 mouseSensitivity: 0.1
maxLookAngle: 80 maxLookAngle: 80
damage: 25
fireRate: 0.12
weaponRange: 100
hitLayers:
serializedVersion: 2
m_Bits: 4294967295
isAutomatic: 1
recoilKick: 1.2
muzzleFlash: {fileID: 0}
impactPrefab: {fileID: 0}
shootSound: {fileID: 0}
moveSpeed: 10 moveSpeed: 10
sprintSpeed: 18 sprintSpeed: 18
crouchSpeed: 5 crouchSpeed: 5
@ -44451,3 +44975,7 @@ SceneRoots:
- {fileID: 1269659453} - {fileID: 1269659453}
- {fileID: 11872312} - {fileID: 11872312}
- {fileID: 217181662} - {fileID: 217181662}
- {fileID: 1903221286}
- {fileID: 2002573467}
- {fileID: 659897088}
- {fileID: 47866430}

View File

@ -151,6 +151,16 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable
""interactions"": """", ""interactions"": """",
""initialStateCheck"": false, ""initialStateCheck"": false,
""priority"": 0 ""priority"": 0
},
{
""name"": ""Attack"",
""type"": ""Button"",
""id"": ""68813cd9-75a1-4031-b390-a01395eef173"",
""expectedControlType"": """",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false,
""priority"": 0
} }
], ],
""bindings"": [ ""bindings"": [
@ -263,6 +273,17 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable
""action"": ""EnterMenu"", ""action"": ""EnterMenu"",
""isComposite"": false, ""isComposite"": false,
""isPartOfComposite"": false ""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""7b7eeb94-7e87-4db8-a3e0-0b75c77293b9"",
""path"": ""<Mouse>/leftButton"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Attack"",
""isComposite"": false,
""isPartOfComposite"": false
} }
] ]
} }
@ -277,6 +298,7 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable
m_Player_Crouch = m_Player.FindAction("Crouch", throwIfNotFound: true); m_Player_Crouch = m_Player.FindAction("Crouch", throwIfNotFound: true);
m_Player_Look = m_Player.FindAction("Look", throwIfNotFound: true); m_Player_Look = m_Player.FindAction("Look", throwIfNotFound: true);
m_Player_EnterMenu = m_Player.FindAction("EnterMenu", throwIfNotFound: true); m_Player_EnterMenu = m_Player.FindAction("EnterMenu", throwIfNotFound: true);
m_Player_Attack = m_Player.FindAction("Attack", throwIfNotFound: true);
} }
~@PlayerControls() ~@PlayerControls()
@ -363,6 +385,7 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable
private readonly InputAction m_Player_Crouch; private readonly InputAction m_Player_Crouch;
private readonly InputAction m_Player_Look; private readonly InputAction m_Player_Look;
private readonly InputAction m_Player_EnterMenu; private readonly InputAction m_Player_EnterMenu;
private readonly InputAction m_Player_Attack;
/// <summary> /// <summary>
/// Provides access to input actions defined in input action map "Player". /// Provides access to input actions defined in input action map "Player".
/// </summary> /// </summary>
@ -399,6 +422,10 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable
/// </summary> /// </summary>
public InputAction @EnterMenu => m_Wrapper.m_Player_EnterMenu; public InputAction @EnterMenu => m_Wrapper.m_Player_EnterMenu;
/// <summary> /// <summary>
/// Provides access to the underlying input action "Player/Attack".
/// </summary>
public InputAction @Attack => m_Wrapper.m_Player_Attack;
/// <summary>
/// Provides access to the underlying input action map instance. /// Provides access to the underlying input action map instance.
/// </summary> /// </summary>
public InputActionMap Get() { return m_Wrapper.m_Player; } public InputActionMap Get() { return m_Wrapper.m_Player; }
@ -442,6 +469,9 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable
@EnterMenu.started += instance.OnEnterMenu; @EnterMenu.started += instance.OnEnterMenu;
@EnterMenu.performed += instance.OnEnterMenu; @EnterMenu.performed += instance.OnEnterMenu;
@EnterMenu.canceled += instance.OnEnterMenu; @EnterMenu.canceled += instance.OnEnterMenu;
@Attack.started += instance.OnAttack;
@Attack.performed += instance.OnAttack;
@Attack.canceled += instance.OnAttack;
} }
/// <summary> /// <summary>
@ -471,6 +501,9 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable
@EnterMenu.started -= instance.OnEnterMenu; @EnterMenu.started -= instance.OnEnterMenu;
@EnterMenu.performed -= instance.OnEnterMenu; @EnterMenu.performed -= instance.OnEnterMenu;
@EnterMenu.canceled -= instance.OnEnterMenu; @EnterMenu.canceled -= instance.OnEnterMenu;
@Attack.started -= instance.OnAttack;
@Attack.performed -= instance.OnAttack;
@Attack.canceled -= instance.OnAttack;
} }
/// <summary> /// <summary>
@ -553,5 +586,12 @@ public partial class @PlayerControls: IInputActionCollection2, IDisposable
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" /> /// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" /> /// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnEnterMenu(InputAction.CallbackContext context); void OnEnterMenu(InputAction.CallbackContext context);
/// <summary>
/// Method invoked when associated input action "Attack" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
/// </summary>
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnAttack(InputAction.CallbackContext context);
} }
} }

View File

@ -65,6 +65,16 @@
"interactions": "", "interactions": "",
"initialStateCheck": false, "initialStateCheck": false,
"priority": 0 "priority": 0
},
{
"name": "Attack",
"type": "Button",
"id": "68813cd9-75a1-4031-b390-a01395eef173",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false,
"priority": 0
} }
], ],
"bindings": [ "bindings": [
@ -177,6 +187,17 @@
"action": "EnterMenu", "action": "EnterMenu",
"isComposite": false, "isComposite": false,
"isPartOfComposite": false "isPartOfComposite": false
},
{
"name": "",
"id": "7b7eeb94-7e87-4db8-a3e0-0b75c77293b9",
"path": "<Mouse>/leftButton",
"interactions": "",
"processors": "",
"groups": "",
"action": "Attack",
"isComposite": false,
"isPartOfComposite": false
} }
] ]
} }

View File

@ -23,15 +23,7 @@ namespace _Project.Scripts
} }
void Update() void Update()
{ {
if (isStarted && !isWorking && isLooped)
{
while (isLooped)
{
isStarted = false;
isWorking = true;
coroutine = StartCoroutine(ColorCoroutine());
}
}
if (isStarted && !isWorking) if (isStarted && !isWorking)
{ {
isStarted = false; isStarted = false;
@ -44,23 +36,30 @@ namespace _Project.Scripts
IEnumerator ColorCoroutine() IEnumerator ColorCoroutine()
{ {
float elapsedTime = 0f; do
while (elapsedTime < TimeForChange)
{ {
image.color = Color.Lerp(prevColor, Color.clear, elapsedTime / TimeForChange); float elapsedTime = 0f;
elapsedTime += Time.deltaTime;
yield return null; while (elapsedTime < TimeForChange)
} {
elapsedTime = 0f; image.color = Color.Lerp(prevColor, Color.clear, elapsedTime / TimeForChange);
while (elapsedTime < TimeForChange) elapsedTime += Time.deltaTime;
{ yield return null;
elapsedTime += Time.deltaTime; }
image.color = Color.Lerp( Color.clear,prevColor, elapsedTime / TimeForChange);
yield return null; elapsedTime = 0f;
} while (elapsedTime < TimeForChange)
coroutine = null; {
isWorking = false; elapsedTime += Time.deltaTime;
image.color = Color.Lerp(Color.clear, prevColor, elapsedTime / TimeForChange);
yield return null;
}
coroutine = null;
isWorking = false;
} while (isLooped);
} }
} }
} }

View File

@ -0,0 +1,17 @@
using UnityEngine;
public class TargetDummy : MonoBehaviour, IDamageable
{
[SerializeField] private float health = 100f;
public void TakeDamage(float amount)
{
health -= amount;
Debug.Log($"Враг получил {amount} урона. Осталось HP: {health}");
if (health <= 0)
{
Destroy(gameObject);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2d7a447e6bc04aec8bf4805369d10a05
timeCreated: 1790086695

View File

@ -0,0 +1,24 @@
using _Project.Scripts.PlayerUtils;
using _Project.Scripts.Utilities;
namespace _Project.Scripts
{
public class Player : MonoSingleton<Player>
{
private PlayerMovement movement;
public PlayerControls controls { get; set; }
void Awake()
{
base.Awake();
movement = GetComponent<PlayerMovement>();
controls = GetComponent<PlayerControls>();
}
void Update()
{
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 75b0375d82064442a50d4b6cf42048bb
timeCreated: 1790082561

View File

@ -10,32 +10,36 @@ public class PlayerController : MonoBehaviour
[SerializeField] private float mouseSensitivity = 0.1f; [SerializeField] private float mouseSensitivity = 0.1f;
[SerializeField] private float maxLookAngle = 80f; [SerializeField] private float maxLookAngle = 80f;
[Header("Оружие и Стрельба (Hitscan)")]
[SerializeField] private float damage = 25f;
[Tooltip("Задержка между выстрелами в секундах (0.1 = 600 выстр/мин)")]
[SerializeField] private float fireRate = 0.12f;
[SerializeField] private float weaponRange = 100f;
[SerializeField] private LayerMask hitLayers = ~0; // По кому попадаем (по умолчанию всё)
[SerializeField] private bool isAutomatic = true;
[Tooltip("Сила вертикального пинка камеры при выстреле")]
[SerializeField] private float recoilKick = 1.2f;
[SerializeField] private ParticleSystem muzzleFlash;
[SerializeField] private GameObject impactPrefab; // Префаб искр / дырки от пули
[SerializeField] private AudioClip shootSound;
[Header("Скорости передвижения (м/с)")] [Header("Скорости передвижения (м/с)")]
[SerializeField] private float moveSpeed = 6.5f; // Обычный бег (~250 u/s) [SerializeField] private float moveSpeed = 6.5f;
[SerializeField] private float sprintSpeed = 9.5f; // Спринт (~360 u/s) [SerializeField] private float sprintSpeed = 9.5f;
[SerializeField] private float crouchSpeed = 3f; [SerializeField] private float crouchSpeed = 3f;
[Header("Параметры Подката (Slide)")] [Header("Параметры Подката (Slide)")]
[Tooltip("Начальная взрывная скорость подката")] [SerializeField] private float slideInitialSpeed = 15f;
[SerializeField] private float slideInitialSpeed = 15f; // (~580 u/s)
[Tooltip("Длительность скольжения в секундах")]
[SerializeField] private float slideDuration = 0.85f; [SerializeField] private float slideDuration = 0.85f;
[Tooltip("Трение коленей при подкате")]
[SerializeField] private float slideFriction = 2.8f; [SerializeField] private float slideFriction = 2.8f;
[Tooltip("Наклон камеры набок при подкате (градусы)")]
[SerializeField] private float slideCameraTiltAngle = 4f; [SerializeField] private float slideCameraTiltAngle = 4f;
[SerializeField] private float slideCooldown = 0.35f; [SerializeField] private float slideCooldown = 0.35f;
[Header("Физика CS / Source (Bunnyhop & Strafe)")] [Header("Физика CS / Source (Bunnyhop & Strafe)")]
[Tooltip("Трение на земле (гасит скорость, если не успели прыгнуть вовремя)")]
[SerializeField] private float groundFriction = 5f; [SerializeField] private float groundFriction = 5f;
[Tooltip("Ускорение на земле")]
[SerializeField] private float groundAcceleration = 10f; [SerializeField] private float groundAcceleration = 10f;
[Tooltip("Сила набора скорости в воздухе при стрейфах (sv_airaccelerate)")]
[SerializeField] private float airAcceleration = 80f; [SerializeField] private float airAcceleration = 80f;
[Tooltip("Лимит добавления скорости в воздухе")]
[SerializeField] private float airCap = 2.0f; [SerializeField] private float airCap = 2.0f;
[Tooltip("Показывать спидометр на экране")]
[SerializeField] private bool showSpeedometer = true; [SerializeField] private bool showSpeedometer = true;
[Header("Гравитация и Прыжок")] [Header("Гравитация и Прыжок")]
@ -44,7 +48,6 @@ public class PlayerController : MonoBehaviour
[SerializeField] private float fallMultiplier = 1.8f; [SerializeField] private float fallMultiplier = 1.8f;
[SerializeField] private LayerMask groundLayer; [SerializeField] private LayerMask groundLayer;
[SerializeField] private float groundCheckDistance = 0.12f; [SerializeField] private float groundCheckDistance = 0.12f;
[Tooltip("Буфер прыжка (время поблажки для колесика мыши)")]
[SerializeField] private float jumpBufferTime = 0.12f; [SerializeField] private float jumpBufferTime = 0.12f;
[Header("Параметры приседания")] [Header("Параметры приседания")]
@ -79,6 +82,10 @@ public class PlayerController : MonoBehaviour
private Vector3 horizontalVelocity = Vector3.zero; private Vector3 horizontalVelocity = Vector3.zero;
private float verticalVelocity = 0f; private float verticalVelocity = 0f;
// Стрельба
private float shootTimer = 0f;
private bool isShootingInput = false;
// Камера // Камера
private float cameraPitch = 0f; private float cameraPitch = 0f;
private float yRotation = 0f; private float yRotation = 0f;
@ -139,8 +146,12 @@ public class PlayerController : MonoBehaviour
controls.Player.Crouch.started += ctx => OnCrouchPressed(); controls.Player.Crouch.started += ctx => OnCrouchPressed();
controls.Player.Crouch.canceled += ctx => OnCrouchReleased(); controls.Player.Crouch.canceled += ctx => OnCrouchReleased();
// Прыжок на Пробел (через буфер) // Прыжок на Пробел
controls.Player.Jump.performed += ctx => QueueJump(); controls.Player.Jump.performed += ctx => QueueJump();
// Стрельба (ЛКМ) через Input Actions
controls.Player.Attack.started += ctx => isShootingInput = true;
controls.Player.Attack.canceled += ctx => isShootingInput = false;
} }
private void OnEnable() => controls.Player.Enable(); private void OnEnable() => controls.Player.Enable();
@ -150,25 +161,24 @@ public class PlayerController : MonoBehaviour
{ {
moveInput = controls.Player.Move.ReadValue<Vector2>(); moveInput = controls.Player.Move.ReadValue<Vector2>();
lookInput = controls.Player.Look.ReadValue<Vector2>(); lookInput = controls.Player.Look.ReadValue<Vector2>();
// Таймер буфера прыжка
if (jumpBufferTimer > 0f) if (jumpBufferTimer > 0f)
jumpBufferTimer -= Time.deltaTime; jumpBufferTimer -= Time.deltaTime;
if (slideCooldownTimer > 0f) if (slideCooldownTimer > 0f)
slideCooldownTimer -= Time.deltaTime; slideCooldownTimer -= Time.deltaTime;
// ПРЫЖОК НА КОЛЁСИКО МЫШИ (вниз и вверх) // Прыжок на колесико мыши
if (Mouse.current != null) if (Mouse.current != null)
{ {
float scrollY = Mouse.current.scroll.y.ReadValue(); float scrollY = Mouse.current.scroll.y.ReadValue();
if (Mathf.Abs(scrollY) > 0.1f) // Крутанули вниз или вверх if (Mathf.Abs(scrollY) > 0.1f)
{ {
QueueJump(); QueueJump();
} }
} }
HandleShooting();
HandleMouseLook(); HandleMouseLook();
HandleCameraAndBobbing(); HandleCameraAndBobbing();
} }
@ -178,21 +188,74 @@ public class PlayerController : MonoBehaviour
CheckGrounded(); CheckGrounded();
CalculateCustomGravity(); CalculateCustomGravity();
// Проверяем прыжок/бхоп (если зажат пробел или крутанули колесо)
if (jumpBufferTimer > 0f && isGrounded) if (jumpBufferTimer > 0f && isGrounded)
{ {
ExecuteJump(); ExecuteJump();
} }
// Движение (земля, воздух, подкат)
ApplyMovement(); ApplyMovement();
// Применяем скорость в Rigidbody
rb.linearVelocity = new Vector3(horizontalVelocity.x, verticalVelocity, horizontalVelocity.z); rb.linearVelocity = new Vector3(horizontalVelocity.x, verticalVelocity, horizontalVelocity.z);
wasGrounded = isGrounded; wasGrounded = isGrounded;
} }
#region Механика Стрельбы (Weapons)
private void HandleShooting()
{
if (shootTimer > 0f)
shootTimer -= Time.deltaTime;
// Проверяем ввод: либо через Input Action, либо напрямую через Mouse (для надежности)
bool shootPressed = isShootingInput || (Mouse.current != null && (isAutomatic ? Mouse.current.leftButton.isPressed : Mouse.current.leftButton.wasPressedThisFrame));
if (shootPressed && shootTimer <= 0f)
{
Shoot();
}
}
private void Shoot()
{
shootTimer = fireRate;
// 1. Звук выстрела
if (shootSound != null)
audioSource.PlayOneShot(shootSound, 0.8f);
// 2. Вспышка из ствола
if (muzzleFlash != null)
muzzleFlash.Play();
// 3. Отдача (вздергивание прицела вверх)
cameraPitch -= recoilKick;
// 4. Рейкаст строго из центра камеры
Ray ray = new Ray(cameraPosition.position, cameraPosition.forward);
if (Physics.Raycast(ray, out RaycastHit hit, weaponRange, hitLayers, QueryTriggerInteraction.Ignore))
{
// Нанесение урона врагу
if (hit.collider.TryGetComponent<IDamageable>(out var damageable))
{
damageable.TakeDamage(damage);
}
// Если попали в физ. объект — отталкиваем его импульсом пули
else if (hit.rigidbody != null)
{
hit.rigidbody.AddForceAtPosition(-hit.normal * (damage * 10f), hit.point, ForceMode.Impulse);
}
// Спавн декали / эффекта удара пули
if (impactPrefab != null)
{
GameObject impact = Instantiate(impactPrefab, hit.point + (hit.normal * 0.001f), Quaternion.LookRotation(hit.normal));
Destroy(impact, 3f);
}
}
}
#endregion
private void QueueJump() private void QueueJump()
{ {
jumpBufferTimer = jumpBufferTime; jumpBufferTimer = jumpBufferTime;
@ -202,7 +265,6 @@ public class PlayerController : MonoBehaviour
private void OnCrouchPressed() private void OnCrouchPressed()
{ {
// Подкат: если бежим вперед, на земле и кулдаун прошел
if (isSprinting && isGrounded && moveInput.y > 0.2f && slideCooldownTimer <= 0f) if (isSprinting && isGrounded && moveInput.y > 0.2f && slideCooldownTimer <= 0f)
{ {
StartSlide(); StartSlide();
@ -228,7 +290,6 @@ public class PlayerController : MonoBehaviour
slideTimer = slideDuration; slideTimer = slideDuration;
slideCurrentSpeed = slideInitialSpeed; slideCurrentSpeed = slideInitialSpeed;
// Направление подката берется от взгляда и нажатых клавиш
slideDirection = (transform.forward * moveInput.y + transform.right * moveInput.x).normalized; slideDirection = (transform.forward * moveInput.y + transform.right * moveInput.x).normalized;
if (slideDirection.sqrMagnitude < 0.01f) slideDirection = transform.forward; if (slideDirection.sqrMagnitude < 0.01f) slideDirection = transform.forward;
@ -248,13 +309,11 @@ public class PlayerController : MonoBehaviour
private void ApplyMovement() private void ApplyMovement()
{ {
// 1. ПОДКАT
if (isSliding) if (isSliding)
{ {
slideCurrentSpeed = Mathf.Lerp(slideCurrentSpeed, crouchSpeed, Time.fixedDeltaTime * slideFriction); slideCurrentSpeed = Mathf.Lerp(slideCurrentSpeed, crouchSpeed, Time.fixedDeltaTime * slideFriction);
slideTimer -= Time.fixedDeltaTime; slideTimer -= Time.fixedDeltaTime;
// Небольшое подруливание в подкате
Vector3 steerDir = (transform.forward * moveInput.y + transform.right * moveInput.x).normalized; Vector3 steerDir = (transform.forward * moveInput.y + transform.right * moveInput.x).normalized;
if (steerDir.sqrMagnitude > 0.01f) if (steerDir.sqrMagnitude > 0.01f)
slideDirection = Vector3.Slerp(slideDirection, steerDir, Time.fixedDeltaTime * 2.5f); slideDirection = Vector3.Slerp(slideDirection, steerDir, Time.fixedDeltaTime * 2.5f);
@ -269,17 +328,14 @@ public class PlayerController : MonoBehaviour
return; return;
} }
// Вектор желаемого направления (WishDir)
Vector3 wishDir = (transform.forward * moveInput.y + transform.right * moveInput.x); Vector3 wishDir = (transform.forward * moveInput.y + transform.right * moveInput.x);
wishDir.y = 0f; wishDir.y = 0f;
wishDir.Normalize(); wishDir.Normalize();
float targetSpeed = isCrouching ? crouchSpeed : (isSprinting ? sprintSpeed : moveSpeed); float targetSpeed = isCrouching ? crouchSpeed : (isSprinting ? sprintSpeed : moveSpeed);
// 2. НА ЗЕМЛЕ
if (isGrounded) if (isGrounded)
{ {
// Если игрок делает баннихоп прямо сейчас — НЕ применяем трение пола!
if (jumpBufferTimer <= 0f) if (jumpBufferTimer <= 0f)
{ {
ApplyGroundFriction(); ApplyGroundFriction();
@ -287,7 +343,6 @@ public class PlayerController : MonoBehaviour
Accelerate(wishDir, targetSpeed, groundAcceleration); Accelerate(wishDir, targetSpeed, groundAcceleration);
} }
// 3. В ВОЗДУХЕ (Формула CS AirAccelerate)
else else
{ {
AirAccelerate(wishDir, targetSpeed, airAcceleration, airCap); AirAccelerate(wishDir, targetSpeed, airAcceleration, airCap);
@ -332,13 +387,11 @@ public class PlayerController : MonoBehaviour
float accelSpeed = accel * wishSpeed * Time.fixedDeltaTime; float accelSpeed = accel * wishSpeed * Time.fixedDeltaTime;
accelSpeed = Mathf.Min(accelSpeed, addSpeed); accelSpeed = Mathf.Min(accelSpeed, addSpeed);
// Добавляем поперечный вектор скорости для стрейфа
horizontalVelocity += wishDir * accelSpeed; horizontalVelocity += wishDir * accelSpeed;
} }
private void ExecuteJump() private void ExecuteJump()
{ {
// SLIDE-JUMP: Если прыгаем из подката — сохраняем скорость в воздух!
if (isSliding) if (isSliding)
{ {
horizontalVelocity = slideDirection * slideCurrentSpeed; horizontalVelocity = slideDirection * slideCurrentSpeed;
@ -346,7 +399,7 @@ public class PlayerController : MonoBehaviour
} }
verticalVelocity = Mathf.Sqrt(jumpHeight * -2f * gravity); verticalVelocity = Mathf.Sqrt(jumpHeight * -2f * gravity);
jumpBufferTimer = 0f; // Сбрасываем запрос на прыжок jumpBufferTimer = 0f;
if (enableHeadBob) if (enableHeadBob)
currentImpactOffset = 0.1f; currentImpactOffset = 0.1f;
@ -396,17 +449,14 @@ public class PlayerController : MonoBehaviour
private void HandleMouseLook() private void HandleMouseLook()
{ {
// Вверх / Вниз
cameraPitch -= lookInput.y * mouseSensitivity; cameraPitch -= lookInput.y * mouseSensitivity;
cameraPitch = Mathf.Clamp(cameraPitch, -maxLookAngle, maxLookAngle); cameraPitch = Mathf.Clamp(cameraPitch, -maxLookAngle, maxLookAngle);
// Наклон камеры в подкате (Camera Roll)
float targetTilt = isSliding ? -slideCameraTiltAngle : 0f; float targetTilt = isSliding ? -slideCameraTiltAngle : 0f;
currentCameraTilt = Mathf.Lerp(currentCameraTilt, targetTilt, Time.deltaTime * 10f); currentCameraTilt = Mathf.Lerp(currentCameraTilt, targetTilt, Time.deltaTime * 10f);
cameraPosition.localRotation = Quaternion.Euler(cameraPitch, 0f, currentCameraTilt); cameraPosition.localRotation = Quaternion.Euler(cameraPitch, 0f, currentCameraTilt);
// Влево / Вправо
yRotation += lookInput.x * mouseSensitivity; yRotation += lookInput.x * mouseSensitivity;
transform.rotation = Quaternion.Euler(0f, yRotation, 0f); transform.rotation = Quaternion.Euler(0f, yRotation, 0f);
} }
@ -421,7 +471,6 @@ public class PlayerController : MonoBehaviour
col.center = new Vector3(col.center.x, col.height * 0.5f, col.center.z); col.center = new Vector3(col.center.x, col.height * 0.5f, col.center.z);
baseCameraY = Mathf.Lerp(baseCameraY, targetCamY, Time.deltaTime * crouchTransitionSpeed); baseCameraY = Mathf.Lerp(baseCameraY, targetCamY, Time.deltaTime * crouchTransitionSpeed);
// В подкате и в воздухе шаги не трясут камеру
bool isMoving = moveInput.sqrMagnitude > 0.01f && isGrounded && !isSliding; bool isMoving = moveInput.sqrMagnitude > 0.01f && isGrounded && !isSliding;
if (isMoving && enableHeadBob) if (isMoving && enableHeadBob)
@ -458,10 +507,12 @@ public class PlayerController : MonoBehaviour
0f 0f
); );
} }
public void SetSensitivity(float newSens) public void SetSensitivity(float newSens)
{ {
mouseSensitivity = newSens; mouseSensitivity = newSens;
} }
private void PlayFootstep() private void PlayFootstep()
{ {
if (footstepSounds == null || footstepSounds.Length == 0) return; if (footstepSounds == null || footstepSounds.Length == 0) return;
@ -487,4 +538,10 @@ public class PlayerController : MonoBehaviour
string state = isSliding ? " [SLIDE]" : (!isGrounded ? " [AIR]" : ""); string state = isSliding ? " [SLIDE]" : (!isGrounded ? " [AIR]" : "");
GUI.Label(new Rect(30, 30, 500, 50), $"Speed: {speed:F1} m/s ({csUnits:F0} u/s){state}", style); GUI.Label(new Rect(30, 30, 500, 50), $"Speed: {speed:F1} m/s ({csUnits:F0} u/s){state}", style);
} }
}
// Интерфейс для любых целей/врагов, принимающих урон
public interface IDamageable
{
void TakeDamage(float amount);
} }

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f89495a02fc2473181e7aa5998a71e2b
timeCreated: 1790083064

View File

@ -0,0 +1,107 @@
using _Project.Scripts.Utilities;
using UnityEngine;
namespace _Project.Scripts.PlayerUtils
{
public class PlayerMovement : MonoSingleton<PlayerMovement>
{
[Header("Камера и Мышь")]
[SerializeField] private Transform cameraPosition;
[SerializeField] private float mouseSensitivity = 0.1f;
[SerializeField] private float maxLookAngle = 80f;
[Header("Скорости передвижения (м/с)")]
[SerializeField] private float moveSpeed = 6.5f; // Обычный бег (~250 u/s)
[SerializeField] private float sprintSpeed = 9.5f; // Спринт (~360 u/s)
[SerializeField] private float crouchSpeed = 3f;
[Header("Параметры Подката (Slide)")]
[Tooltip("Начальная взрывная скорость подката")]
[SerializeField] private float slideInitialSpeed = 15f; // (~580 u/s)
[Tooltip("Длительность скольжения в секундах")]
[SerializeField] private float slideDuration = 0.85f;
[Tooltip("Трение коленей при подкате")]
[SerializeField] private float slideFriction = 2.8f;
[Tooltip("Наклон камеры набок при подкате (градусы)")]
[SerializeField] private float slideCameraTiltAngle = 4f;
[SerializeField] private float slideCooldown = 0.35f;
[Header("Физика CS / Source (Bunnyhop & Strafe)")]
[Tooltip("Трение на земле (гасит скорость, если не успели прыгнуть вовремя)")]
[SerializeField] private float groundFriction = 5f;
[Tooltip("Ускорение на земле")]
[SerializeField] private float groundAcceleration = 10f;
[Tooltip("Сила набора скорости в воздухе при стрейфах (sv_airaccelerate)")]
[SerializeField] private float airAcceleration = 80f;
[Tooltip("Лимит добавления скорости в воздухе")]
[SerializeField] private float airCap = 2.0f;
[Tooltip("Показывать спидометр на экране")]
[SerializeField] private bool showSpeedometer = true;
[Header("Гравитация и Прыжок")]
[SerializeField] private float jumpHeight = 1.35f;
[SerializeField] private float gravity = -25f;
[SerializeField] private float fallMultiplier = 1.8f;
[SerializeField] private LayerMask groundLayer;
[SerializeField] private float groundCheckDistance = 0.12f;
[Tooltip("Буфер прыжка (время поблажки для колесика мыши)")]
[SerializeField] private float jumpBufferTime = 0.12f;
[Header("Параметры приседания")]
[SerializeField] private float standingHeight = 2f;
[SerializeField] private float crouchingHeight = 1.05f;
[SerializeField] private float standingCameraY = 1.6f;
[SerializeField] private float crouchingCameraY = 0.8f;
[SerializeField] private float crouchTransitionSpeed = 15f;
private Rigidbody rb;
private CapsuleCollider col;
private Vector2 moveInput;
private Vector2 lookInput;
private Vector3 horizontalVelocity = Vector3.zero;
private float verticalVelocity = 0f;
private bool isGrounded;
private bool wasGrounded;
private bool isSprinting = false;
private bool isCrouching = false;
private float jumpBufferTimer = 0f;
// Подкат
private bool isSliding = false;
private float slideTimer = 0f;
private float slideCurrentSpeed = 0f;
private Vector3 slideDirection = Vector3.zero;
private float slideCooldownTimer = 0f;
private PlayerControls controls;
void Awake()
{
base.Awake();
rb = GetComponent<Rigidbody>();
col = GetComponent<CapsuleCollider>();
mouseSensitivity = PlayerPrefs.GetFloat("MouseSensitivity", mouseSensitivity);
rb.useGravity = false;
rb.freezeRotation = true;
rb.interpolation = RigidbodyInterpolation.None;
controls = new PlayerControls();
controls = Player.Instance.controls;
// Спринт
controls.Player.Sprint.started += ctx => isSprinting = true;
controls.Player.Sprint.canceled += ctx => isSprinting = false;
/* // Присед и Подкат
controls.Player.Crouch.started += ctx => OnCrouchPressed();
controls.Player.Crouch.canceled += ctx => OnCrouchReleased();
// Прыжок на Пробел (через буфер)
controls.Player.Jump.performed += ctx => QueueJump();
*/
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 51301269a09843b8af775b231056fa86
timeCreated: 1790082597

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4cf71ad00ebc47e7849387c806fe9f46
timeCreated: 1790083090

View File

@ -0,0 +1,20 @@
using UnityEngine;
namespace _Project.Scripts.Utilities
{
public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoBehaviour
{
public static T Instance { get; private set; }
protected virtual void Awake()
{
if (Instance != null&& Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this as T;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e974b3a40b5b4d09b675d2139ac7407b
timeCreated: 1790083100

BIN
mono_crash.mem.11927.1.blob Normal file

Binary file not shown.