浏览代码

removing stray scripts from initial-setup branch, and removing SampleScene which has been moved, and thus duplicated by this merge

/main
David Woodruff 4 年前
当前提交
65abb54f
共有 13 个文件被更改,包括 0 次插入932 次删除
  1. 8
      Assets/Scenes/SampleScene.meta
  2. 648
      Assets/Scenes/SampleScene.unity
  3. 88
      Assets/Scripts/Character.cs
  4. 11
      Assets/Scripts/Character.cs.meta
  5. 25
      Assets/Scripts/Interpolation.cs
  6. 11
      Assets/Scripts/Interpolation.cs.meta
  7. 40
      Assets/Scripts/PlayerInput.cs
  8. 11
      Assets/Scripts/PlayerInput.cs.meta
  9. 19
      Assets/Scripts/PositionInterpolation.cs
  10. 11
      Assets/Scripts/PositionInterpolation.cs.meta
  11. 49
      Assets/Scripts/SimulationManager.cs
  12. 11
      Assets/Scripts/SimulationManager.cs.meta

8
Assets/Scenes/SampleScene.meta


fileFormatVersion: 2
guid: d35e52e80fddfa34e8598be81bb477bb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

648
Assets/Scenes/SampleScene.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 0
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 23800000, guid: c7720ceef5c5df34c98168df9d4f695e, type: 2}
--- !u!1 &532797402
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 532797406}
- component: {fileID: 532797405}
- component: {fileID: 532797404}
- component: {fileID: 532797403}
m_Layer: 0
m_Name: Plane
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!64 &532797403
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 532797402}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 4
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &532797404
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 532797402}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
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 &532797405
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 532797402}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &532797406
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 532797402}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: -1, z: 10}
m_LocalScale: {x: 2, y: 2, z: 2}
m_Children: []
m_Father: {fileID: 1233618361}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 705507995}
- component: {fileID: 705507994}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!108 &705507994
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 1
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &705507995
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 2, z: 10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1233618361}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 963194228}
- component: {fileID: 963194227}
- component: {fileID: 963194226}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &963194226
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
--- !u!20 &963194227
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &963194228
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0.5, y: 0, z: 0, w: 0.8660254}
m_LocalPosition: {x: 0, y: 10, z: -5.62}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}
--- !u!1 &1069853755
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1069853757}
- component: {fileID: 1069853756}
- component: {fileID: 1069853760}
- component: {fileID: 1069853759}
- component: {fileID: 1069853758}
- component: {fileID: 1069853761}
m_Layer: 0
m_Name: NetworkingManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1069853756
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1069853755}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 593a2fe42fa9d37498c96f9a383b6521, type: 3}
m_Name:
m_EditorClassIdentifier:
DontDestroy: 1
RunInBackground: 1
LogLevel: 1
NetworkConfig:
ProtocolVersion: 0
NetworkTransport: {fileID: 1069853760}
RegisteredScenes:
- SampleScene
AllowRuntimeSceneChanges: 0
NetworkedPrefabs:
- Prefab: {fileID: 922472105905938403, guid: e57f88b20c296674cb0c1517a43f99da, type: 3}
PlayerPrefab: 1
PlayerPrefabHash:
id: 0
CreatePlayerPrefab: 1
ReceiveTickrate: 0
MaxReceiveEventsPerTickRate: 1000
EventTickrate: 0
MaxObjectUpdatesPerTick: -1
ClientConnectionBufferTimeout: 10
ConnectionApproval: 0
ConnectionData:
SecondsHistory: 0
EnableTimeResync: 0
TimeResyncInterval: 30
EnableNetworkedVar: 0
EnsureNetworkedVarLengthSafety: 0
EnableSceneManagement: 0
ForceSamePrefabs: 1
UsePrefabSync: 0
RecycleNetworkIds: 1
NetworkIdRecycleDelay: 120
RpcHashSize: 0
LoadSceneTimeOut: 120
EnableMessageBuffering: 0
MessageBufferTimeout: 20
EnableNetworkLogs: 1
EnableEncryption: 0
SignKeyExchange: 0
ServerBase64PfxCertificate:
references:
version: 1
00000000:
type: {class: NullableBoolSerializable, ns: MLAPI.Configuration, asm: Unity.Multiplayer.MLAPI.Runtime}
data:
Value: 6075374942793011955
--- !u!4 &1069853757
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1069853755}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1069853758
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1069853755}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 52c005b32a68a254cbe502a4e5cb8eb6, type: 3}
m_Name:
m_EditorClassIdentifier:
appId: bc5b8b0d-edf3-4c61-9593-ce38da7f0c79
gameVersion: 0.0.0
region: EU
nickName:
roomName:
maxPlayers: 4
batchedTransportEventCode: 129
channelIdCodesStartRange: 130
attachSupportLogger: 1
sendQueueBatchSize: 4096
--- !u!114 &1069853759
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1069853755}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: db28424c2ae12f64da25c9ecccded6b1, type: 3}
m_Name:
m_EditorClassIdentifier:
Port: 7777
Address: 127.0.0.1
PingInterval: 1
DisconnectTimeout: 5
ReconnectDelay: 0.5
MaxConnectAttempts: 10
channels: []
MessageBufferSize: 5120
SimulatePacketLossChance: 0
SimulateMinLatency: 0
SimulateMaxLatency: 0
--- !u!114 &1069853760
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1069853755}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b84c2d8dfe509a34fb59e2b81f8e1319, type: 3}
m_Name:
m_EditorClassIdentifier:
MessageBufferSize: 5120
MaxConnections: 100
MaxSentMessageQueueSize: 128
ConnectAddress: 127.0.0.1
ConnectPort: 7777
ServerListenPort: 7777
ServerWebsocketListenPort: 8887
SupportWebsocket: 0
Channels: []
UseMLAPIRelay: 0
MLAPIRelayAddress: 184.72.104.138
MLAPIRelayPort: 8888
MessageSendMode: 0
--- !u!114 &1069853761
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1069853755}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e26f82009f8f36d45a99adae79eab7b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1233618360
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1233618361}
m_Layer: 0
m_Name: Environment
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!4 &1233618361
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1233618360}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 532797406}
- {fileID: 705507995}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1601651753
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1601651754}
- component: {fileID: 1601651755}
m_Layer: 0
m_Name: SimulationManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1601651754
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1601651753}
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_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1601651755
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1601651753}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3e6c31da8c35c2743b0311f50e3e1a69, type: 3}
m_Name:
m_EditorClassIdentifier:
tickRate: 20

88
Assets/Scripts/Character.cs


using MLAPI;
using MLAPI.Messaging;
using System;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.AI;
public class Character : NetworkedBehaviour
{
[SerializeField]
private float movementSpeed;
private NavMeshAgent _navMeshAgent;
private NavMeshPath _path;
private PositionInterpolation _interpolation;
public void Awake()
{
_path = new NavMeshPath();
_navMeshAgent = GetComponent<NavMeshAgent>();
_interpolation = GetComponentInChildren<PositionInterpolation>();
}
///<inheritdoc/>
public override void NetworkStart()
{
base.NetworkStart();
SimulationManager.Singleton.OnSimulationUpdate += SimulationUpdate;
SimulationManager.Singleton.OnSyncNetworkEvents += SyncNetworkEvents;
_navMeshAgent.updateRotation = false;
_navMeshAgent.updatePosition = true;
if (!IsServer)
{
Destroy(_navMeshAgent);
}
}
private void SyncNetworkEvents(float time, float deltaTime)
{
if (IsServer)
{
_interpolation.AddValue(time, transform.position);
InvokeClientRpcOnEveryoneExcept<float, Vector3>(ReplicatePosition, NetworkingManager.Singleton.ServerClientId, time, transform.position);
}
}
public void SetMovementTarget(Vector3 position)
{
_navMeshAgent.CalculatePath(position, _path);
}
private void SimulationUpdate(float time, float deltaTime)
{
if (IsServer)
{
NavigationMovement(deltaTime);
}
}
private void NavigationMovement(float deltaTime)
{
var corners = _path.corners; // TODO: maybe use non-alloc version
if (corners.Any() && Vector3.SqrMagnitude(corners[corners.Length - 1]- transform.position) < 1)
{
_path = new NavMeshPath();
corners = _path.corners;
}
var direction = corners.Length > 1 ? (corners[1]- corners[0]).normalized : Vector3.zero;
var movement = direction * movementSpeed * deltaTime;
_navMeshAgent.Move(movement);
}
[ClientRPC]
private void ReplicatePosition(float time, Vector3 value)
{
// The time which we receive here is server time. TODO We need to match it with our client time.
_interpolation.AddValue(time, value);
}
}

11
Assets/Scripts/Character.cs.meta


fileFormatVersion: 2
guid: 5ef335173735a554a98a17d4ef9b21c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

25
Assets/Scripts/Interpolation.cs


using System;
using UnityEngine;
public abstract class Interpolation<T> : MonoBehaviour
{
public abstract Func<T, T, float, T> LerpFunction { get;}
private (float, T) _last;
private (float, T) _previous;
public T GetValueForTime(float time)
{
float timeSincePrevious = time - _previous.Item1;
float t = (timeSincePrevious / (_last.Item1 - _previous.Item1) - 1f);
return LerpFunction(_previous.Item2, _last.Item2, t);
}
public void AddValue(float time, T value)
{
_previous = _last;
_last = (time, value);
}
}

11
Assets/Scripts/Interpolation.cs.meta


fileFormatVersion: 2
guid: 4be874942db508e4bb7c4481d0ffb727
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

40
Assets/Scripts/PlayerInput.cs


using MLAPI;
using MLAPI.Messaging;
using System;
using UnityEngine;
public class PlayerInput : NetworkedBehaviour
{
private Character character;
public void Awake()
{
character = GetComponent<Character>();
}
public override void NetworkStart()
{
if (IsClient)
{
SimulationManager.Singleton.OnSimulationUpdate += SimulationUpdate;
}
}
private void SimulationUpdate(float time, float deltaTime)
{
if (Input.GetMouseButton(0))
{
RaycastHit hit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
{
InvokeServerRpc(SendPlayerInput, hit.point);
}
}
}
[ServerRPC]
public void SendPlayerInput(Vector3 position)
{
character.SetMovementTarget(position);
}
}

11
Assets/Scripts/PlayerInput.cs.meta


fileFormatVersion: 2
guid: 0eaaa5f4790dfc64ebc62ee85984bab9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

19
Assets/Scripts/PositionInterpolation.cs


using System;
using UnityEngine;
using MLAPI;
[DefaultExecutionOrder(200)]
public class PositionInterpolation : Interpolation<Vector3>
{
public override Func<Vector3, Vector3, float, Vector3> LerpFunction => Vector3.LerpUnclamped;
private void Update()
{
var value = GetValueForTime(NetworkingManager.Singleton.NetworkTime);
if (!float.IsNaN(value.x))
{
transform.position = value;
}
}
}

11
Assets/Scripts/PositionInterpolation.cs.meta


fileFormatVersion: 2
guid: 7dac193e15c19dd47bcfb78c85bd6d8d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

49
Assets/Scripts/SimulationManager.cs


using MLAPI;
using UnityEngine;
[DefaultExecutionOrder(100)]
public class SimulationManager : MonoBehaviour
{
public static SimulationManager Singleton { get; private set; }
public delegate void SimulationUpdateDelegate(float time, float deltaTime);
/// <summary>
/// Main game simulation such as processing inputs, running AI, ticking state machines etc. An event is definitely not what we want to use because we have no order, but FixedUpdate isn't as well.
/// </summary>
public event SimulationUpdateDelegate OnSimulationUpdate;
/// <summary>
/// Called after simulation is done replicate game state such as positions to the client.
/// </summary>
public event SimulationUpdateDelegate OnSyncNetworkEvents;
[SerializeField]
private int tickRate = 20;
private float _networkTickDelta;
private float _lastNetworkTickTime;
private void OnEnable()
{
Singleton = this;
_networkTickDelta = 1f / tickRate;
}
// Update is called once per frame
void Update()
{
// The goal here is to sync this up with MLAPIs synchronization but the current network tick model in MLAPI is broken.
while (NetworkingManager.Singleton.NetworkTime - _lastNetworkTickTime >= _networkTickDelta)
{
_lastNetworkTickTime += _networkTickDelta;
Physics.Simulate(_networkTickDelta);
OnSimulationUpdate?.Invoke(_lastNetworkTickTime,_networkTickDelta);
OnSyncNetworkEvents?.Invoke(_lastNetworkTickTime, _networkTickDelta);
}
}
}

11
Assets/Scripts/SimulationManager.cs.meta


fileFormatVersion: 2
guid: 3e6c31da8c35c2743b0311f50e3e1a69
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存