Fix player jitter on moving platforms

This commit is contained in:
2026-03-17 22:28:39 +01:00
parent 0355b049ff
commit 758a1d420c
22 changed files with 2351 additions and 603 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: af87bdff314fefc45b0ecbd3174bd327
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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: 650dd9526735d5b46b79224bc6e94025, 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
- _BlendOp: 0
- _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
- _SampleGI: 0
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _XRMotionVectorsPass: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.4182093, g: 0.49699396, b: 0.6981132, a: 1}
- _Color: {r: 0.41820928, g: 0.4969939, b: 0.6981132, 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 &5525997884479554624
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: 1dfd0cfa15c0afb438de9bf69aaf091d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,524 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3073126710210553932
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6728665140691231851}
- component: {fileID: 2762692464511061414}
- component: {fileID: 8055405824175897156}
m_Layer: 0
m_Name: Capsule (2)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6728665140691231851
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3073126710210553932}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.14, y: -0.084, z: 0}
m_LocalScale: {x: 0.20256731, y: 0.16072094, z: 0.20256731}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4084594981166643486}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &2762692464511061414
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3073126710210553932}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &8055405824175897156
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3073126710210553932}
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: 27e2a9836de184e4b9ac07a0099ff283, 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!1 &4769862468880687933
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4084594981166643486}
m_Layer: 0
m_Name: models
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4084594981166643486
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4769862468880687933}
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:
- {fileID: 239730964352513143}
- {fileID: 6728665140691231851}
- {fileID: 6058741350329443892}
- {fileID: 7674713765504838473}
m_Father: {fileID: 5867842663273052736}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5340892673040759779
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 239730964352513143}
- component: {fileID: 327048105371865173}
- component: {fileID: 9185845266402765069}
m_Layer: 0
m_Name: Capsule
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &239730964352513143
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5340892673040759779}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.14, y: 0, z: 0}
m_LocalScale: {x: 0.23593295, y: 0.23593295, z: 0.23593295}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4084594981166643486}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &327048105371865173
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5340892673040759779}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &9185845266402765069
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5340892673040759779}
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: b44589781f5e0e04c8ca5f190db42ada, 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!1 &5353553569795347060
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5867842663273052736}
- component: {fileID: 3548182774296225678}
- component: {fileID: 234486930834537741}
- component: {fileID: 6077536968720832767}
- component: {fileID: 5343236964637381801}
m_Layer: 0
m_Name: JetPack
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5867842663273052736
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5353553569795347060}
serializedVersion: 2
m_LocalRotation: {x: -0.05523832, y: 0.09464295, z: 0.010979698, w: 0.9939169}
m_LocalPosition: {x: 2.10401, y: 0.757, z: -3.67892}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4084594981166643486}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: -6.424, y: 10.842, z: 0.656}
--- !u!135 &3548182774296225678
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5353553569795347060}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 1
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Radius: 0.75
m_Center: {x: 0, y: 0, z: 0}
--- !u!65 &234486930834537741
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5353553569795347060}
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: 3
m_Size: {x: 0.52, y: 0.46, z: 0.21}
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &6077536968720832767
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5353553569795347060}
serializedVersion: 5
m_Mass: 1
m_LinearDamping: 0
m_AngularDamping: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &5343236964637381801
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5353553569795347060}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e22ce2b6f35d2f441b3b72c98bfd81a4, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::JetPack
_settings:
Force: 15
Duration: 10
_references:
Collider: {fileID: 234486930834537741}
Trigger: {fileID: 3548182774296225678}
Rigidbody: {fileID: 6077536968720832767}
InputActions: {fileID: -944628639613478452, guid: 052faaac586de48259a63d0c4782560b, type: 3}
_state:
Equiped: 0
--- !u!1 &7672612686317121953
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7674713765504838473}
- component: {fileID: 6897229576336574703}
- component: {fileID: 6185945404168675395}
m_Layer: 0
m_Name: Capsule (3)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7674713765504838473
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7672612686317121953}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.14, y: -0.08399999, z: 0}
m_LocalScale: {x: 0.20256731, y: 0.16072094, z: 0.20256731}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4084594981166643486}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &6897229576336574703
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7672612686317121953}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &6185945404168675395
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7672612686317121953}
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: 27e2a9836de184e4b9ac07a0099ff283, 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!1 &8189109629263975934
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6058741350329443892}
- component: {fileID: 674889486106847705}
- component: {fileID: 82475505613324255}
m_Layer: 0
m_Name: Capsule (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6058741350329443892
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8189109629263975934}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.14, y: 0, z: 0}
m_LocalScale: {x: 0.23593295, y: 0.23593295, z: 0.23593295}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4084594981166643486}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &674889486106847705
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8189109629263975934}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &82475505613324255
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8189109629263975934}
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: b44589781f5e0e04c8ca5f190db42ada, 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}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dfb5576e46653d9419747f6c7e441ee4
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
using UnityEngine;
using UnityEngine.InputSystem;
[DefaultExecutionOrder(1001)]
public class CameraThirdPerson : MonoBehaviour
{
[System.Serializable]
@@ -39,6 +40,7 @@ public class CameraThirdPerson : MonoBehaviour
public class References
{
public InputActionAsset InputActions;
public Transform Target;
}
[SerializeField]
@@ -96,7 +98,7 @@ public class CameraThirdPerson : MonoBehaviour
private void SetCursor()
{
bool lockCursor = Player.Owner && !Player.Owner.State.IsPaused;
bool lockCursor = Player.Instance && !Player.Instance.State.IsPaused;
Cursor.lockState = lockCursor ? CursorLockMode.Locked : CursorLockMode.None;
Cursor.visible = !lockCursor;
@@ -104,7 +106,7 @@ public class CameraThirdPerson : MonoBehaviour
private void SetYawAndPitch(float deltaTime)
{
if (!Player.Owner || Player.Owner.State.IsPaused)
if ((!Player.Instance || Player.Instance.State.IsPaused) && !_references.Target)
return;
Vector2 lookInput = _lookAction?.ReadValue<Vector2>() ?? Vector2.zero;
@@ -132,9 +134,11 @@ public class CameraThirdPerson : MonoBehaviour
{
Vector3 offset = Vector3.up * _settings.VerticalOffset;
if (!Player.Owner)
return Vector3.zero + offset;
if (_references.Target)
return _references.Target.position + offset;
else if(Player.Instance)
return Player.Instance.transform.position + offset;
return Player.Owner.transform.position + offset;
return Vector3.zero + offset;
}
}

View File

@@ -30,7 +30,7 @@ public class FallingPlatform : MonoBehaviour
void OnTriggerEnter(Collider col)
{
if (Player.Owner && Player.Owner.gameObject == col.gameObject)
if (Player.Instance && Player.Instance.gameObject == col.gameObject)
{
Fall();
}

View File

@@ -0,0 +1,129 @@
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
public class JetPack : MonoBehaviour
{
[System.Serializable]
public class Settings
{
public float Force = 5;
public float Duration = 10;
}
[System.Serializable]
public class References
{
public BoxCollider Collider;
public SphereCollider Trigger;
public Rigidbody Rigidbody;
public ParticleSystem Particles;
public InputActionAsset InputActions;
}
[System.Serializable]
public class StateContainer
{
public bool Equiped;
}
[SerializeField]
public Settings _settings;
[SerializeField]
public References _references;
[SerializeField]
public StateContainer _state;
private bool _wasPressed;
private float _duration = 0;
private float _smooth = 0;
private InputAction _jumpAction;
void OnTriggerEnter(Collider col)
{
if (Player.Instance && Player.Instance.gameObject == col.gameObject)
{
Equip();
}
}
void Awake()
{
_duration = _settings.Duration;
_jumpAction = _references.InputActions.FindActionMap("Player").FindAction("Jump");
}
void Update()
{
if (_state.Equiped && Player.Instance)
{
if (_duration > 0)
{
if (_jumpAction.IsPressed())
{
_wasPressed = true;
_duration -= Time.deltaTime;
_smooth = Mathf.Clamp01(_smooth + Time.deltaTime);
//Player.Instance.SetExtraForce(Vector3.up * _settings.Force * _smooth, true);
}
else if (_wasPressed)
{
_smooth = 0;
_wasPressed = false;
ResetExtraForce();
}
}
else
{
Unequip();
}
}
}
private void Equip()
{
if (_state.Equiped || _duration <= 0 ||!Player.Instance)
return;
_wasPressed = false;
_state.Equiped = true;
_duration = _settings.Duration;
_references.Collider.enabled = false;
_references.Trigger.enabled = false;
_references.Rigidbody.isKinematic = true;
transform.parent = Player.Instance.transform.GetChild(0).GetChild(1).GetChild(0);
transform.localPosition = new Vector3(0, .3f, -.4f);
transform.localEulerAngles = Vector3.zero;
}
private void Unequip()
{
if (!_state.Equiped)
return;
ResetExtraForce();
_state.Equiped = false;
_duration = _settings.Duration;
transform.parent = null;
Vector3 random = new Vector3(UnityEngine.Random.Range(-1, 1), UnityEngine.Random.Range(-1, 1), UnityEngine.Random.Range(-1, 1)).normalized;
_references.Collider.enabled = true;
_references.Trigger.enabled = false;
_references.Rigidbody.isKinematic = false;
_references.Rigidbody.AddRelativeTorque(random, ForceMode.Impulse);
}
private void ResetExtraForce()
{
//Player.Instance.SetExtraForce(Vector3.zero, false);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e22ce2b6f35d2f441b3b72c98bfd81a4

View File

@@ -0,0 +1,22 @@
using UnityEngine;
[DefaultExecutionOrder(1)]
public class ParentSimuator : MonoBehaviour
{
[SerializeField] Transform _target;
[SerializeField] Vector3 _targetPosition;
void OnEnable()
{
_targetPosition = _target.InverseTransformPoint(transform.position);
}
void Update()
{
Vector3 targetPosition = _target.TransformPoint(_targetPosition);
transform.position = targetPosition;
_targetPosition = _target.InverseTransformPoint(transform.position);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 98c2f408a2e65a54da421fc54a4f07f3

View File

@@ -1,22 +1,15 @@
using System.Collections;
using UnityEngine;
using UnityEngine;
using UnityEngine.InputSystem;
//using Unity.Netcode;
//using Unity.Netcode.Components;
using System;
/// <summary>
/// Player controller.
/// </summary>
[RequireComponent(typeof(CharacterController))]
public class Player : MonoBehaviour //NetworkBehaviour
[DefaultExecutionOrder(1000)]
public class Player : MonoBehaviour
{
public static Player Owner { get; private set; }
public enum PlayerType
{
Local,
//Network
}
public static Player Instance { get; private set; }
public enum PlayerState
{
@@ -33,8 +26,6 @@ public class Player : MonoBehaviour //NetworkBehaviour
[System.Serializable]
public class Settings
{
public PlayerType Type;
[Header("Movements")]
[Tooltip("Movement speed in km/h")]
@@ -51,7 +42,7 @@ public class Player : MonoBehaviour //NetworkBehaviour
[Tooltip("Layers considered as ground")]
public LayerMask GroundLayer = 1;
[Header("Debug")]
[Tooltip("GUI logs of current state")]
@@ -63,7 +54,6 @@ public class Player : MonoBehaviour //NetworkBehaviour
{
public CharacterController Controller;
public InputActionAsset InputActions;
//public NetworkTransform NetworkTransform;
}
[System.Serializable]
@@ -78,23 +68,14 @@ public class Player : MonoBehaviour //NetworkBehaviour
[Tooltip("Is player grounded?")]
public bool IsGrounded;
[Tooltip("Is gravity suspended?")]
public bool IsGravitySuspended;
[Tooltip("Vertical velocity in m/s")]
public float VerticalVelocity;
[Tooltip("Horizontal velocity in m/s")]
public Vector2 HorizontalVelocity;
[Tooltip("Additionnal velocity in m/s")]
public Vector3 ExtraVelocity;
[Tooltip("Ground velocity in m/s to avoid parenting")]
public Vector3 GroundVelocity;
[Tooltip("Current velocity in m/s")]
public Vector3 Velocity;
[Tooltip("Ground transform evaluated as parent")]
public Transform GroundTransform;
public Transform Ground;
public float VerticalVelocity => Velocity.y;
public Vector3 HorizontalVelocity => new Vector3(Velocity.x, 0, Velocity.z);
}
[SerializeField] private Settings _settings;
@@ -104,84 +85,32 @@ public class Player : MonoBehaviour //NetworkBehaviour
public StateContainer State => _state;
#region Private Fields
private bool _jumpInput;
private Vector2 _moveInput;
private InputAction _moveAction;
private InputAction _jumpAction;
private Camera _camera;
// Ground check geometry
private Vector3 _groundCheckRayOffset;
private Vector3 _groundCheckSphereOffset;
private float _groundCheckRadius;
private Vector3 _groundCheckOffset;
private Vector3 _groundContactPosition;
private Quaternion _groundContactRotation;
private Collider[] _groundCheckResults = new Collider[1];
IEnumerator _addExtraForceCoroutine;
// OverlapSphere results buffer (non-alloc)
private Collider[] _overlapResults = new Collider[1];
// Platform tracking
private Vector3 _lastPlatformPosition;
private Quaternion _lastPlatformRotation;
// Events
public event Action<PlayerState, PlayerState> OnStateChanged;
#endregion
#region Constants
private const float GRAVITY = -20;
private const float KMH_TO_MS = 1 / 3.6f;
private const float GROUND_STICK_FORCE = -2;
#endregion
#region Network
const bool IsOwner = true; // Remove when enable Network
/*
// Network variables to synchronize state
private NetworkVariable<PlayerState> _networkCurrentState = new NetworkVariable<PlayerState>(
PlayerState.Idle,
NetworkVariableReadPermission.Everyone,
NetworkVariableWritePermission.Owner
);
private NetworkVariable<Vector2> _networkHorizontalVelocity = new NetworkVariable<Vector2>(
Vector2.zero,
NetworkVariableReadPermission.Everyone,
NetworkVariableWritePermission.Owner
);
public override void OnNetworkSpawn()
{
base.OnNetworkSpawn();
_references.NetworkTransform.Interpolate = !IsOwner;
if (IsOwner)
{
Init();
}
else
{
// Subscribe to NetworkVariable changes for non-owners
_networkCurrentState.OnValueChanged += OnNetworkStateChanged;
_networkHorizontalVelocity.OnValueChanged += OnNetworkHorizontalVelocityChanged;
}
}
public override void OnNetworkDespawn()
{
base.OnNetworkDespawn();
// Unsubscribe from NetworkVariable changes
if (!IsOwner)
{
_networkCurrentState.OnValueChanged -= OnNetworkStateChanged;
_networkHorizontalVelocity.OnValueChanged -= OnNetworkHorizontalVelocityChanged;
}
}
// Callback when player state changes (for non-owners)
private void OnNetworkStateChanged(PlayerState previousState, PlayerState newState)
{
_state.CurrentState = newState;
}
// Callback when horizontal velocity changes (for non-owners)
private void OnNetworkHorizontalVelocityChanged(Vector2 previousVelocity, Vector2 newVelocity)
{
_state.HorizontalVelocity = newVelocity;
}*/
private const float STICK_FORCE = -5f;
private const float GRAVITY = -20f;
private const float MAX_GRAVITY = -50f;
#endregion
#region Unity Debug
@@ -194,36 +123,57 @@ public class Player : MonoBehaviour //NetworkBehaviour
style.normal.textColor = Color.white;
style.alignment = TextAnchor.UpperLeft;
string debug = $"Horizontal Velocity: {_state.HorizontalVelocity.magnitude / KMH_TO_MS:F2} km/h\n";
debug += $"X: {_state.HorizontalVelocity.x:F2} Z: {_state.HorizontalVelocity.y:F2}\n";
debug += $"Vertical Velocity: {_state.VerticalVelocity / KMH_TO_MS:F2} km/h\n";
debug += $"Grounded: {_state.IsGrounded}\n";
debug += $"State: {_state.CurrentState}\n";
//debug += $"IsOwner: {IsOwner}\n";
//debug += $"IsServer: {IsServer}\n";
//debug += $"IsClient: {IsClient}";
GUI.Label(new Rect(10, 10, 400, 200), debug, style);
GUILayout.BeginArea(new Rect(10, 10, 400, 200));
GUILayout.Label($"State: {_state.CurrentState}", style);
GUILayout.Label($"Grounded: {_state.IsGrounded}", style);
GUILayout.Label($"Velocity: {_state.Velocity.magnitude:F2} m/s", style);
GUILayout.EndArea();
}
}
void OnDrawGizmos()
{
if (_settings.Type == PlayerType.Local || IsOwner)
{
// Draw ground check sphere
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.color = _state.IsGrounded ? Color.green : new Color(1, .5f, 0);
Gizmos.DrawWireSphere(_groundCheckOffset, _groundCheckRadius);
}
Color c = _state.IsGrounded ? Color.green : new Color(1, .5f, 0);
Gizmos.color = c;
Gizmos.DrawRay(transform.position + _groundCheckRayOffset, Vector3.down * (_settings.GroundTolerance * 2f));
Gizmos.DrawWireSphere(transform.position + _groundCheckSphereOffset, _groundCheckRadius);
}
#endregion
#region Unity Lifecycle
void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
if (_references.Controller == null)
_references.Controller = GetComponent<CharacterController>();
_camera = Camera.main;
_moveAction = _references.InputActions.FindActionMap("Player").FindAction("Move");
_jumpAction = _references.InputActions.FindActionMap("Player").FindAction("Jump");
_references.Controller.skinWidth = 0.08f;
_references.Controller.minMoveDistance = 0f;
_references.Controller.stepOffset = 0.4f;
CharacterController cc = _references.Controller;
_groundCheckRayOffset = cc.center + Vector3.up * (-cc.height * .5f - cc.skinWidth + _settings.GroundTolerance);
_groundCheckSphereOffset = cc.center + Vector3.up * (-cc.height * .5f + cc.radius - cc.skinWidth - _settings.GroundTolerance);
_groundCheckRadius = cc.radius;
}
void OnEnable()
{
if (_settings.Type == PlayerType.Local)
Init();
_moveAction?.Enable();
_jumpAction?.Enable();
}
void OnDisable()
@@ -234,80 +184,26 @@ public class Player : MonoBehaviour //NetworkBehaviour
void Update()
{
if (_settings.Type == PlayerType.Local || IsOwner)
{
float deltaTime = Time.deltaTime;
if (_state.IsPaused) return;
GetInputs();
CheckGround(deltaTime);
SetVelocity(deltaTime);
SetMovement(deltaTime);
UpdateState();
}
}
float deltaTime = Time.deltaTime;
void LateUpdate()
{
// Owner sends state to network
if (IsOwner)
{
//_networkCurrentState.Value = _state.CurrentState;
//_networkHorizontalVelocity.Value = _state.HorizontalVelocity;
}
SetPlatformOffset();
SetGravity(deltaTime);
SetVelocity(deltaTime);
SetJump();
SetMovement(deltaTime);
SetState();
}
#endregion
#region Physics
#endregion
#region Public Methods
/// <summary>
/// Add an additionnal force to the player.
/// </summary>
/// <param name="force">Force direction in m/s</param>
/// <param name="suspendGravity">Suspend gravity for the duration of the force</param>
/// <param name="duration">Duration while fore is applied (if 0: infinite duration)</param>
/// <param name="curve">A remplir par claude</param>
public void AddExtraForce(Vector3 force, bool suspendGravity, float duration = -1, AnimationCurve curve = null)
{
if (_state.CurrentState == PlayerState.Eliminated)
return;
if (_addExtraForceCoroutine != null)
return;
if (duration <= 0)
_state.ExtraVelocity = force;
else
StartCoroutine(_addExtraForceCoroutine = AddExtraForceCoroutine(force, suspendGravity, duration, curve));
}
private IEnumerator AddExtraForceCoroutine(Vector3 force, bool suspendGravity, float duration, AnimationCurve curve)
{
if (suspendGravity)
_state.IsGravitySuspended = true;
for (float t = 0f; t < duration; t += Time.deltaTime)
{
float normaliwedTime = t / duration;
float easeTime = curve != null ? curve.Evaluate(normaliwedTime) : normaliwedTime;
_state.ExtraVelocity = force * easeTime;
yield return new WaitForEndOfFrame();
}
if (suspendGravity)
_state.IsGravitySuspended = false;
_state.ExtraVelocity = Vector3.zero;
_addExtraForceCoroutine = null;
}
public void ResetExtraForce()
{
_state.ExtraVelocity = Vector3.zero;
}
/// <summary>
/// Stuns the player for a specified duration (0 = infinite).
/// Stuns for a specified duration (0 = infinite).
/// </summary>
public void Stun(float duration = 0)
{
@@ -315,15 +211,14 @@ public class Player : MonoBehaviour //NetworkBehaviour
return;
_state.CurrentState = PlayerState.Stunned;
_state.HorizontalVelocity = Vector2.zero;
_state.VerticalVelocity = 0f;
_state.Velocity = Vector3.zero;
if (duration > 0)
Invoke(nameof(RecoverFromStun), duration);
}
/// <summary>
/// Recover the player from stun.
/// Recover from stun.
/// </summary>
public void RecoverFromStun()
{
@@ -337,8 +232,7 @@ public class Player : MonoBehaviour //NetworkBehaviour
public void Eliminate()
{
_state.CurrentState = PlayerState.Eliminated;
_state.HorizontalVelocity = Vector2.zero;
_state.VerticalVelocity = 0f;
_state.Velocity = Vector3.zero;
_references.Controller.enabled = false;
}
@@ -352,228 +246,116 @@ public class Player : MonoBehaviour //NetworkBehaviour
#endregion
#region Player Logic
private void Init()
private void SetPlatformOffset()
{
if (_settings.Type == PlayerType.Local || IsOwner)
{
if (Owner == null)
{
Owner = this;
}
else
{
Debug.LogWarning($"Multiple Player instances detected. Destroy: {gameObject.name}");
Destroy(gameObject);
}
// Raycast for center contact
Vector3 rayOrigin = transform.position + _groundCheckRayOffset;
bool rayHit = Physics.Raycast(rayOrigin, Vector3.down, out RaycastHit rayInfo, _settings.GroundTolerance * 2f, _settings.GroundLayer);
_moveAction = _references.InputActions.FindActionMap("Player").FindAction("Move");
_jumpAction = _references.InputActions.FindActionMap("Player").FindAction("Jump");
// OverlapSphere for edge contact
Vector3 sphereOrigin = transform.position + _groundCheckSphereOffset;
int overlapCount = Physics.OverlapSphereNonAlloc(sphereOrigin, _groundCheckRadius, _overlapResults, _settings.GroundLayer);
bool sphereHit = overlapCount > 0;
_moveAction?.Enable();
_jumpAction?.Enable();
}
_groundCheckOffset = _references.Controller.center + Vector3.up * (_references.Controller.height * -.5f + _references.Controller.radius - _references.Controller.skinWidth - _settings.GroundTolerance);
_groundCheckRadius = _references.Controller.radius;
}
private void GetInputs()
{
if (Keyboard.current?.escapeKey.wasPressedThisFrame ?? false)
Pause(!_state.IsPaused);
_moveInput = _moveAction != null ? _moveAction.ReadValue<Vector2>() : Vector2.zero;
bool jumpInput = _jumpAction != null && _jumpAction.WasPressedThisFrame();
if (jumpInput)
{
bool canJump = _state.IsGrounded &&
_state.CurrentState != PlayerState.Stunned &&
_state.CurrentState != PlayerState.Eliminated &&
_state.CurrentState != PlayerState.Jumping &&
_state.CurrentState != PlayerState.Falling;
_jumpInput = canJump;
}
else
{
_jumpInput = false;
}
}
private void CheckGround(float deltaTime)
{
int hitCount = Physics.OverlapSphereNonAlloc(
transform.position + transform.rotation * _groundCheckOffset,
_groundCheckRadius,
_groundCheckResults,
_settings.GroundLayer
);
bool wasGrounded = _state.IsGrounded;
_state.IsGrounded = hitCount > 0;
_state.IsGrounded = rayHit || sphereHit;
if (_state.IsGrounded)
{
Transform newPlatform = _groundCheckResults[0].transform;
Transform currentGround = rayHit ? rayInfo.collider.transform : _overlapResults[0].transform;
// If platform changed, initialize last frame values
if (newPlatform != _state.GroundTransform)
// Initialize references when landing on a new surface to prevent teleporting
if (currentGround != _state.Ground)
{
_state.GroundTransform = newPlatform;
_state.GroundVelocity = Vector3.zero;
_groundContactPosition = _state.GroundTransform.position;
_groundContactRotation = _state.GroundTransform.rotation;
_state.Ground = currentGround;
_lastPlatformPosition = _state.Ground.position;
_lastPlatformRotation = _state.Ground.rotation;
return;
}
// Yaw delta: rotate player around platform pivot
Quaternion rotationDelta = _state.Ground.rotation * Quaternion.Inverse(_lastPlatformRotation);
float platformYaw = rotationDelta.eulerAngles.y;
if (Mathf.Abs(platformYaw) > .001f)
{
Vector3 dir = transform.position - _state.Ground.position;
dir = Quaternion.Euler(0, platformYaw, 0) * dir;
transform.position = _state.Ground.position + dir;
transform.Rotate(0, platformYaw, 0);
}
// Translation delta
transform.position += _state.Ground.position - _lastPlatformPosition;
// Store current state for next frame
_lastPlatformPosition = _state.Ground.position;
_lastPlatformRotation = _state.Ground.rotation;
// Sync physics broadphase to the new transform, the CharacterController
// doesn't see a stale overlap and generate a corrective push
Physics.SyncTransforms();
}
else
{
// If player just left the platform
if (wasGrounded && _state.GroundTransform != null)
{
Vector3 platformVelocity = (_state.GroundTransform.position - _groundContactPosition) / deltaTime;
// Add platform velovity to player ground velocity
_state.GroundVelocity = platformVelocity;
}
_state.GroundTransform = null;
_state.Ground = null;
}
}
private void SetGravity(float deltaTime)
{
if (_state.IsGrounded && _state.Velocity.y < 0)
_state.Velocity.y = STICK_FORCE;
else
_state.Velocity.y = Mathf.Max(_state.Velocity.y + GRAVITY * deltaTime, MAX_GRAVITY);
}
private void SetVelocity(float deltaTime)
{
// Determine movement attenuation based on current state
Vector2 input = _moveAction.ReadValue<Vector2>();
Vector3 forward = Vector3.ProjectOnPlane(_camera.transform.forward, Vector3.up).normalized;
Vector3 right = Vector3.ProjectOnPlane(_camera.transform.right, Vector3.up).normalized;
float moveAtten;
switch (_state.CurrentState)
float speed = _settings.Speed * KMH_TO_MS;
Vector3 moveInput = (forward * input.y + right * input.x) * speed;
_state.Velocity.x = moveInput.x;
_state.Velocity.z = moveInput.z;
if (moveInput.sqrMagnitude > 0.001f)
{
case PlayerState.Idle:
case PlayerState.Moving:
moveAtten = 1;
break;
case PlayerState.Jumping:
moveAtten = .8f;
break;
case PlayerState.Falling:
moveAtten = .6f;
break;
default:
moveAtten = 0;
break;
Quaternion targetRot = Quaternion.LookRotation(moveInput);
float step = _settings.RotationSpeed * deltaTime;
Vector3 euler = Quaternion.Slerp(transform.rotation, targetRot, step).eulerAngles;
transform.rotation = Quaternion.Euler(0, euler.y, 0);
}
}
// Update horizontal velocity
Vector2 horizontalVelocity = _state.HorizontalVelocity;
if (moveAtten > 0 && Camera.main)
private void SetJump()
{
if (_jumpAction.triggered && _state.IsGrounded)
{
Vector2 move = Vector2.zero;
// Don't apply move to velocity if paused
if (!_state.IsPaused)
{
Vector3 forward = Camera.main.transform.forward;
Vector3 right = Camera.main.transform.right;
forward.y = right.y = 0;
forward.Normalize();
right.Normalize();
Vector3 direction3D = (forward * _moveInput.y + right * _moveInput.x);
move = new Vector2(direction3D.x, direction3D.z).normalized;
move *= _settings.Speed * KMH_TO_MS;
}
horizontalVelocity = Vector2.Lerp(horizontalVelocity, move, moveAtten * deltaTime * 5);
_state.Velocity.y = _settings.JumpForce;
_state.Ground = null;
}
else
{
horizontalVelocity = Vector2.zero;
}
_state.HorizontalVelocity = horizontalVelocity.magnitude > .01f ? horizontalVelocity : Vector2.zero;
// Update vertical velocity
float verticalVelocity = _state.VerticalVelocity;
if (_state.IsGrounded && _jumpInput && !_state.IsPaused)
{
_state.IsGrounded = _jumpInput = false;
verticalVelocity = _settings.JumpForce;
}
else if (_state.IsGrounded && verticalVelocity <= 0)
{
verticalVelocity = _state.IsGravitySuspended ? 0 : GROUND_STICK_FORCE;
}
else if (!_state.IsGravitySuspended)
{
verticalVelocity = Mathf.Max(verticalVelocity + GRAVITY * deltaTime, GRAVITY);
}
_state.VerticalVelocity = verticalVelocity;
}
private void SetMovement(float deltaTime)
{
// Apply platform movement and rotation
if (_state.GroundTransform)
{
// Calculate platform delta position
Vector3 platformPositionDelta = _state.GroundTransform.position - _groundContactPosition;
// Calculate platform delta rotation
Quaternion platformRotationDelta = _state.GroundTransform.rotation * Quaternion.Inverse(_groundContactRotation);
// Apply rotation around platform center
Vector3 localPosition = transform.position - _state.GroundTransform.position;
Vector3 rotatedPosition = platformRotationDelta * localPosition;
platformPositionDelta += rotatedPosition - localPosition;
// Move player with platform
_references.Controller.Move(platformPositionDelta);
// Rotate player with platform
transform.Rotate(Vector3.up, platformRotationDelta.eulerAngles.y, Space.World);
// Update last frame values
_groundContactPosition = _state.GroundTransform.position;
_groundContactRotation = _state.GroundTransform.rotation;
}
// Apply player movement
Vector3 lookDir = new Vector3(_state.HorizontalVelocity.x, 0, _state.HorizontalVelocity.y);
Vector3 velocity = lookDir;
velocity.y = _state.VerticalVelocity;
velocity += _state.GroundVelocity;
velocity += _state.ExtraVelocity;
velocity *= deltaTime;
_references.Controller.Move(velocity);
// Apply player rotation
if (lookDir.sqrMagnitude > .01f)
{
Quaternion targetRotation = Quaternion.LookRotation(lookDir, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, _settings.RotationSpeed * deltaTime);
}
_references.Controller.Move(_state.Velocity * deltaTime);
}
private void UpdateState()
private void SetState()
{
PlayerState previousState = _state.CurrentState;
if (_state.CurrentState == PlayerState.Stunned ||
_state.CurrentState == PlayerState.Eliminated)
_state.CurrentState == PlayerState.Eliminated ||
_state.CurrentState == PlayerState.Winner ||
_state.CurrentState == PlayerState.Loser)
{
return;
}
PlayerState previousState = _state.CurrentState;
if (!_state.IsGrounded)
{
_state.CurrentState = _state.VerticalVelocity > 0
@@ -582,14 +364,13 @@ public class Player : MonoBehaviour //NetworkBehaviour
}
else
{
if (_state.VerticalVelocity <= 0)
_state.CurrentState = _state.HorizontalVelocity.sqrMagnitude > 0.1f
? PlayerState.Moving
: PlayerState.Idle;
_state.CurrentState = _state.HorizontalVelocity.sqrMagnitude > 0.1f
? PlayerState.Moving
: PlayerState.Idle;
}
//if (_state.CurrentState != previousState)
// Debug.Log($"{previousState} → {_state.CurrentState}");
if (previousState != _state.CurrentState)
OnStateChanged?.Invoke(previousState, _state.CurrentState);
}
#endregion
}

View File

@@ -4,6 +4,7 @@
/// Procedural platform animation supporting translation, rotation, and scaling.
/// Supports multiple animation types (Constant, PingPong, Loop, Single) with easing.
/// </summary>
[DefaultExecutionOrder(0)]
public class ProceduralAnimator : MonoBehaviour
{
public enum AnimationSpace
@@ -89,7 +90,7 @@ public class ProceduralAnimator : MonoBehaviour
_state.IsFinished = false;
}
void LateUpdate()
void Update()
{
if (_state.IsFinished)
return;

View File

@@ -10,10 +10,10 @@ public class Springboard : MonoBehaviour
void OnTriggerEnter(Collider col)
{
if (Player.Owner && col.gameObject == Player.Owner.gameObject)
if (Player.Instance && col.gameObject == Player.Instance.gameObject)
{
Debug.Log("Player triggered springboard");
Player.Owner.AddExtraForce(Vector3.up * _force, true, _duration, _curve);
//Player.Instance.AddExtraForce(transform.up * _force, true, _duration, _curve);
_onJump?.Invoke();
}
}

View File

@@ -24,8 +24,9 @@ MonoBehaviour:
probeSamplingDebugMesh: {fileID: 0}
probeSamplingDebugTexture: {fileID: 0}
probeVolumeBlendStatesCS: {fileID: 0}
m_RendererFeatures: []
m_RendererFeatureMap:
m_RendererFeatures:
- {fileID: 5331441224716313634}
m_RendererFeatureMap: 22e416f48b15fd49
m_UseNativeRenderPass: 1
xrSystemData: {fileID: 0}
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
@@ -54,3 +55,45 @@ MonoBehaviour:
m_DepthTextureFormat: 0
m_AccurateGbufferNormals: 0
m_IntermediateTextureMode: 0
--- !u!114 &5331441224716313634
MonoBehaviour:
m_ObjectHideFlags: 0
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: 6b3d386ba5cd94485973aee1479b272e, type: 3}
m_Name: RenderObjects
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.RenderObjects
m_Active: 0
settings:
passTag: RenderObjects
Event: 300
filterSettings:
RenderQueueType: 0
LayerMask:
serializedVersion: 2
m_Bits: 128
PassNames: []
overrideMaterial: {fileID: 2100000, guid: 1dfd0cfa15c0afb438de9bf69aaf091d, type: 2}
overrideMaterialPassIndex: 0
overrideShader: {fileID: 0}
overrideShaderPassIndex: 0
overrideMode: 1
overrideDepthState: 0
depthCompareFunction: 4
enableWrite: 1
stencilSettings:
overrideStencilState: 0
stencilReference: 0
stencilCompareFunction: 8
passOperation: 0
failOperation: 0
zFailOperation: 0
cameraSettings:
overrideCamera: 0
restoreCamera: 1
offset: {x: 0, y: 0, z: 0, w: 0}
cameraFieldOfView: 60

View File

@@ -13,32 +13,28 @@ MonoBehaviour:
m_Name: PC_Renderer
m_EditorClassIdentifier:
debugShaders:
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
type: 3}
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, type: 3}
hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
probeVolumeSamplingDebugComputeShader: {fileID: 7200000, guid: 53626a513ea68ce47b59dc1299fe3959,
type: 3}
probeVolumeSamplingDebugComputeShader: {fileID: 7200000, guid: 53626a513ea68ce47b59dc1299fe3959, type: 3}
probeVolumeResources:
probeVolumeDebugShader: {fileID: 4800000, guid: e5c6678ed2aaa91408dd3df699057aae,
type: 3}
probeVolumeFragmentationDebugShader: {fileID: 4800000, guid: 03cfc4915c15d504a9ed85ecc404e607,
type: 3}
probeVolumeOffsetDebugShader: {fileID: 4800000, guid: 53a11f4ebaebf4049b3638ef78dc9664,
type: 3}
probeVolumeSamplingDebugShader: {fileID: 4800000, guid: 8f96cd657dc40064aa21efcc7e50a2e7,
type: 3}
probeSamplingDebugMesh: {fileID: -3555484719484374845, guid: 57d7c4c16e2765b47a4d2069b311bffe,
type: 3}
probeSamplingDebugTexture: {fileID: 2800000, guid: 24ec0e140fb444a44ab96ee80844e18e,
type: 3}
probeVolumeBlendStatesCS: {fileID: 7200000, guid: b9a23f869c4fd45f19c5ada54dd82176,
type: 3}
probeVolumeDebugShader: {fileID: 4800000, guid: e5c6678ed2aaa91408dd3df699057aae, type: 3}
probeVolumeFragmentationDebugShader: {fileID: 4800000, guid: 03cfc4915c15d504a9ed85ecc404e607, type: 3}
probeVolumeOffsetDebugShader: {fileID: 4800000, guid: 53a11f4ebaebf4049b3638ef78dc9664, type: 3}
probeVolumeSamplingDebugShader: {fileID: 4800000, guid: 8f96cd657dc40064aa21efcc7e50a2e7, type: 3}
probeSamplingDebugMesh: {fileID: -3555484719484374845, guid: 57d7c4c16e2765b47a4d2069b311bffe, type: 3}
probeSamplingDebugTexture: {fileID: 2800000, guid: 24ec0e140fb444a44ab96ee80844e18e, type: 3}
probeVolumeBlendStatesCS: {fileID: 7200000, guid: b9a23f869c4fd45f19c5ada54dd82176, type: 3}
m_RendererFeatures:
- {fileID: 7833122117494664109}
m_RendererFeatureMap: ad6b866f10d7b46c
- {fileID: 5153190125947533465}
m_RendererFeatureMap: ad6b866f10d7b46c993827e51dcf8347
m_UseNativeRenderPass: 1
xrSystemData: {fileID: 0}
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
m_AssetVersion: 2
m_AssetVersion: 3
m_PrepassLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_OpaqueLayerMask:
serializedVersion: 2
m_Bits: 4294967295
@@ -56,8 +52,52 @@ MonoBehaviour:
m_RenderingMode: 2
m_DepthPrimingMode: 0
m_CopyDepthMode: 0
m_DepthAttachmentFormat: 0
m_DepthTextureFormat: 0
m_AccurateGbufferNormals: 0
m_IntermediateTextureMode: 0
--- !u!114 &5153190125947533465
MonoBehaviour:
m_ObjectHideFlags: 0
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: 6b3d386ba5cd94485973aee1479b272e, type: 3}
m_Name: RenderObjects
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.RenderObjects
m_Active: 0
settings:
passTag: RenderObjects
Event: 300
filterSettings:
RenderQueueType: 0
LayerMask:
serializedVersion: 2
m_Bits: 128
PassNames: []
overrideMaterial: {fileID: 2100000, guid: 1dfd0cfa15c0afb438de9bf69aaf091d, type: 2}
overrideMaterialPassIndex: 0
overrideShader: {fileID: 0}
overrideShaderPassIndex: 0
overrideMode: 1
overrideDepthState: 1
depthCompareFunction: 5
enableWrite: 1
stencilSettings:
overrideStencilState: 0
stencilReference: 0
stencilCompareFunction: 0
passOperation: 0
failOperation: 0
zFailOperation: 0
cameraSettings:
overrideCamera: 0
restoreCamera: 1
offset: {x: 0, y: 0, z: 0, w: 0}
cameraFieldOfView: 60
--- !u!114 &7833122117494664109
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -84,12 +124,3 @@ MonoBehaviour:
BlurQuality: 0
Falloff: 100
SampleCount: -1
m_BlueNoise256Textures:
- {fileID: 2800000, guid: 36f118343fc974119bee3d09e2111500, type: 3}
- {fileID: 2800000, guid: 4b7b083e6b6734e8bb2838b0b50a0bc8, type: 3}
- {fileID: 2800000, guid: c06cc21c692f94f5fb5206247191eeee, type: 3}
- {fileID: 2800000, guid: cb76dd40fa7654f9587f6a344f125c9a, type: 3}
- {fileID: 2800000, guid: e32226222ff144b24bf3a5a451de54bc, type: 3}
- {fileID: 2800000, guid: 3302065f671a8450b82c9ddf07426f3a, type: 3}
- {fileID: 2800000, guid: 56a77a3e8d64f47b6afe9e3c95cb57d5, type: 3}
m_Shader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e6011b3abff97c6468ae337132ba8225
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@@ -0,0 +1,143 @@
fileFormatVersion: 2
guid: 9a0066edbdb335844a09a8146462d93f
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -5,7 +5,7 @@ EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
- enabled: 0
path: Assets/Content/Scenes/SampleScene.unity
guid: 99c9720ab356a0642a771bea13969a05
m_configObjects:

View File

@@ -12,7 +12,7 @@ TagManager:
- Water
- UI
- Ground
-
- Player
-
-
-