Progress network character controls

This commit is contained in:
Marius 2025-02-12 21:59:30 +01:00
parent 01f38a19a1
commit 0cb70d4042
51 changed files with 297 additions and 2093 deletions

View File

@ -1,278 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1555240849038293811
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1555240849038293810}
- component: {fileID: 6060867110873050882}
- component: {fileID: 6622008125457246999}
- component: {fileID: 4995878257031069448}
- component: {fileID: 8700726934599842024}
- component: {fileID: 1854736588908238760}
- component: {fileID: 3403150522591491636}
- component: {fileID: 742358034037228598}
m_Layer: 0
m_Name: CharacterPrefab
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1555240849038293810
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
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: 2348594743945901555}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!136 &6060867110873050882
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
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!114 &6622008125457246999
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c16549610bfe4458aa9389201d072bb6, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &4995878257031069448
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7c79d771cedb4794bf100ce60df5f764, type: 3}
m_Name:
m_EditorClassIdentifier:
DefaultGhostMode: 1
SupportedGhostModes: 3
OptimizationMode: 0
Importance: 1000
prefabId:
HasOwner: 1
SupportAutoCommandTarget: 1
TrackInterpolationDelay: 0
GhostGroup: 0
UsePreSerialization: 0
RollbackPredictedSpawnedGhostState: 0
RollbackPredictionOnStructuralChanges: 1
--- !u!23 &8700726934599842024
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
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_RenderingLayerMask: 257
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 70c3442346d77cb4781288146feb488a, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &1854736588908238760
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!114 &3403150522591491636
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 544609009a6605d44a92eca2ad0145ad, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!54 &742358034037228598
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 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!1 &5307440377108821305
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2348594743945901555}
- component: {fileID: 2119331458662122770}
- component: {fileID: 4415356237060297836}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2348594743945901555
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5307440377108821305}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.391, z: 0.419}
m_LocalScale: {x: 0.6016427, y: 0.2015024, z: 0.1763629}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1555240849038293810}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &2119331458662122770
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5307440377108821305}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &4415356237060297836
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5307440377108821305}
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_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}

View File

@ -9,15 +9,16 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1555240849038293810}
- component: {fileID: 2357972388217118203}
- component: {fileID: 6060867110873050882}
- component: {fileID: 6622008125457246999}
- component: {fileID: 4995878257031069448}
- component: {fileID: 8700726934599842024}
- component: {fileID: 1854736588908238760}
- component: {fileID: 3403150522591491636}
- component: {fileID: 5883734756752601847}
- component: {fileID: 4239438941384307771}
m_Layer: 0
m_Name: FPSPrefab
m_Name: FPSCharacter
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -39,6 +40,30 @@ Transform:
- {fileID: 2348594743945901555}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2357972388217118203
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7c79d771cedb4794bf100ce60df5f764, type: 3}
m_Name:
m_EditorClassIdentifier:
DefaultGhostMode: 2
SupportedGhostModes: 3
OptimizationMode: 0
Importance: 1
prefabId:
HasOwner: 1
SupportAutoCommandTarget: 1
TrackInterpolationDelay: 0
GhostGroup: 0
UsePreSerialization: 0
RollbackPredictedSpawnedGhostState: 0
RollbackPredictionOnStructuralChanges: 1
--- !u!136 &6060867110873050882
CapsuleCollider:
m_ObjectHideFlags: 0
@ -74,30 +99,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c16549610bfe4458aa9389201d072bb6, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &4995878257031069448
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7c79d771cedb4794bf100ce60df5f764, type: 3}
m_Name:
m_EditorClassIdentifier:
DefaultGhostMode: 2
SupportedGhostModes: 3
OptimizationMode: 0
Importance: 1000
prefabId:
HasOwner: 1
SupportAutoCommandTarget: 1
TrackInterpolationDelay: 0
GhostGroup: 0
UsePreSerialization: 0
RollbackPredictedSpawnedGhostState: 0
RollbackPredictionOnStructuralChanges: 1
--- !u!23 &8700726934599842024
MeshRenderer:
m_ObjectHideFlags: 0
@ -225,6 +226,19 @@ MonoBehaviour:
ConstrainVelocityToGroundPlane: 1
MinViewAngle: -90
MaxViewAngle: 90
--- !u!114 &4239438941384307771
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bfdaa6c06fe64fbda2b16e07a4ee0b25, type: 3}
m_Name:
m_EditorClassIdentifier:
ComponentOverrides: []
--- !u!1 &5307440377108821305
GameObject:
m_ObjectHideFlags: 0

View File

@ -11,7 +11,8 @@ GameObject:
- component: {fileID: 577874318210893197}
- component: {fileID: 7698645590983583992}
- component: {fileID: 3788593771807550029}
- component: {fileID: 1933375481360013513}
- component: {fileID: 7015821749181243120}
- component: {fileID: 512968691703412025}
m_Layer: 0
m_Name: FPSPlayer
m_TagString: Untagged
@ -59,7 +60,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c16549610bfe4458aa9389201d072bb6, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1933375481360013513
--- !u!114 &7015821749181243120
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -75,6 +76,7 @@ MonoBehaviour:
SupportedGhostModes: 3
OptimizationMode: 0
Importance: 1
MaxSendRate: 0
prefabId:
HasOwner: 1
SupportAutoCommandTarget: 1
@ -83,3 +85,16 @@ MonoBehaviour:
UsePreSerialization: 0
RollbackPredictedSpawnedGhostState: 0
RollbackPredictionOnStructuralChanges: 1
--- !u!114 &512968691703412025
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 577874318210893199}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bfdaa6c06fe64fbda2b16e07a4ee0b25, type: 3}
m_Name:
m_EditorClassIdentifier:
ComponentOverrides: []

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 3618e38bce9ef804a9830edc2f987f2b
guid: b9133acc328ddc94586c3102b324204b
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,91 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &342835398672184499
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1555240849038293810, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1555240849038293810, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1555240849038293810, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1555240849038293810, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1555240849038293810, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1555240849038293810, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1555240849038293810, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1555240849038293810, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1555240849038293810, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1555240849038293810, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1555240849038293811, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: m_Name
value: NetFPSCharacter Variant
objectReference: {fileID: 0}
- target: {fileID: 2357972388217118203, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: prefabId
value: 1d0dd41a9ab5e3a4ea7626a3fb8fbcc3
objectReference: {fileID: 0}
- target: {fileID: 4239438941384307771, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: ComponentOverrides.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4239438941384307771, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: ComponentOverrides.Array.data[0].PrefabType
value: -1
objectReference: {fileID: 0}
- target: {fileID: 4239438941384307771, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: ComponentOverrides.Array.data[0].VariantHash
value: 10188360468653526834
objectReference: {fileID: 0}
- target: {fileID: 4239438941384307771, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: ComponentOverrides.Array.data[0].FullTypeName
value: Unity.Physics.PhysicsVelocity
objectReference: {fileID: 0}
- target: {fileID: 4239438941384307771, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: ComponentOverrides.Array.data[0].SendTypeOptimization
value: -1
objectReference: {fileID: 0}
- target: {fileID: 5883734756752601847, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: Gravity.y
value: -9.81
objectReference: {fileID: 0}
- target: {fileID: 5883734756752601847, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
propertyPath: JumpSpeed
value: 20
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 5fbcc801dea8fd640a004697d22ed448
guid: 1d0dd41a9ab5e3a4ea7626a3fb8fbcc3
PrefabImporter:
externalObjects: {}
userData:

View File

@ -0,0 +1,83 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &5180934913353149668
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 512968691703412025, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: ComponentOverrides.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 512968691703412025, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: ComponentOverrides.Array.data[0].PrefabType
value: -1
objectReference: {fileID: 0}
- target: {fileID: 512968691703412025, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: ComponentOverrides.Array.data[0].VariantHash
value: 10188360468653526834
objectReference: {fileID: 0}
- target: {fileID: 512968691703412025, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: ComponentOverrides.Array.data[0].FullTypeName
value: Unity.Transforms.LocalTransform
objectReference: {fileID: 0}
- target: {fileID: 512968691703412025, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: ComponentOverrides.Array.data[0].SendTypeOptimization
value: -1
objectReference: {fileID: 0}
- target: {fileID: 577874318210893197, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 577874318210893197, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 577874318210893197, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 577874318210893197, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 577874318210893197, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 577874318210893197, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 577874318210893197, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 577874318210893197, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 577874318210893197, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 577874318210893197, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 577874318210893199, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: m_Name
value: NetFPSPlayer Variant
objectReference: {fileID: 0}
- target: {fileID: 7015821749181243120, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
propertyPath: prefabId
value: 7d31de590ce492146824ea754807601c
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2c95b1fb964db584b842d4c61dff15c7
guid: 7d31de590ce492146824ea754807601c
PrefabImporter:
externalObjects: {}
userData:

View File

@ -25,13 +25,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240848202863130}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1555240849038293810}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1555240848202863135
MeshFilter:
@ -58,6 +58,9 @@ MeshRenderer:
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_RenderingLayerMask: 257
m_RendererPriority: 0
m_Materials:
@ -108,6 +111,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1555240849038293811}
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}
@ -116,7 +120,6 @@ Transform:
- {fileID: 1555240848202863129}
- {fileID: 6401532902016766949}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!136 &6060867110873050882
CapsuleCollider:
@ -186,14 +189,14 @@ MonoBehaviour:
AirAcceleration: 50
AirMaxSpeed: 10
AirDrag: 0
JumpSpeed: 10
JumpSpeed: 20
Gravity:
x: -0
y: -30
y: -9.81
z: -0
PreventAirAccelerationAgainstUngroundedHits: 1
StepAndSlopeHandling:
StepHandling: 0
StepHandling: 1
MaxStepHeight: 0.5
ExtraStepChecksDistance: 0.1
CharacterWidthForStepGroundingCheck: 1
@ -227,13 +230,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3463604651959167738}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.4, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1555240849038293810}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3909008753188905296
MonoBehaviour:

View File

@ -7,6 +7,7 @@ using Unity.CharacterController;
using Unity.NetCode;
[Serializable]
[GhostComponent]
public struct FirstPersonCharacterComponent : IComponentData
{
public float GroundMaxSpeed;

View File

@ -4,6 +4,7 @@ using Unity.Mathematics;
using Unity.NetCode;
[Serializable]
[GhostComponent]
public struct FirstPersonPlayer : IComponentData
{
[GhostField] public Entity ControlledCharacter;
@ -14,7 +15,7 @@ public struct FirstPersonPlayerInputs : IInputComponentData
{
public float2 MoveInput;
public float2 LookInput;
public FixedInputEvent JumpPressed;
public InputEvent JumpPressed;
}
[Serializable]

View File

@ -34,7 +34,7 @@ public partial class FirstPersonPlayerInputsSystem : SystemBase
playerInputs.ValueRW.JumpPressed = default;
if (Input.GetKeyDown(KeyCode.Space))
{
playerInputs.ValueRW.JumpPressed.Set(time.Tick);
playerInputs.ValueRW.JumpPressed.Set();
}
}
}
@ -95,8 +95,6 @@ public partial struct FirstPersonPlayerFixedStepControlSystem : ISystem
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var time = SystemAPI.GetSingleton<FixedTickSystem.Singleton>();
foreach (var (playerInputs, player) in SystemAPI.Query<FirstPersonPlayerInputs, FirstPersonPlayer>().WithAll<Simulate>())
{
if (SystemAPI.HasComponent<FirstPersonCharacterControl>(player.ControlledCharacter))
@ -112,7 +110,7 @@ public partial struct FirstPersonPlayerFixedStepControlSystem : ISystem
characterControl.MoveVector = MathUtilities.ClampToMaxLength(characterControl.MoveVector, 1f);
// Jump
characterControl.Jump = playerInputs.JumpPressed.IsSet(time.Tick);
characterControl.Jump = playerInputs.JumpPressed.IsSet;
SystemAPI.SetComponent(player.ControlledCharacter, characterControl);
}

View File

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

View File

@ -1,60 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7568817337597995144
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7568817337597995142}
- component: {fileID: 7568817337597995143}
m_Layer: 0
m_Name: OrbitCamera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7568817337597995142
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7568817337597995144}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.09, z: -3.54}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7568817337597995143
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7568817337597995144}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70c323b4be4b1fa4089d1a1fd2872754, type: 3}
m_Name:
m_EditorClassIdentifier:
RotationSpeed: 2
MaxVAngle: 89
MinVAngle: -89
RotateWithCharacterParent: 1
StartDistance: 5
MinDistance: 0
MaxDistance: 10
DistanceMovementSpeed: 1
DistanceMovementSharpness: 20
ObstructionRadius: 0.1
ObstructionInnerSmoothingSharpness: 3.4028235e+38
ObstructionOuterSmoothingSharpness: 5
PreventFixedUpdateJitter: 1
IgnoredEntities: []

View File

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

View File

@ -1,332 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1692896102597148395
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1692896102597148394}
- component: {fileID: 8041698241194078798}
- component: {fileID: 6689285571920954877}
- component: {fileID: 7542772330835976783}
m_Layer: 0
m_Name: ThirdPersonCharacter
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1692896102597148394
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1692896102597148395}
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: 1692896103431116737}
- {fileID: 2861637503494133750}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!136 &8041698241194078798
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1692896102597148395}
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: 1, z: 0}
--- !u!114 &6689285571920954877
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1692896102597148395}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c854a728d43c7cf47bec103607a449f9, type: 3}
m_Name:
m_EditorClassIdentifier:
CharacterProperties:
CustomPhysicsBodyTags:
Tag00: 0
Tag01: 0
Tag02: 0
Tag03: 0
Tag04: 0
Tag05: 0
Tag06: 0
Tag07: 0
InterpolatePosition: 1
InterpolateRotation: 0
EvaluateGrounding: 1
SnapToGround: 1
GroundSnappingDistance: 0.5
EnhancedGroundPrecision: 0
MaxGroundedSlopeAngle: 60
DetectMovementCollisions: 1
DecollideFromOverlaps: 1
ProjectVelocityOnInitialOverlaps: 0
MaxContinuousCollisionsIterations: 8
MaxOverlapDecollisionIterations: 2
DiscardMovementWhenExceedMaxIterations: 1
KillVelocityWhenExceedMaxIterations: 1
DetectObstructionsForParentBodyMovement: 0
SimulateDynamicBody: 1
Mass: 1
RotationSharpness: 25
GroundMaxSpeed: 10
GroundedMovementSharpness: 15
AirAcceleration: 50
AirMaxSpeed: 10
AirDrag: 0
JumpSpeed: 10
Gravity:
x: -0
y: -30
z: -0
PreventAirAccelerationAgainstUngroundedHits: 1
StepAndSlopeHandling:
StepHandling: 0
MaxStepHeight: 0.5
ExtraStepChecksDistance: 0.1
CharacterWidthForStepGroundingCheck: 1
PreventGroundingWhenMovingTowardsNoGrounding: 1
HasMaxDownwardSlopeChangeAngle: 0
MaxDownwardSlopeChangeAngle: 90
ConstrainVelocityToGroundPlane: 1
--- !u!114 &7542772330835976783
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1692896102597148395}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d3a88336df575c34e80048c54a815367, type: 3}
m_Name:
m_EditorClassIdentifier:
Target: {fileID: 2861637503494133753}
--- !u!1 &1692896103431116738
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1692896103431116737}
- component: {fileID: 1692896103431116743}
- component: {fileID: 1692896103431116736}
m_Layer: 0
m_Name: Capsule
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1692896103431116737
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1692896103431116738}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6498846982015491111}
m_Father: {fileID: 1692896102597148394}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1692896103431116743
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1692896103431116738}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &1692896103431116736
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1692896103431116738}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 257
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 70c3442346d77cb4781288146feb488a, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &2787829476024719926
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6498846982015491111}
- component: {fileID: 6362252827327739790}
- component: {fileID: 1601238720869374913}
m_Layer: 0
m_Name: Cylinder
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6498846982015491111
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2787829476024719926}
m_LocalRotation: {x: -0.70710677, y: -0, z: -0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0.487, z: 0.357}
m_LocalScale: {x: 0.78007, y: 0.17738, z: 0.34445}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1692896103431116737}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!33 &6362252827327739790
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2787829476024719926}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &1601238720869374913
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2787829476024719926}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 257
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 70c3442346d77cb4781288146feb488a, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &2861637503494133753
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2861637503494133750}
m_Layer: 0
m_Name: CameraTarget
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2861637503494133750
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2861637503494133753}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.2, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1692896102597148394}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -1,48 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4729649056687684238
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4729649056687684239}
- component: {fileID: 5910332505473654983}
m_Layer: 0
m_Name: ThirdPersonPlayer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4729649056687684239
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4729649056687684238}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5910332505473654983
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4729649056687684238}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3fbdb3174a73a07408595a85d3e7fb6a, type: 3}
m_Name:
m_EditorClassIdentifier:
ControlledCharacter: {fileID: 0}
ControlledCamera: {fileID: 0}

