diff --git a/Assets/Mirror/Examples/PhysicsPickupParty/Prefabs/PlayerPickupParty.prefab b/Assets/Mirror/Examples/PhysicsPickupParty/Prefabs/PlayerPickupParty.prefab index f8ace62da..13ef7cbd6 100644 --- a/Assets/Mirror/Examples/PhysicsPickupParty/Prefabs/PlayerPickupParty.prefab +++ b/Assets/Mirror/Examples/PhysicsPickupParty/Prefabs/PlayerPickupParty.prefab @@ -9,9 +9,10 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1248491844850321368} - - component: {fileID: 8368403556113648273} - - component: {fileID: 1736402182742738709} - - component: {fileID: 4111629840625821116} + - component: {fileID: 2830913123588181647} + - component: {fileID: 3830997961433048184} + - component: {fileID: 8773920849830949837} + - component: {fileID: 2395542827503755245} m_Layer: 0 m_Name: Bone__3_ m_TagString: Untagged @@ -37,7 +38,7 @@ Transform: - {fileID: 8986374482142443477} m_Father: {fileID: 1949961484162180731} m_LocalEulerAnglesHint: {x: 0, y: 0, z: -10} ---- !u!65 &8368403556113648273 +--- !u!65 &2830913123588181647 BoxCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -57,8 +58,8 @@ BoxCollider: m_Enabled: 1 serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 1.68, z: 0} ---- !u!54 &1736402182742738709 + m_Center: {x: 0, y: 1.71, z: 0} +--- !u!54 &3830997961433048184 Rigidbody: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -66,9 +67,9 @@ Rigidbody: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 452980654671751133} serializedVersion: 4 - m_Mass: 1 - m_Drag: 0.1 - m_AngularDrag: 0.1 + m_Mass: 0.5 + m_Drag: 0.05 + 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} @@ -85,14 +86,14 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 0 m_CollisionDetection: 0 ---- !u!59 &4111629840625821116 +--- !u!59 &8773920849830949837 HingeJoint: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 452980654671751133} - m_ConnectedBody: {fileID: 192638345736324421} + m_ConnectedBody: {fileID: 1130229831850137548} m_ConnectedArticulationBody: {fileID: 0} m_Anchor: {x: 0, y: 0, z: 0} m_Axis: {x: 0, y: 0, z: 0} @@ -113,8 +114,8 @@ HingeJoint: m_ExtendedLimits: 0 m_UseAcceleration: 0 m_Limits: - min: -35 - max: 35 + min: -45 + max: 45 bounciness: 0.5 bounceMinVelocity: 0.2 contactDistance: 0 @@ -124,6 +125,21 @@ HingeJoint: m_EnablePreprocessing: 1 m_MassScale: 1 m_ConnectedMassScale: 1 +--- !u!114 &2395542827503755245 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 452980654671751133} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ff6ff7e3b685142b8913fe0432ad34e8, type: 3} + m_Name: + m_EditorClassIdentifier: + characterController: {fileID: 4117093369808553598} + jointRigidbody: {fileID: 3830997961433048184} + forceMultiplier: 50 --- !u!1 &524371680692680772 GameObject: m_ObjectHideFlags: 0 @@ -336,7 +352,7 @@ Rigidbody: m_Bits: 0 m_ImplicitCom: 1 m_ImplicitTensor: 1 - m_UseGravity: 1 + m_UseGravity: 0 m_IsKinematic: 1 m_Interpolate: 0 m_Constraints: 0 @@ -1632,9 +1648,10 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1949961484162180731} - - component: {fileID: 192638345736324421} - - component: {fileID: 277754474636220153} - - component: {fileID: 8801781938880517542} + - component: {fileID: 1130229831850137548} + - component: {fileID: 2167014065819113315} + - component: {fileID: 617232723998170435} + - component: {fileID: 6050803512130430068} m_Layer: 0 m_Name: Bone__2_ m_TagString: Untagged @@ -1658,7 +1675,7 @@ Transform: - {fileID: 1248491844850321368} m_Father: {fileID: 2323077973285806868} m_LocalEulerAnglesHint: {x: 0, y: 0, z: -10} ---- !u!54 &192638345736324421 +--- !u!54 &1130229831850137548 Rigidbody: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -1685,109 +1702,7 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 0 m_CollisionDetection: 0 ---- !u!153 &277754474636220153 -ConfigurableJoint: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 9126622635895510908} - m_ConnectedBody: {fileID: 7762469913996749116} - m_ConnectedArticulationBody: {fileID: 0} - m_Anchor: {x: 0, y: 0, z: 0} - m_Axis: {x: 1, y: 0, z: 0} - m_AutoConfigureConnectedAnchor: 1 - m_ConnectedAnchor: {x: 0, y: 0, z: 0} - serializedVersion: 3 - m_SecondaryAxis: {x: 0, y: 1, z: 0} - m_XMotion: 0 - m_YMotion: 0 - m_ZMotion: 0 - m_AngularXMotion: 0 - m_AngularYMotion: 2 - m_AngularZMotion: 2 - m_LinearLimitSpring: - spring: 0 - damper: 0 - m_LinearLimit: - limit: 0 - bounciness: 0 - contactDistance: 0 - m_AngularXLimitSpring: - spring: 0 - damper: 0 - m_LowAngularXLimit: - limit: 0 - bounciness: 0 - contactDistance: 0 - m_HighAngularXLimit: - limit: 0 - bounciness: 0 - contactDistance: 0 - m_AngularYZLimitSpring: - spring: 0 - damper: 0 - m_AngularYLimit: - limit: 0 - bounciness: 0 - contactDistance: 0 - m_AngularZLimit: - limit: 0 - bounciness: 0 - contactDistance: 0 - m_TargetPosition: {x: 0, y: 0, z: 0} - m_TargetVelocity: {x: 0, y: 0, z: 0} - m_XDrive: - serializedVersion: 4 - positionSpring: 0 - positionDamper: 0 - maximumForce: 3.4028233e+38 - useAcceleration: 0 - m_YDrive: - serializedVersion: 4 - positionSpring: 0 - positionDamper: 0 - maximumForce: 3.4028233e+38 - useAcceleration: 0 - m_ZDrive: - serializedVersion: 4 - positionSpring: 0 - positionDamper: 0 - maximumForce: 3.4028233e+38 - useAcceleration: 0 - m_TargetRotation: {x: 0, y: 0, z: 0, w: 1} - m_TargetAngularVelocity: {x: 0, y: 0, z: 0} - m_RotationDriveMode: 0 - m_AngularXDrive: - serializedVersion: 4 - positionSpring: 0 - positionDamper: 0 - maximumForce: 3.4028233e+38 - useAcceleration: 0 - m_AngularYZDrive: - serializedVersion: 4 - positionSpring: 50 - positionDamper: 1 - maximumForce: 3.4028233e+38 - useAcceleration: 0 - m_SlerpDrive: - serializedVersion: 4 - positionSpring: 0 - positionDamper: 0 - maximumForce: 3.4028233e+38 - useAcceleration: 0 - m_ProjectionMode: 0 - m_ProjectionDistance: 0.1 - m_ProjectionAngle: 180 - m_ConfiguredInWorldSpace: 0 - m_SwapBodies: 0 - m_BreakForce: Infinity - m_BreakTorque: Infinity - m_EnableCollision: 1 - m_EnablePreprocessing: 1 - m_MassScale: 1 - m_ConnectedMassScale: 1 ---- !u!65 &8801781938880517542 +--- !u!65 &2167014065819113315 BoxCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -1806,5 +1721,59 @@ BoxCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 3 - m_Size: {x: 1, y: 0.76, z: 1} - m_Center: {x: 0, y: 0.75, z: 0} + m_Size: {x: 1, y: 0.75, z: 1} + m_Center: {x: 0, y: 0.83, z: 0} +--- !u!59 &617232723998170435 +HingeJoint: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9126622635895510908} + m_ConnectedBody: {fileID: 7762469913996749116} + m_ConnectedArticulationBody: {fileID: 0} + m_Anchor: {x: 0, y: 0, z: 0} + m_Axis: {x: 0, y: 0, z: 1} + m_AutoConfigureConnectedAnchor: 1 + m_ConnectedAnchor: {x: 0.053000025, y: 0.60800016, z: 0} + serializedVersion: 2 + m_UseSpring: 1 + m_Spring: + spring: 20 + damper: 0 + targetPosition: 1 + m_UseMotor: 0 + m_Motor: + targetVelocity: 100 + force: 100 + freeSpin: 0 + m_UseLimits: 1 + m_ExtendedLimits: 0 + m_UseAcceleration: 0 + m_Limits: + min: -45 + max: 45 + bounciness: 0.5 + bounceMinVelocity: 0.2 + contactDistance: 0 + m_BreakForce: Infinity + m_BreakTorque: Infinity + m_EnableCollision: 1 + m_EnablePreprocessing: 1 + m_MassScale: 1 + m_ConnectedMassScale: 1 +--- !u!114 &6050803512130430068 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9126622635895510908} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ff6ff7e3b685142b8913fe0432ad34e8, type: 3} + m_Name: + m_EditorClassIdentifier: + characterController: {fileID: 4117093369808553598} + jointRigidbody: {fileID: 1130229831850137548} + forceMultiplier: 75 diff --git a/Assets/Mirror/Examples/PhysicsPickupParty/Scripts/JointForce.cs b/Assets/Mirror/Examples/PhysicsPickupParty/Scripts/JointForce.cs new file mode 100644 index 000000000..afd633acd --- /dev/null +++ b/Assets/Mirror/Examples/PhysicsPickupParty/Scripts/JointForce.cs @@ -0,0 +1,23 @@ +using UnityEngine; + +public class JointForce : MonoBehaviour +{ + public CharacterController characterController; + public Rigidbody jointRigidbody; + public float forceMultiplier = 100f; + + private Vector3 lastPosition; + + void Start() + { + lastPosition = characterController.transform.position; + } + + void FixedUpdate() + { + Vector3 movementDelta = characterController.transform.position - lastPosition; + Vector3 force = -movementDelta * forceMultiplier; + jointRigidbody.AddForce(force); + lastPosition = characterController.transform.position; + } +} \ No newline at end of file diff --git a/Assets/Mirror/Examples/PhysicsPickupParty/Scripts/JointForce.cs.meta b/Assets/Mirror/Examples/PhysicsPickupParty/Scripts/JointForce.cs.meta new file mode 100644 index 000000000..e96442df4 --- /dev/null +++ b/Assets/Mirror/Examples/PhysicsPickupParty/Scripts/JointForce.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ff6ff7e3b685142b8913fe0432ad34e8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: