diff --git a/Assets/Mirror/Examples/RigidbodyPhysics/Materials/Floor.mat b/Assets/Mirror/Examples/RigidbodyPhysics/Materials/Floor.mat new file mode 100644 index 000000000..990f77873 --- /dev/null +++ b/Assets/Mirror/Examples/RigidbodyPhysics/Materials/Floor.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Floor + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.192 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0.99504846, b: 0.5518868, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Mirror/Examples/RigidbodyPhysics/Materials/Floor.mat.meta b/Assets/Mirror/Examples/RigidbodyPhysics/Materials/Floor.mat.meta new file mode 100644 index 000000000..09dd28178 --- /dev/null +++ b/Assets/Mirror/Examples/RigidbodyPhysics/Materials/Floor.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2082151ae101a9445990e8a0fe9142da +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirror/Examples/RigidbodyPhysics/Materials/Green.mat b/Assets/Mirror/Examples/RigidbodyPhysics/Materials/Green.mat index bccc96b17..dd7a2b8dc 100644 --- a/Assets/Mirror/Examples/RigidbodyPhysics/Materials/Green.mat +++ b/Assets/Mirror/Examples/RigidbodyPhysics/Materials/Green.mat @@ -61,7 +61,7 @@ Material: - _DetailNormalMapScale: 1 - _DstBlend: 0 - _GlossMapScale: 1 - - _Glossiness: 0.192 + - _Glossiness: 0.816 - _GlossyReflections: 1 - _Metallic: 0 - _Mode: 0 diff --git a/Assets/Mirror/Examples/RigidbodyPhysics/Scenes/BounceScene.unity b/Assets/Mirror/Examples/RigidbodyPhysics/Scenes/BounceScene.unity index bc10d1e30..54f821c11 100644 --- a/Assets/Mirror/Examples/RigidbodyPhysics/Scenes/BounceScene.unity +++ b/Assets/Mirror/Examples/RigidbodyPhysics/Scenes/BounceScene.unity @@ -172,7 +172,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2100000, guid: bbe2c7293af197640a2b40018e79b9a6, type: 2} + - {fileID: 2100000, guid: 2082151ae101a9445990e8a0fe9142da, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -247,12 +247,15 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Port: 7777 + DualMode: 1 NoDelay: 1 Interval: 10 + Timeout: 10000 FastResend: 2 CongestionWindow: 0 SendWindowSize: 4096 ReceiveWindowSize: 4096 + NonAlloc: 1 debugLog: 0 statisticsGUI: 0 statisticsLog: 0 @@ -273,15 +276,11 @@ MonoBehaviour: runInBackground: 1 autoStartServerBuild: 1 serverTickRate: 30 - serverBatching: 0 - serverBatchInterval: 0 offlineScene: onlineScene: transport: {fileID: 492096634} networkAddress: localhost maxConnections: 100 - disconnectInactiveConnections: 0 - disconnectInactiveTimeout: 60 authenticator: {fileID: 0} playerPrefab: {fileID: 844717362685181648, guid: 4ab0a427bdc13244499c6e044ad7eb40, type: 3} @@ -300,7 +299,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &492096637 MonoBehaviour: @@ -314,7 +313,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6442dc8070ceb41f094e44de0bf87274, type: 3} m_Name: m_EditorClassIdentifier: - showGUI: 1 offsetX: 0 offsetY: 0 --- !u!1 &746548597 @@ -329,7 +327,7 @@ GameObject: - component: {fileID: 746548600} - component: {fileID: 746548599} m_Layer: 5 - m_Name: Image (2) + m_Name: Image m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -429,7 +427,7 @@ MonoBehaviour: m_EditorClassIdentifier: syncMode: 0 syncInterval: 0.1 - rigidbody3d: {fileID: 0} + rigidbody3d: {fileID: 1019217379} force: 500 --- !u!114 &1019217377 MonoBehaviour: @@ -444,14 +442,22 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: syncMode: 0 - syncInterval: 0 + syncInterval: 0.1 clientAuthority: 0 - localPositionSensitivity: 0.01 - localRotationSensitivity: 0.01 - localScaleSensitivity: 0.01 - compressRotation: 1 - interpolateScale: 0 + sendInterval: 0.05 + syncPosition: 1 + syncRotation: 1 syncScale: 0 + interpolatePosition: 1 + interpolateRotation: 1 + interpolateScale: 0 + bufferTimeMultiplier: 1 + bufferSizeLimit: 64 + catchupThreshold: 4 + catchupMultiplier: 0.1 + showGizmos: 0 + showOverlay: 0 + overlayColor: {r: 0, g: 0, b: 0, a: 0.5} --- !u!114 &1019217378 MonoBehaviour: m_ObjectHideFlags: 0 @@ -483,7 +489,7 @@ Rigidbody: m_UseGravity: 1 m_IsKinematic: 1 m_Interpolate: 0 - m_Constraints: 0 + m_Constraints: 122 m_CollisionDetection: 0 --- !u!135 &1019217380 SphereCollider: @@ -553,7 +559,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1019217375} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1.5, y: 0.5, z: 0} + m_LocalPosition: {x: -3, y: 0.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -689,7 +695,7 @@ MonoBehaviour: m_EditorClassIdentifier: syncMode: 0 syncInterval: 0.1 - rigidbody3d: {fileID: 0} + rigidbody3d: {fileID: 1200292995} force: 500 --- !u!114 &1200292992 MonoBehaviour: @@ -704,7 +710,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: syncMode: 0 - syncInterval: 0 + syncInterval: 0.1 target: {fileID: 1200292995} clientAuthority: 0 syncVelocity: 1 @@ -726,14 +732,22 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: syncMode: 0 - syncInterval: 0 + syncInterval: 0.1 clientAuthority: 0 - localPositionSensitivity: 0.01 - localRotationSensitivity: 0.01 - localScaleSensitivity: 0.01 - compressRotation: 1 - interpolateScale: 0 + sendInterval: 0.05 + syncPosition: 1 + syncRotation: 1 syncScale: 0 + interpolatePosition: 1 + interpolateRotation: 1 + interpolateScale: 0 + bufferTimeMultiplier: 1 + bufferSizeLimit: 64 + catchupThreshold: 4 + catchupMultiplier: 0.1 + showGizmos: 0 + showOverlay: 0 + overlayColor: {r: 0, g: 0, b: 0, a: 0.5} --- !u!114 &1200292994 MonoBehaviour: m_ObjectHideFlags: 0 @@ -765,7 +779,7 @@ Rigidbody: m_UseGravity: 1 m_IsKinematic: 1 m_Interpolate: 0 - m_Constraints: 0 + m_Constraints: 122 m_CollisionDetection: 0 --- !u!135 &1200292996 SphereCollider: @@ -835,7 +849,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1200292990} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 1.5, y: 0.5, z: 0} + m_LocalPosition: {x: 0, y: 0.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -853,7 +867,7 @@ GameObject: - component: {fileID: 1282619066} - component: {fileID: 1282619065} m_Layer: 5 - m_Name: Image (1) + m_Name: Image m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -928,7 +942,7 @@ GameObject: - component: {fileID: 1592570047} - component: {fileID: 1592570046} m_Layer: 5 - m_Name: Text (2) + m_Name: Text m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -973,7 +987,7 @@ MonoBehaviour: m_PersistentCalls: m_Calls: [] m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 3} + m_Font: {fileID: 12800000, guid: e3265ab4bf004d28a9537516768c1c75, type: 3} m_FontSize: 24 m_FontStyle: 0 m_BestFit: 0 @@ -1051,7 +1065,7 @@ MonoBehaviour: m_PersistentCalls: m_Calls: [] m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 3} + m_Font: {fileID: 12800000, guid: e3265ab4bf004d28a9537516768c1c75, type: 3} m_FontSize: 24 m_FontStyle: 0 m_BestFit: 0 @@ -1240,13 +1254,177 @@ RectTransform: - {fileID: 1282619064} - {fileID: 746548598} m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} +--- !u!1 &1945586487 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1945586496} + - component: {fileID: 1945586495} + - component: {fileID: 1945586494} + - component: {fileID: 1945586493} + - component: {fileID: 1945586492} + - component: {fileID: 1945586491} + - component: {fileID: 1945586489} + - component: {fileID: 1945586488} + m_Layer: 0 + m_Name: Ball Green + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1945586488 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1945586487} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c1b468aa0f3779f4b950b7651891cb8c, type: 3} + m_Name: + m_EditorClassIdentifier: + syncMode: 0 + syncInterval: 0.1 + rigidbody3d: {fileID: 1945586492} + force: 500 +--- !u!114 &1945586489 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1945586487} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7f032128052c95a46afb0ddd97d994cc, type: 3} + m_Name: + m_EditorClassIdentifier: + syncMode: 0 + syncInterval: 0.1 + target: {fileID: 1945586492} + lerpVelocityAmount: 0.5 + lerpPositionAmount: 0.5 + clientAuthority: 0 +--- !u!114 &1945586491 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1945586487} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3} + m_Name: + m_EditorClassIdentifier: + sceneId: 4068402964 + serverOnly: 0 + visible: 0 + m_AssetId: + hasSpawned: 0 +--- !u!54 &1945586492 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1945586487} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_UseGravity: 1 + m_IsKinematic: 1 + m_Interpolate: 0 + m_Constraints: 122 + m_CollisionDetection: 0 +--- !u!135 &1945586493 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1945586487} + m_Material: {fileID: 13400000, guid: f2bb9a8ecc30457468aea7dacef6f5de, type: 2} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &1945586494 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1945586487} + 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_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: bbe2c7293af197640a2b40018e79b9a6, 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: 0 + 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 +--- !u!33 &1945586495 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1945586487} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1945586496 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1945586487} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 3, y: 0.5, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2029351939 GameObject: m_ObjectHideFlags: 0 @@ -1259,7 +1437,7 @@ GameObject: - component: {fileID: 2029351942} - component: {fileID: 2029351941} m_Layer: 5 - m_Name: Text (1) + m_Name: Text m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1304,7 +1482,7 @@ MonoBehaviour: m_PersistentCalls: m_Calls: [] m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 3} + m_Font: {fileID: 12800000, guid: e3265ab4bf004d28a9537516768c1c75, type: 3} m_FontSize: 24 m_FontStyle: 0 m_BestFit: 0 diff --git a/Assets/Mirror/Examples/RigidbodyPhysics/Scripts/AddForce.cs b/Assets/Mirror/Examples/RigidbodyPhysics/Scripts/AddForce.cs index 36030bec3..ccbd6d225 100644 --- a/Assets/Mirror/Examples/RigidbodyPhysics/Scripts/AddForce.cs +++ b/Assets/Mirror/Examples/RigidbodyPhysics/Scripts/AddForce.cs @@ -2,22 +2,27 @@ namespace Mirror.Examples.RigidbodyPhysics { + [RequireComponent(typeof(Rigidbody))] public class AddForce : NetworkBehaviour { public Rigidbody rigidbody3d; public float force = 500f; - void Start() + void OnValidate() { - rigidbody3d.isKinematic = !isServer; + rigidbody3d = GetComponent(); + rigidbody3d.isKinematic = true; + } + + public override void OnStartServer() + { + rigidbody3d.isKinematic = false; } void Update() { if (isServer && Input.GetKeyDown(KeyCode.Space)) - { rigidbody3d.AddForce(Vector3.up * force); - } } } }