View File

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

View File

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

View File

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

View File

@ -1,10 +0,0 @@
using System;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
[Serializable]
public struct CameraTarget : IComponentData
{
public Entity TargetEntity;
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 74ff9a59933a5494bbc1bb465a5f2180
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,22 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Entities;
[DisallowMultipleComponent]
public class CameraTargetAuthoring : MonoBehaviour
{
public GameObject Target;
public class Baker : Baker<CameraTargetAuthoring>
{
public override void Bake(CameraTargetAuthoring authoring)
{
Entity entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent(entity, new CameraTarget
{
TargetEntity = GetEntity(authoring.Target, TransformUsageFlags.Dynamic),
});
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: d3a88336df575c34e80048c54a815367
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,44 +0,0 @@
using System;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
[Serializable]
public struct OrbitCamera : IComponentData
{
public float RotationSpeed;
public float MaxVAngle;
public float MinVAngle;
public bool RotateWithCharacterParent;
public float MinDistance;
public float MaxDistance;
public float DistanceMovementSpeed;
public float DistanceMovementSharpness;
public float ObstructionRadius;
public float ObstructionInnerSmoothingSharpness;
public float ObstructionOuterSmoothingSharpness;
public bool PreventFixedUpdateJitter;
public float TargetDistance;
public float SmoothedTargetDistance;
public float ObstructedDistance;
public float PitchAngle;
public float3 PlanarForward;
}
[Serializable]
public struct OrbitCameraControl : IComponentData
{
public Entity FollowedCharacterEntity;
public float2 LookDegreesDelta;
public float ZoomDelta;
}
[Serializable]
public struct OrbitCameraIgnoredEntityBufferElement : IBufferElementData
{
public Entity Entity;
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 441900b2dca2cda429cba5f372fcf5fe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,75 +0,0 @@
using System.Collections.Generic;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
[DisallowMultipleComponent]
public class OrbitCameraAuthoring : MonoBehaviour
{
[Header("Rotation")]
public float RotationSpeed = 2f;
public float MaxVAngle = 89f;
public float MinVAngle = -89f;
public bool RotateWithCharacterParent = true;
[Header("Distance")]
public float StartDistance = 5f;
public float MinDistance = 0f;
public float MaxDistance = 10f;
public float DistanceMovementSpeed = 1f;
public float DistanceMovementSharpness = 20f;
[Header("Obstructions")]
public float ObstructionRadius = 0.1f;
public float ObstructionInnerSmoothingSharpness = float.MaxValue;
public float ObstructionOuterSmoothingSharpness = 5f;
public bool PreventFixedUpdateJitter = true;
[Header("Misc")]
public List<GameObject> IgnoredEntities = new List<GameObject>();
public class Baker : Baker<OrbitCameraAuthoring>
{
public override void Bake(OrbitCameraAuthoring authoring)
{
Entity entity = GetEntity(TransformUsageFlags.Dynamic | TransformUsageFlags.WorldSpace);
AddComponent(entity, new OrbitCamera
{
RotationSpeed = authoring.RotationSpeed,
MaxVAngle = authoring.MaxVAngle,
MinVAngle = authoring.MinVAngle,
RotateWithCharacterParent = authoring.RotateWithCharacterParent,
MinDistance = authoring.MinDistance,
MaxDistance = authoring.MaxDistance,
DistanceMovementSpeed = authoring.DistanceMovementSpeed,
DistanceMovementSharpness = authoring.DistanceMovementSharpness,
ObstructionRadius = authoring.ObstructionRadius,
ObstructionInnerSmoothingSharpness = authoring.ObstructionInnerSmoothingSharpness,
ObstructionOuterSmoothingSharpness = authoring.ObstructionOuterSmoothingSharpness,
PreventFixedUpdateJitter = authoring.PreventFixedUpdateJitter,
TargetDistance = authoring.StartDistance,
SmoothedTargetDistance = authoring.StartDistance,
ObstructedDistance = authoring.StartDistance,
PitchAngle = 0f,
PlanarForward = -math.forward(),
});
AddComponent(entity, new OrbitCameraControl());
DynamicBuffer<OrbitCameraIgnoredEntityBufferElement> ignoredEntitiesBuffer = AddBuffer<OrbitCameraIgnoredEntityBufferElement>(entity);
for (int i = 0; i < authoring.IgnoredEntities.Count; i++)
{
ignoredEntitiesBuffer.Add(new OrbitCameraIgnoredEntityBufferElement
{
Entity = GetEntity(authoring.IgnoredEntities[i], TransformUsageFlags.None),
});
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 70c323b4be4b1fa4089d1a1fd2872754
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,367 +0,0 @@
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Transforms;
using Unity.CharacterController;
[UpdateInGroup(typeof(SimulationSystemGroup))]
[UpdateAfter(typeof(FixedStepSimulationSystemGroup))]
[UpdateAfter(typeof(ThirdPersonPlayerVariableStepControlSystem))]
[UpdateAfter(typeof(ThirdPersonCharacterVariableUpdateSystem))]
[UpdateBefore(typeof(TransformSystemGroup))]
[BurstCompile]
public partial struct OrbitCameraSimulationSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate(SystemAPI.QueryBuilder().WithAll<OrbitCamera, OrbitCameraControl>().Build());
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
OrbitCameraSimulationJob job = new OrbitCameraSimulationJob
{
DeltaTime = SystemAPI.Time.DeltaTime,
LocalTransformLookup = SystemAPI.GetComponentLookup<LocalTransform>(false),
ParentLookup = SystemAPI.GetComponentLookup<Parent>(true),
PostTransformMatrixLookup = SystemAPI.GetComponentLookup<PostTransformMatrix>(true),
CameraTargetLookup = SystemAPI.GetComponentLookup<CameraTarget>(true),
KinematicCharacterBodyLookup = SystemAPI.GetComponentLookup<KinematicCharacterBody>(true),
};
job.Schedule();
}
[BurstCompile]
[WithAll(typeof(Simulate))]
public partial struct OrbitCameraSimulationJob : IJobEntity
{
public float DeltaTime;
public ComponentLookup<LocalTransform> LocalTransformLookup;
[ReadOnly] public ComponentLookup<Parent> ParentLookup;
[ReadOnly] public ComponentLookup<PostTransformMatrix> PostTransformMatrixLookup;
[ReadOnly] public ComponentLookup<CameraTarget> CameraTargetLookup;
[ReadOnly] public ComponentLookup<KinematicCharacterBody> KinematicCharacterBodyLookup;
void Execute(Entity entity, ref OrbitCamera orbitCamera, in OrbitCameraControl cameraControl)
{
if (OrbitCameraUtilities.TryGetCameraTargetSimulationWorldTransform(
cameraControl.FollowedCharacterEntity,
ref LocalTransformLookup,
ref ParentLookup,
ref PostTransformMatrixLookup,
ref CameraTargetLookup,
out float4x4 targetWorldTransform))
{
float3 targetUp = targetWorldTransform.Up();
float3 targetPosition = targetWorldTransform.Translation();
// Update planar forward based on target up direction and rotation from parent
{
quaternion tmpPlanarRotation = MathUtilities.CreateRotationWithUpPriority(targetUp, orbitCamera.PlanarForward);
// Rotation from character parent
if (orbitCamera.RotateWithCharacterParent &&
KinematicCharacterBodyLookup.TryGetComponent(cameraControl.FollowedCharacterEntity, out KinematicCharacterBody characterBody))
{
// Only consider rotation around the character up, since the camera is already adjusting itself to character up
quaternion planarRotationFromParent = characterBody.RotationFromParent;
KinematicCharacterUtilities.AddVariableRateRotationFromFixedRateRotation(ref tmpPlanarRotation, planarRotationFromParent, DeltaTime, characterBody.LastPhysicsUpdateDeltaTime);
}
orbitCamera.PlanarForward = MathUtilities.GetForwardFromRotation(tmpPlanarRotation);
}
// Yaw
float yawAngleChange = cameraControl.LookDegreesDelta.x * orbitCamera.RotationSpeed;
quaternion yawRotation = quaternion.Euler(targetUp * math.radians(yawAngleChange));
orbitCamera.PlanarForward = math.rotate(yawRotation, orbitCamera.PlanarForward);
// Pitch
orbitCamera.PitchAngle += -cameraControl.LookDegreesDelta.y * orbitCamera.RotationSpeed;
orbitCamera.PitchAngle = math.clamp(orbitCamera.PitchAngle, orbitCamera.MinVAngle, orbitCamera.MaxVAngle);
// Calculate final rotation
quaternion cameraRotation = OrbitCameraUtilities.CalculateCameraRotation(targetUp, orbitCamera.PlanarForward, orbitCamera.PitchAngle);
// Distance input
float desiredDistanceMovementFromInput = cameraControl.ZoomDelta * orbitCamera.DistanceMovementSpeed;
orbitCamera.TargetDistance = math.clamp(orbitCamera.TargetDistance + desiredDistanceMovementFromInput, orbitCamera.MinDistance, orbitCamera.MaxDistance);
// Calculate camera position (no smoothing or obstructions yet; these are done in the camera late update)
float3 cameraPosition = OrbitCameraUtilities.CalculateCameraPosition(targetPosition, cameraRotation, orbitCamera.TargetDistance);
// Write back to component
LocalTransformLookup[entity] = LocalTransform.FromPositionRotation(cameraPosition, cameraRotation);
}
}
}
}
[UpdateInGroup(typeof(SimulationSystemGroup))]
[UpdateAfter(typeof(TransformSystemGroup))]
[BurstCompile]
public partial struct OrbitCameraLateUpdateSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<PhysicsWorldSingleton>();
state.RequireForUpdate(SystemAPI.QueryBuilder().WithAll<OrbitCamera, OrbitCameraControl>().Build());
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
OrbitCameraLateUpdateJob job = new OrbitCameraLateUpdateJob
{
DeltaTime = SystemAPI.Time.DeltaTime,
PhysicsWorld = SystemAPI.GetSingleton<PhysicsWorldSingleton>().PhysicsWorld,
LocalToWorldLookup = SystemAPI.GetComponentLookup<LocalToWorld>(false),
CameraTargetLookup = SystemAPI.GetComponentLookup<CameraTarget>(true),
KinematicCharacterBodyLookup = SystemAPI.GetComponentLookup<KinematicCharacterBody>(true),
};
job.Schedule();
}
[BurstCompile]
[WithAll(typeof(Simulate))]
public partial struct OrbitCameraLateUpdateJob : IJobEntity
{
public float DeltaTime;
[ReadOnly]
public PhysicsWorld PhysicsWorld;
public ComponentLookup<LocalToWorld> LocalToWorldLookup;
[ReadOnly]
public ComponentLookup<CameraTarget> CameraTargetLookup;
[ReadOnly]
public ComponentLookup<KinematicCharacterBody> KinematicCharacterBodyLookup;
void Execute(
Entity entity,
ref OrbitCamera orbitCamera,
in OrbitCameraControl cameraControl,
in DynamicBuffer<OrbitCameraIgnoredEntityBufferElement> ignoredEntitiesBuffer)
{
if (OrbitCameraUtilities.TryGetCameraTargetInterpolatedWorldTransform(
cameraControl.FollowedCharacterEntity,
ref LocalToWorldLookup,
ref CameraTargetLookup,
out LocalToWorld targetWorldTransform))
{
quaternion cameraRotation = OrbitCameraUtilities.CalculateCameraRotation(targetWorldTransform.Up, orbitCamera.PlanarForward, orbitCamera.PitchAngle);
float3 cameraForward = math.mul(cameraRotation, math.forward());
float3 targetPosition = targetWorldTransform.Position;
// Distance smoothing
orbitCamera.SmoothedTargetDistance = math.lerp(orbitCamera.SmoothedTargetDistance, orbitCamera.TargetDistance, MathUtilities.GetSharpnessInterpolant(orbitCamera.DistanceMovementSharpness, DeltaTime));
// Obstruction handling
// Obstruction detection is handled here, because we have to adjust the obstruction distance
// to match the interpolated physics body transform (as opposed to the "simulation" transform). Otherwise, a
// camera getting obstructed by a moving physics body would have visible jitter.
if (orbitCamera.ObstructionRadius > 0f)
{
float obstructionCheckDistance = orbitCamera.SmoothedTargetDistance;
CameraObstructionHitsCollector collector = new CameraObstructionHitsCollector(cameraControl.FollowedCharacterEntity, ignoredEntitiesBuffer, cameraForward);
PhysicsWorld.SphereCastCustom(
targetPosition,
orbitCamera.ObstructionRadius,
-cameraForward,
obstructionCheckDistance,
ref collector,
CollisionFilter.Default,
QueryInteraction.IgnoreTriggers);
float newObstructedDistance = obstructionCheckDistance;
if (collector.NumHits > 0)
{
newObstructedDistance = obstructionCheckDistance * collector.ClosestHit.Fraction;
// Redo cast with the interpolated body transform to prevent FixedUpdate jitter in obstruction detection
if (orbitCamera.PreventFixedUpdateJitter)
{
RigidBody hitBody = PhysicsWorld.Bodies[collector.ClosestHit.RigidBodyIndex];
if (LocalToWorldLookup.TryGetComponent(hitBody.Entity, out LocalToWorld hitBodyLocalToWorld))
{
// Adjust the rigidbody transform for interpolation, so we can raycast it in that state
hitBody.WorldFromBody = new RigidTransform(quaternion.LookRotationSafe(hitBodyLocalToWorld.Forward, hitBodyLocalToWorld.Up), hitBodyLocalToWorld.Position);
collector = new CameraObstructionHitsCollector(cameraControl.FollowedCharacterEntity, ignoredEntitiesBuffer, cameraForward);
hitBody.SphereCastCustom(
targetPosition,
orbitCamera.ObstructionRadius,
-cameraForward,
obstructionCheckDistance,
ref collector,
CollisionFilter.Default,
QueryInteraction.IgnoreTriggers);
if (collector.NumHits > 0)
{
newObstructedDistance = obstructionCheckDistance * collector.ClosestHit.Fraction;
}
}
}
}
// Update current distance based on obstructed distance
if (orbitCamera.ObstructedDistance < newObstructedDistance)
{
// Move outer
orbitCamera.ObstructedDistance = math.lerp(orbitCamera.ObstructedDistance, newObstructedDistance, MathUtilities.GetSharpnessInterpolant(orbitCamera.ObstructionOuterSmoothingSharpness, DeltaTime));
}
else if (orbitCamera.ObstructedDistance > newObstructedDistance)
{
// Move inner
orbitCamera.ObstructedDistance = math.lerp(orbitCamera.ObstructedDistance, newObstructedDistance, MathUtilities.GetSharpnessInterpolant(orbitCamera.ObstructionInnerSmoothingSharpness, DeltaTime));
}
}
else
{
orbitCamera.ObstructedDistance = orbitCamera.SmoothedTargetDistance;
}
// Place camera at the final distance (includes smoothing and obstructions)
float3 cameraPosition = OrbitCameraUtilities.CalculateCameraPosition(targetPosition, cameraRotation, orbitCamera.ObstructedDistance);
// Write to LtW
LocalToWorldLookup[entity] = new LocalToWorld { Value = new float4x4(cameraRotation, cameraPosition) };
}
}
}
}
public static class OrbitCameraUtilities
{
public static bool TryGetCameraTargetSimulationWorldTransform(
Entity targetCharacterEntity,
ref ComponentLookup<LocalTransform> localTransformLookup,
ref ComponentLookup<Parent> parentLookup,
ref ComponentLookup<PostTransformMatrix> postTransformMatrixLookup,
ref ComponentLookup<CameraTarget> cameraTargetLookup,
out float4x4 worldTransform)
{
bool foundValidCameraTarget = false;
worldTransform = float4x4.identity;
// Camera target is either defined by the CameraTarget component, or if not, the transform of the followed character
if (cameraTargetLookup.TryGetComponent(targetCharacterEntity, out CameraTarget cameraTarget) &&
localTransformLookup.HasComponent(cameraTarget.TargetEntity))
{
TransformHelpers.ComputeWorldTransformMatrix(
cameraTarget.TargetEntity,
out worldTransform,
ref localTransformLookup,
ref parentLookup,
ref postTransformMatrixLookup);
foundValidCameraTarget = true;
}
else if (localTransformLookup.TryGetComponent(targetCharacterEntity, out LocalTransform characterLocalTransform))
{
worldTransform = float4x4.TRS(characterLocalTransform.Position, characterLocalTransform.Rotation, 1f);
foundValidCameraTarget = true;
}
return foundValidCameraTarget;
}
public static bool TryGetCameraTargetInterpolatedWorldTransform(
Entity targetCharacterEntity,
ref ComponentLookup<LocalToWorld> localToWorldLookup,
ref ComponentLookup<CameraTarget> cameraTargetLookup,
out LocalToWorld worldTransform)
{
bool foundValidCameraTarget = false;
worldTransform = default;
// Get the interpolated transform of the target
if (cameraTargetLookup.TryGetComponent(targetCharacterEntity, out CameraTarget cameraTarget) &&
localToWorldLookup.TryGetComponent(cameraTarget.TargetEntity, out worldTransform))
{
foundValidCameraTarget = true;
}
else if (localToWorldLookup.TryGetComponent(targetCharacterEntity, out worldTransform))
{
foundValidCameraTarget = true;
}
return foundValidCameraTarget;
}
public static quaternion CalculateCameraRotation(float3 targetUp, float3 planarForward, float pitchAngle)
{
quaternion pitchRotation = quaternion.Euler(math.right() * math.radians(pitchAngle));
quaternion cameraRotation = MathUtilities.CreateRotationWithUpPriority(targetUp, planarForward);
cameraRotation = math.mul(cameraRotation, pitchRotation);
return cameraRotation;
}
public static float3 CalculateCameraPosition(float3 targetPosition, quaternion cameraRotation, float distance)
{
return targetPosition + (-MathUtilities.GetForwardFromRotation(cameraRotation) * distance);
}
}
public struct CameraObstructionHitsCollector : ICollector<ColliderCastHit>
{
public bool EarlyOutOnFirstHit => false;
public float MaxFraction => 1f;
public int NumHits { get; private set; }
public ColliderCastHit ClosestHit;
private float _closestHitFraction;
private float3 _cameraDirection;
private Entity _followedCharacter;
private DynamicBuffer<OrbitCameraIgnoredEntityBufferElement> _ignoredEntitiesBuffer;
public CameraObstructionHitsCollector(Entity followedCharacter, DynamicBuffer<OrbitCameraIgnoredEntityBufferElement> ignoredEntitiesBuffer, float3 cameraDirection)
{
NumHits = 0;
ClosestHit = default;
_closestHitFraction = float.MaxValue;
_cameraDirection = cameraDirection;
_followedCharacter = followedCharacter;
_ignoredEntitiesBuffer = ignoredEntitiesBuffer;
}
public bool AddHit(ColliderCastHit hit)
{
if (_followedCharacter == hit.Entity)
{
return false;
}
if (math.dot(hit.SurfaceNormal, _cameraDirection) < 0f || !PhysicsUtilities.IsCollidable(hit.Material))
{
return false;
}
for (int i = 0; i < _ignoredEntitiesBuffer.Length; i++)
{
if (_ignoredEntitiesBuffer[i].Entity == hit.Entity)
{
return false;
}
}
// Process valid hit
if (hit.Fraction < _closestHitFraction)
{
_closestHitFraction = hit.Fraction;
ClosestHit = hit;
}
NumHits++;
return true;
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 6d6d36bc694f390408f5683be8de8c7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,224 +0,0 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.CharacterController;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Physics.Authoring;
using Unity.Physics.Extensions;
using Unity.Physics.Systems;
using Unity.Transforms;
using UnityEngine;
public struct ThirdPersonCharacterUpdateContext
{
// Here, you may add additional global data for your character updates, such as ComponentLookups, Singletons, NativeCollections, etc...
// The data you add here will be accessible in your character updates and all of your character "callbacks".
public void OnSystemCreate(ref SystemState state)
{
// Get lookups
}
public void OnSystemUpdate(ref SystemState state)
{
// Update lookups
}
}
public readonly partial struct ThirdPersonCharacterAspect : IAspect, IKinematicCharacterProcessor<ThirdPersonCharacterUpdateContext>
{
public readonly KinematicCharacterAspect CharacterAspect;
public readonly RefRW<ThirdPersonCharacterComponent> CharacterComponent;
public readonly RefRW<ThirdPersonCharacterControl> CharacterControl;
public void PhysicsUpdate(ref ThirdPersonCharacterUpdateContext context, ref KinematicCharacterUpdateContext baseContext)
{
ref ThirdPersonCharacterComponent characterComponent = ref CharacterComponent.ValueRW;
ref KinematicCharacterBody characterBody = ref CharacterAspect.CharacterBody.ValueRW;
ref float3 characterPosition = ref CharacterAspect.LocalTransform.ValueRW.Position;
// First phase of default character update
CharacterAspect.Update_Initialize(in this, ref context, ref baseContext, ref characterBody, baseContext.Time.DeltaTime);
CharacterAspect.Update_ParentMovement(in this, ref context, ref baseContext, ref characterBody, ref characterPosition, characterBody.WasGroundedBeforeCharacterUpdate);
CharacterAspect.Update_Grounding(in this, ref context, ref baseContext, ref characterBody, ref characterPosition);
// Update desired character velocity after grounding was detected, but before doing additional processing that depends on velocity
HandleVelocityControl(ref context, ref baseContext);
// Second phase of default character update
CharacterAspect.Update_PreventGroundingFromFutureSlopeChange(in this, ref context, ref baseContext, ref characterBody, in characterComponent.StepAndSlopeHandling);
CharacterAspect.Update_GroundPushing(in this, ref context, ref baseContext, characterComponent.Gravity);
CharacterAspect.Update_MovementAndDecollisions(in this, ref context, ref baseContext, ref characterBody, ref characterPosition);
CharacterAspect.Update_MovingPlatformDetection(ref baseContext, ref characterBody);
CharacterAspect.Update_ParentMomentum(ref baseContext, ref characterBody);
CharacterAspect.Update_ProcessStatefulCharacterHits();
}
private void HandleVelocityControl(ref ThirdPersonCharacterUpdateContext context, ref KinematicCharacterUpdateContext baseContext)
{
float deltaTime = baseContext.Time.DeltaTime;
ref KinematicCharacterBody characterBody = ref CharacterAspect.CharacterBody.ValueRW;
ref ThirdPersonCharacterComponent characterComponent = ref CharacterComponent.ValueRW;
ref ThirdPersonCharacterControl characterControl = ref CharacterControl.ValueRW;
// Rotate move input and velocity to take into account parent rotation
if(characterBody.ParentEntity != Entity.Null)
{
characterControl.MoveVector = math.rotate(characterBody.RotationFromParent, characterControl.MoveVector);
characterBody.RelativeVelocity = math.rotate(characterBody.RotationFromParent, characterBody.RelativeVelocity);
}
if (characterBody.IsGrounded)
{
// Move on ground
float3 targetVelocity = characterControl.MoveVector * characterComponent.GroundMaxSpeed;
CharacterControlUtilities.StandardGroundMove_Interpolated(ref characterBody.RelativeVelocity, targetVelocity, characterComponent.GroundedMovementSharpness, deltaTime, characterBody.GroundingUp, characterBody.GroundHit.Normal);
// Jump
if (characterControl.Jump)
{
CharacterControlUtilities.StandardJump(ref characterBody, characterBody.GroundingUp * characterComponent.JumpSpeed, true, characterBody.GroundingUp);
}
}
else
{
// Move in air
float3 airAcceleration = characterControl.MoveVector * characterComponent.AirAcceleration;
if (math.lengthsq(airAcceleration) > 0f)
{
float3 tmpVelocity = characterBody.RelativeVelocity;
CharacterControlUtilities.StandardAirMove(ref characterBody.RelativeVelocity, airAcceleration, characterComponent.AirMaxSpeed, characterBody.GroundingUp, deltaTime, false);
// Cancel air acceleration from input if we would hit a non-grounded surface (prevents air-climbing slopes at high air accelerations)
if (characterComponent.PreventAirAccelerationAgainstUngroundedHits && CharacterAspect.MovementWouldHitNonGroundedObstruction(in this, ref context, ref baseContext, characterBody.RelativeVelocity * deltaTime, out ColliderCastHit hit))
{
characterBody.RelativeVelocity = tmpVelocity;
}
}
// Gravity
CharacterControlUtilities.AccelerateVelocity(ref characterBody.RelativeVelocity, characterComponent.Gravity, deltaTime);
// Drag
CharacterControlUtilities.ApplyDragToVelocity(ref characterBody.RelativeVelocity, deltaTime, characterComponent.AirDrag);
}
}
public void VariableUpdate(ref ThirdPersonCharacterUpdateContext context, ref KinematicCharacterUpdateContext baseContext)
{
ref KinematicCharacterBody characterBody = ref CharacterAspect.CharacterBody.ValueRW;
ref ThirdPersonCharacterComponent characterComponent = ref CharacterComponent.ValueRW;
ref ThirdPersonCharacterControl characterControl = ref CharacterControl.ValueRW;
ref quaternion characterRotation = ref CharacterAspect.LocalTransform.ValueRW.Rotation;
// Add rotation from parent body to the character rotation
// (this is for allowing a rotating moving platform to rotate your character as well, and handle interpolation properly)
KinematicCharacterUtilities.AddVariableRateRotationFromFixedRateRotation(ref characterRotation, characterBody.RotationFromParent, baseContext.Time.DeltaTime, characterBody.LastPhysicsUpdateDeltaTime);
// Rotate towards move direction
if (math.lengthsq(characterControl.MoveVector) > 0f)
{
CharacterControlUtilities.SlerpRotationTowardsDirectionAroundUp(ref characterRotation, baseContext.Time.DeltaTime, math.normalizesafe(characterControl.MoveVector), MathUtilities.GetUpFromRotation(characterRotation), characterComponent.RotationSharpness);
}
}
#region Character Processor Callbacks
public void UpdateGroundingUp(
ref ThirdPersonCharacterUpdateContext context,
ref KinematicCharacterUpdateContext baseContext)
{
ref KinematicCharacterBody characterBody = ref CharacterAspect.CharacterBody.ValueRW;
CharacterAspect.Default_UpdateGroundingUp(ref characterBody);
}
public bool CanCollideWithHit(
ref ThirdPersonCharacterUpdateContext context,
ref KinematicCharacterUpdateContext baseContext,
in BasicHit hit)
{
return PhysicsUtilities.IsCollidable(hit.Material);
}
public bool IsGroundedOnHit(
ref ThirdPersonCharacterUpdateContext context,
ref KinematicCharacterUpdateContext baseContext,
in BasicHit hit,
int groundingEvaluationType)
{
ThirdPersonCharacterComponent characterComponent = CharacterComponent.ValueRO;
return CharacterAspect.Default_IsGroundedOnHit(
in this,
ref context,
ref baseContext,
in hit,
in characterComponent.StepAndSlopeHandling,
groundingEvaluationType);
}
public void OnMovementHit(
ref ThirdPersonCharacterUpdateContext context,
ref KinematicCharacterUpdateContext baseContext,
ref KinematicCharacterHit hit,
ref float3 remainingMovementDirection,
ref float remainingMovementLength,
float3 originalVelocityDirection,
float hitDistance)
{
ref KinematicCharacterBody characterBody = ref CharacterAspect.CharacterBody.ValueRW;
ref float3 characterPosition = ref CharacterAspect.LocalTransform.ValueRW.Position;
ThirdPersonCharacterComponent characterComponent = CharacterComponent.ValueRO;
CharacterAspect.Default_OnMovementHit(
in this,
ref context,
ref baseContext,
ref characterBody,
ref characterPosition,
ref hit,
ref remainingMovementDirection,
ref remainingMovementLength,
originalVelocityDirection,
hitDistance,
characterComponent.StepAndSlopeHandling.StepHandling,
characterComponent.StepAndSlopeHandling.MaxStepHeight,
characterComponent.StepAndSlopeHandling.CharacterWidthForStepGroundingCheck);
}
public void OverrideDynamicHitMasses(
ref ThirdPersonCharacterUpdateContext context,
ref KinematicCharacterUpdateContext baseContext,
ref PhysicsMass characterMass,
ref PhysicsMass otherMass,
BasicHit hit)
{
// Custom mass overrides
}
public void ProjectVelocityOnHits(
ref ThirdPersonCharacterUpdateContext context,
ref KinematicCharacterUpdateContext baseContext,
ref float3 velocity,
ref bool characterIsGrounded,
ref BasicHit characterGroundHit,
in DynamicBuffer<KinematicVelocityProjectionHit> velocityProjectionHits,
float3 originalVelocityDirection)
{
ThirdPersonCharacterComponent characterComponent = CharacterComponent.ValueRO;
CharacterAspect.Default_ProjectVelocityOnHits(
ref velocity,
ref characterIsGrounded,
ref characterGroundHit,
in velocityProjectionHits,
originalVelocityDirection,
characterComponent.StepAndSlopeHandling.ConstrainVelocityToGroundPlane);
}
#endregion
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 2e1982b631c39194b8eaa4838ec11284
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,50 +0,0 @@
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics.Authoring;
using UnityEngine;
using Unity.CharacterController;
using Unity.Physics;
using UnityEngine.Serialization;
[DisallowMultipleComponent]
public class ThirdPersonCharacterAuthoring : MonoBehaviour
{
public AuthoringKinematicCharacterProperties CharacterProperties = AuthoringKinematicCharacterProperties.GetDefault();
public float RotationSharpness = 25f;
public float GroundMaxSpeed = 10f;
public float GroundedMovementSharpness = 15f;
public float AirAcceleration = 50f;
public float AirMaxSpeed = 10f;
public float AirDrag = 0f;
public float JumpSpeed = 10f;
public float3 Gravity = math.up() * -30f;
public bool PreventAirAccelerationAgainstUngroundedHits = true;
public BasicStepAndSlopeHandlingParameters StepAndSlopeHandling = BasicStepAndSlopeHandlingParameters.GetDefault();
public class Baker : Baker<ThirdPersonCharacterAuthoring>
{
public override void Bake(ThirdPersonCharacterAuthoring authoring)
{
KinematicCharacterUtilities.BakeCharacter(this, authoring.gameObject, authoring.CharacterProperties);
Entity entity = GetEntity(TransformUsageFlags.Dynamic | TransformUsageFlags.WorldSpace);
AddComponent(entity, new ThirdPersonCharacterComponent
{
RotationSharpness = authoring.RotationSharpness,
GroundMaxSpeed = authoring.GroundMaxSpeed,
GroundedMovementSharpness = authoring.GroundedMovementSharpness,
AirAcceleration = authoring.AirAcceleration,
AirMaxSpeed = authoring.AirMaxSpeed,
AirDrag = authoring.AirDrag,
JumpSpeed = authoring.JumpSpeed,
Gravity = authoring.Gravity,
PreventAirAccelerationAgainstUngroundedHits = authoring.PreventAirAccelerationAgainstUngroundedHits,
StepAndSlopeHandling = authoring.StepAndSlopeHandling,
});
AddComponent(entity, new ThirdPersonCharacterControl());
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c854a728d43c7cf47bec103607a449f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,28 +0,0 @@
using System;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
using Unity.CharacterController;
[Serializable]
public struct ThirdPersonCharacterComponent : IComponentData
{
public float RotationSharpness;
public float GroundMaxSpeed;
public float GroundedMovementSharpness;
public float AirAcceleration;
public float AirMaxSpeed;
public float AirDrag;
public float JumpSpeed;
public float3 Gravity;
public bool PreventAirAccelerationAgainstUngroundedHits;
public BasicStepAndSlopeHandlingParameters StepAndSlopeHandling;
}
[Serializable]
public struct ThirdPersonCharacterControl : IComponentData
{
public float3 MoveVector;
public bool Jump;
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: d8471dfde63584745b2234708055b211
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,137 +0,0 @@
using Unity.Burst;
using Unity.Entities;
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Transforms;
using Unity.CharacterController;
using Unity.Burst.Intrinsics;
[UpdateInGroup(typeof(KinematicCharacterPhysicsUpdateGroup))]
[BurstCompile]
public partial struct ThirdPersonCharacterPhysicsUpdateSystem : ISystem
{
private EntityQuery _characterQuery;
private ThirdPersonCharacterUpdateContext _context;
private KinematicCharacterUpdateContext _baseContext;
[BurstCompile]
public void OnCreate(ref SystemState state)
{
_characterQuery = KinematicCharacterUtilities.GetBaseCharacterQueryBuilder()
.WithAll<
ThirdPersonCharacterComponent,
ThirdPersonCharacterControl>()
.Build(ref state);
_context = new ThirdPersonCharacterUpdateContext();
_context.OnSystemCreate(ref state);
_baseContext = new KinematicCharacterUpdateContext();
_baseContext.OnSystemCreate(ref state);
state.RequireForUpdate(_characterQuery);
state.RequireForUpdate<PhysicsWorldSingleton>();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
_context.OnSystemUpdate(ref state);
_baseContext.OnSystemUpdate(ref state, SystemAPI.Time, SystemAPI.GetSingleton<PhysicsWorldSingleton>());
ThirdPersonCharacterPhysicsUpdateJob job = new ThirdPersonCharacterPhysicsUpdateJob
{
Context = _context,
BaseContext = _baseContext,
};
job.ScheduleParallel();
}
[BurstCompile]
[WithAll(typeof(Simulate))]
public partial struct ThirdPersonCharacterPhysicsUpdateJob : IJobEntity, IJobEntityChunkBeginEnd
{
public ThirdPersonCharacterUpdateContext Context;
public KinematicCharacterUpdateContext BaseContext;
void Execute(ThirdPersonCharacterAspect characterAspect)
{
characterAspect.PhysicsUpdate(ref Context, ref BaseContext);
}
public bool OnChunkBegin(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
{
BaseContext.EnsureCreationOfTmpCollections();
return true;
}
public void OnChunkEnd(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask, bool chunkWasExecuted)
{ }
}
}
[UpdateInGroup(typeof(SimulationSystemGroup))]
[UpdateAfter(typeof(FixedStepSimulationSystemGroup))]
[UpdateAfter(typeof(ThirdPersonPlayerVariableStepControlSystem))]
[UpdateBefore(typeof(TransformSystemGroup))]
[BurstCompile]
public partial struct ThirdPersonCharacterVariableUpdateSystem : ISystem
{
private EntityQuery _characterQuery;
private ThirdPersonCharacterUpdateContext _context;
private KinematicCharacterUpdateContext _baseContext;
[BurstCompile]
public void OnCreate(ref SystemState state)
{
_characterQuery = KinematicCharacterUtilities.GetBaseCharacterQueryBuilder()
.WithAll<
ThirdPersonCharacterComponent,
ThirdPersonCharacterControl>()
.Build(ref state);
_context = new ThirdPersonCharacterUpdateContext();
_context.OnSystemCreate(ref state);
_baseContext = new KinematicCharacterUpdateContext();
_baseContext.OnSystemCreate(ref state);
state.RequireForUpdate(_characterQuery);
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
_context.OnSystemUpdate(ref state);
_baseContext.OnSystemUpdate(ref state, SystemAPI.Time, SystemAPI.GetSingleton<PhysicsWorldSingleton>());
ThirdPersonCharacterVariableUpdateJob job = new ThirdPersonCharacterVariableUpdateJob
{
Context = _context,
BaseContext = _baseContext,
};
job.ScheduleParallel();
}
[BurstCompile]
[WithAll(typeof(Simulate))]
public partial struct ThirdPersonCharacterVariableUpdateJob : IJobEntity, IJobEntityChunkBeginEnd
{
public ThirdPersonCharacterUpdateContext Context;
public KinematicCharacterUpdateContext BaseContext;
void Execute(ThirdPersonCharacterAspect characterAspect)
{
characterAspect.VariableUpdate(ref Context, ref BaseContext);
}
public bool OnChunkBegin(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
{
BaseContext.EnsureCreationOfTmpCollections();
return true;
}
public void OnChunkEnd(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask, bool chunkWasExecuted)
{ }
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b37392a281d8a5f45a770ad4cfd747a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,20 +0,0 @@
using System;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
[Serializable]
public struct ThirdPersonPlayer : IComponentData
{
public Entity ControlledCharacter;
public Entity ControlledCamera;
}
[Serializable]
public struct ThirdPersonPlayerInputs : IComponentData
{
public float2 MoveInput;
public float2 CameraLookInput;
public float CameraZoomInput;
public FixedInputEvent JumpPressed;
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 8586d18bf7667c040949956b7ff40b6d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,23 +0,0 @@
using UnityEngine;
using Unity.Entities;
[DisallowMultipleComponent]
public class ThirdPersonPlayerAuthoring : MonoBehaviour
{
public GameObject ControlledCharacter;
public GameObject ControlledCamera;
public class Baker : Baker<ThirdPersonPlayerAuthoring>
{
public override void Bake(ThirdPersonPlayerAuthoring authoring)
{
Entity entity = GetEntity(TransformUsageFlags.None);
AddComponent(entity, new ThirdPersonPlayer
{
ControlledCharacter = GetEntity(authoring.ControlledCharacter, TransformUsageFlags.Dynamic),
ControlledCamera = GetEntity(authoring.ControlledCamera, TransformUsageFlags.Dynamic),
});
AddComponent<ThirdPersonPlayerInputs>(entity);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3fbdb3174a73a07408595a85d3e7fb6a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,127 +0,0 @@
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
using Unity.CharacterController;
[UpdateInGroup(typeof(InitializationSystemGroup))]
public partial class ThirdPersonPlayerInputsSystem : SystemBase
{
protected override void OnCreate()
{
RequireForUpdate<FixedTickSystem.Singleton>();
RequireForUpdate(SystemAPI.QueryBuilder().WithAll<ThirdPersonPlayer, ThirdPersonPlayerInputs>().Build());
}
protected override void OnUpdate()
{
uint tick = SystemAPI.GetSingleton<FixedTickSystem.Singleton>().Tick;
foreach (var (playerInputs, player) in SystemAPI.Query<RefRW<ThirdPersonPlayerInputs>, ThirdPersonPlayer>())
{
playerInputs.ValueRW.MoveInput = new float2
{
x = (Input.GetKey(KeyCode.D) ? 1f : 0f) + (Input.GetKey(KeyCode.A) ? -1f : 0f),
y = (Input.GetKey(KeyCode.W) ? 1f : 0f) + (Input.GetKey(KeyCode.S) ? -1f : 0f),
};
playerInputs.ValueRW.CameraLookInput = new float2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
playerInputs.ValueRW.CameraZoomInput = -Input.mouseScrollDelta.y;
if (Input.GetKeyDown(KeyCode.Space))
{
playerInputs.ValueRW.JumpPressed.Set(tick);
}
}
}
}
/// <summary>
/// Apply inputs that need to be read at a variable rate
/// </summary>
[UpdateInGroup(typeof(SimulationSystemGroup))]
[UpdateAfter(typeof(FixedStepSimulationSystemGroup))]
[BurstCompile]
public partial struct ThirdPersonPlayerVariableStepControlSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate(SystemAPI.QueryBuilder().WithAll<ThirdPersonPlayer, ThirdPersonPlayerInputs>().Build());
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
foreach (var (playerInputs, player) in SystemAPI.Query<ThirdPersonPlayerInputs, ThirdPersonPlayer>().WithAll<Simulate>())
{
if (SystemAPI.HasComponent<OrbitCameraControl>(player.ControlledCamera))
{
OrbitCameraControl cameraControl = SystemAPI.GetComponent<OrbitCameraControl>(player.ControlledCamera);
cameraControl.FollowedCharacterEntity = player.ControlledCharacter;
cameraControl.LookDegreesDelta = playerInputs.CameraLookInput;
cameraControl.ZoomDelta = playerInputs.CameraZoomInput;
SystemAPI.SetComponent(player.ControlledCamera, cameraControl);
}
}
}
}
/// <summary>
/// Apply inputs that need to be read at a fixed rate.
/// It is necessary to handle this as part of the fixed step group, in case your framerate is lower than the fixed step rate.
/// </summary>
[UpdateInGroup(typeof(FixedStepSimulationSystemGroup), OrderFirst = true)]
[BurstCompile]
public partial struct ThirdPersonPlayerFixedStepControlSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<FixedTickSystem.Singleton>();
state.RequireForUpdate(SystemAPI.QueryBuilder().WithAll<ThirdPersonPlayer, ThirdPersonPlayerInputs>().Build());
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
uint tick = SystemAPI.GetSingleton<FixedTickSystem.Singleton>().Tick;
foreach (var (playerInputs, player) in SystemAPI.Query<ThirdPersonPlayerInputs, ThirdPersonPlayer>().WithAll<Simulate>())
{
if (SystemAPI.HasComponent<ThirdPersonCharacterControl>(player.ControlledCharacter))
{
ThirdPersonCharacterControl characterControl = SystemAPI.GetComponent<ThirdPersonCharacterControl>(player.ControlledCharacter);
float3 characterUp = MathUtilities.GetUpFromRotation(SystemAPI.GetComponent<LocalTransform>(player.ControlledCharacter).Rotation);
// Get camera rotation, since our movement is relative to it.
quaternion cameraRotation = quaternion.identity;
if (SystemAPI.HasComponent<OrbitCamera>(player.ControlledCamera))
{
// Camera rotation is calculated rather than gotten from transform, because this allows us to
// reduce the size of the camera ghost state in a netcode prediction context.
// If not using netcode prediction, we could simply get rotation from transform here instead.
OrbitCamera orbitCamera = SystemAPI.GetComponent<OrbitCamera>(player.ControlledCamera);
cameraRotation = OrbitCameraUtilities.CalculateCameraRotation(characterUp, orbitCamera.PlanarForward, orbitCamera.PitchAngle);
}
float3 cameraForwardOnUpPlane = math.normalizesafe(MathUtilities.ProjectOnPlane(MathUtilities.GetForwardFromRotation(cameraRotation), characterUp));
float3 cameraRight = MathUtilities.GetRightFromRotation(cameraRotation);
// Move
characterControl.MoveVector = (playerInputs.MoveInput.y * cameraForwardOnUpPlane) + (playerInputs.MoveInput.x * cameraRight);
characterControl.MoveVector = MathUtilities.ClampToMaxLength(characterControl.MoveVector, 1f);
// Jump
characterControl.Jump = playerInputs.JumpPressed.IsSet(tick);
SystemAPI.SetComponent(player.ControlledCharacter, characterControl);
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 427fac77ddc96db4a87e6d5b4a31555f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -163,8 +163,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8c277d7b8d296f0418bcdc6075f1e394, type: 3}
m_Name:
m_EditorClassIdentifier:
PrefabCharacter: {fileID: 1555240849038293811, guid: 3ec06d4b739fd724c83484d1713584a8, type: 3}
PrefabFPSPlayer: {fileID: 577874318210893199, guid: fb25bd25e66169c4f83a52201b051ba2, type: 3}
PrefabCharacter: {fileID: 1248813991221940096, guid: 1d0dd41a9ab5e3a4ea7626a3fb8fbcc3, type: 3}
PrefabFPSPlayer: {fileID: 5756556331676690795, guid: 7d31de590ce492146824ea754807601c, type: 3}
--- !u!1 &1798493387
GameObject:
m_ObjectHideFlags: 0
@ -178,7 +178,7 @@ GameObject:
- component: {fileID: 1798493389}
- component: {fileID: 1798493388}
m_Layer: 0
m_Name: Cube
m_Name: Floor
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

View File

@ -11,6 +11,7 @@ namespace Client
{
private EntityQuery _pendingNetworkIdQuery;
[BurstCompile]
public void OnCreate(ref SystemState state)
{
//Get all entities connected to the server (having networkID), but not in game yet (no NetworkStreamInGame)
@ -22,11 +23,16 @@ namespace Client
state.RequireForUpdate<ClientTeamRequest>();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
//Get Requested team and all network ids that want to join
var teamrequest = SystemAPI.GetSingleton<ClientTeamRequest>();
var ecb = new EntityCommandBuffer(Allocator.Temp);
var ecb = SystemAPI.GetSingletonRW<EndSimulationEntityCommandBufferSystem.Singleton>().ValueRW
.CreateCommandBuffer(state.WorldUnmanaged);
var pendingNetworkIds = _pendingNetworkIdQuery.ToEntityArray(Allocator.Temp);
foreach (var pendingNetworkId in pendingNetworkIds)
@ -49,9 +55,6 @@ namespace Client
TargetConnection = pendingNetworkId
});
}
//Broadcast Rpc - playback disposes of ecb
ecb.Playback(state.EntityManager);
}
}
}

View File

@ -14,6 +14,7 @@ namespace Server
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
public partial struct ServerProcessGameEntryRequestSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<TdPrefabs>();
@ -22,21 +23,19 @@ namespace Server
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var ecb = new EntityCommandBuffer(Allocator.Temp);
// var ecb = new EntityCommandBuffer(Allocator.Temp);
var ecb = SystemAPI.GetSingletonRW<EndSimulationEntityCommandBufferSystem.Singleton>().ValueRW
.CreateCommandBuffer(state.WorldUnmanaged);
var tdPrefabs = SystemAPI.GetSingleton<TdPrefabs>();
var characterPrefab = tdPrefabs.Character;
var fpsPlayerPrefab = tdPrefabs.FPSPlayer;
foreach (var (teamRequest, requestSource, requestEntity) in SystemAPI.Query<TdTeamRequest, ReceiveRpcCommandRequest>().WithEntityAccess())
{
//destroy request entity that only holds request
ecb.DestroyEntity(requestEntity);
//sync server connection entity with client connection entity
ecb.AddComponent<NetworkStreamInGame>(requestSource.SourceConnection);
var requestedTeam = teamRequest.Value;
var requestedColor = teamRequest.Color;
@ -54,37 +53,47 @@ namespace Server
break;
}
Debug.Log($"Server is assigning ClientId {clientId} to team {requestedTeam}");
var newCharacter = ecb.Instantiate(characterPrefab);
var newFPSPlayer = ecb.Instantiate(fpsPlayerPrefab);
ecb.SetName(newCharacter, "Character");
//instantiate prefab
var characterEntity = ecb.Instantiate(tdPrefabs.Character);
var playerEntity = ecb.Instantiate(tdPrefabs.FPSPlayer);
//Destroy character prefab, when client disconnects
ecb.AppendToBuffer(requestSource.SourceConnection, new LinkedEntityGroup{Value = characterEntity});
ecb.AppendToBuffer(requestSource.SourceConnection, new LinkedEntityGroup{Value = playerEntity});
//Setup ghost owner
ecb.SetComponent(characterEntity, new GhostOwner { NetworkId = clientId});
ecb.SetComponent(playerEntity, new GhostOwner { NetworkId = clientId});
ecb.SetName(characterEntity, "Character");
//Set position
var newTransform = LocalTransform.FromPosition(spawnPosition);
ecb.SetComponent(newCharacter, newTransform);
ecb.SetComponent(characterEntity, newTransform);
ecb.SetComponent(newCharacter, new GhostOwner { NetworkId = clientId});
ecb.SetComponent(newFPSPlayer, new GhostOwner { NetworkId = clientId});
ecb.SetComponent(newCharacter, new TdTeam { Value = requestedTeam });
//Set config and Team
ecb.SetComponent(characterEntity, new TdTeam { Value = requestedTeam });
ecb.SetComponent(newCharacter, new CharacterConfig
ecb.SetComponent(characterEntity, new CharacterConfig
{
Color = requestedColor
});
//Setup connection
FirstPersonPlayer playerComponent = SystemAPI.GetComponent<FirstPersonPlayer>(tdPrefabs.FPSPlayer);
playerComponent.ControlledCharacter = newCharacter;
ecb.SetComponent(newFPSPlayer, playerComponent);
playerComponent.ControlledCharacter = characterEntity;
ecb.SetComponent(playerEntity, playerComponent);
//Destroy character prefab, when client disconnects
ecb.AppendToBuffer(requestSource.SourceConnection, new LinkedEntityGroup{Value = newCharacter});
ecb.AppendToBuffer(requestSource.SourceConnection, new LinkedEntityGroup{Value = newFPSPlayer});
//sync server connection entity with client connection entity
ecb.AddComponent<NetworkStreamInGame>(requestSource.SourceConnection);
//destroy request entity that only holds request
ecb.DestroyEntity(requestEntity);
}
ecb.Playback(state.EntityManager);
}
}
}

View File

@ -10,7 +10,7 @@
"url": "https://packages.unity.com"
},
"com.unity.burst": {
"version": "1.8.18",
"version": "1.8.19",
"depth": 2,
"source": "registry",
"dependencies": {

View File

@ -141,7 +141,8 @@ PlayerSettings:
visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0
bundleVersion: 0.1.0
preloadedAssets: []
preloadedAssets:
- {fileID: -944628639613478452, guid: 052faaac586de48259a63d0c4782560b, type: 3}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1

View File

@ -1,2 +1,2 @@
m_EditorVersion: 6000.0.36f1
m_EditorVersionWithRevision: 6000.0.36f1 (9fe3b5f71dbb)
m_EditorVersion: 6000.0.37f1
m_EditorVersionWithRevision: 6000.0.37f1 (090b7797214c)