浮漂修改
This commit is contained in:
@@ -41538,8 +41538,8 @@ MonoBehaviour:
|
||||
Dependencies: []
|
||||
Tags:
|
||||
- Name: main/plyaer.bundle
|
||||
Hash: e4ec05a4b781eddaae2f07fc44c008f4
|
||||
Size: 378599896
|
||||
Hash: 0765d7b38fb20176d24357d15a00b8f2
|
||||
Size: 378600019
|
||||
Assets:
|
||||
- Path: Assets/ResRaw/Prefabs/Line/fishing line float set.prefab
|
||||
Address: Plyaer/fishing line float set
|
||||
|
||||
BIN
Assets/New Terrain 12.asset
Normal file
BIN
Assets/New Terrain 12.asset
Normal file
Binary file not shown.
8
Assets/New Terrain 12.asset.meta
Normal file
8
Assets/New Terrain 12.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e465e80fb4cc6eb468c18e24b9c28c2a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 15600000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -70,6 +70,7 @@ MonoBehaviour:
|
||||
groundCastDistance: 2.5
|
||||
groundSampleStep: 3
|
||||
groundInterpolate: 1
|
||||
groundUpdateEvery: 1
|
||||
renderSubdivisionsIdle: 6
|
||||
renderSubdivisionsMoving: 2
|
||||
movingSpeedThreshold: 2
|
||||
@@ -453,6 +454,7 @@ GameObject:
|
||||
- component: {fileID: 54298866000586118}
|
||||
- component: {fileID: 153691655494134957}
|
||||
- component: {fileID: 2717383850592950062}
|
||||
- component: {fileID: 3104700584461846010}
|
||||
m_Layer: 16
|
||||
m_Name: Float
|
||||
m_TagString: Untagged
|
||||
@@ -618,6 +620,30 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::NBF.BobberController
|
||||
_rbody: {fileID: 54298866000586118}
|
||||
joint: {fileID: 153691655494134957}
|
||||
_buoyancy: {fileID: 3104700584461846010}
|
||||
--- !u!114 &3104700584461846010
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1858052053854210}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dd1aa9f0de8b435448c6893ecc60d021, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Buoyancy
|
||||
includeDeformation: 1
|
||||
sphereRadiusApproximation: 0.1
|
||||
waveForceMultiplier: 0.01
|
||||
currentSpeedMultiplier: 0.01
|
||||
dragMultiplier: 1
|
||||
defaultRigidbodyDrag: 5
|
||||
underwaterRigidbodyAngularDrag: 5
|
||||
overwaterRigidbodyAngularDrag: 1
|
||||
surfaceTensionDamping: 10
|
||||
applyForceWithRandomOffset: 0
|
||||
drawDebug: 1
|
||||
--- !u!1 &1933124697579601
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -688,6 +714,7 @@ MonoBehaviour:
|
||||
groundCastDistance: 2.5
|
||||
groundSampleStep: 3
|
||||
groundInterpolate: 1
|
||||
groundUpdateEvery: 1
|
||||
renderSubdivisionsIdle: 6
|
||||
renderSubdivisionsMoving: 2
|
||||
movingSpeedThreshold: 2
|
||||
|
||||
@@ -10,7 +10,7 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 4943038628811238}
|
||||
- component: {fileID: 4160997794325361152}
|
||||
- component: {fileID: -1878270173486354861}
|
||||
- component: {fileID: 642471695031276768}
|
||||
m_Layer: 0
|
||||
m_Name: bob_25004
|
||||
m_TagString: Untagged
|
||||
@@ -31,12 +31,7 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 4033285271709525}
|
||||
- {fileID: 4753668062539042}
|
||||
- {fileID: 4391537656274936}
|
||||
- {fileID: 4219322353105327}
|
||||
- {fileID: 4083127709589988}
|
||||
- {fileID: 4696959239802335}
|
||||
- {fileID: 2628037665683154556}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: -0, z: -0}
|
||||
--- !u!114 &4160997794325361152
|
||||
@@ -56,8 +51,8 @@ MonoBehaviour:
|
||||
topConnector: {fileID: 4753668062539042}
|
||||
bottomConnector: {fileID: 4391537656274936}
|
||||
waterline: {fileID: 4083127709589988}
|
||||
--- !u!65 &-1878270173486354861
|
||||
BoxCollider:
|
||||
--- !u!136 &642471695031276768
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
@@ -74,9 +69,11 @@ BoxCollider:
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 0.005, y: 0.005, z: 0.005}
|
||||
m_Center: {x: 0, y: -0.01, z: 0}
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.002
|
||||
m_Height: 0.03
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0.01, z: 0}
|
||||
--- !u!1 &1236424003946422
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -86,7 +83,6 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4219322353105327}
|
||||
- component: {fileID: 136815202583894138}
|
||||
m_Layer: 0
|
||||
m_Name: _body
|
||||
m_TagString: Untagged
|
||||
@@ -102,36 +98,13 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1236424003946422}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.028749999, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4943038628811238}
|
||||
m_Father: {fileID: 2628037665683154556}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: -0, z: -0}
|
||||
--- !u!136 &136815202583894138
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1236424003946422}
|
||||
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.002
|
||||
m_Height: 0.035
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1256211692469512
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -162,7 +135,7 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4943038628811238}
|
||||
m_Father: {fileID: 2628037665683154556}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!136 &136849029598565726
|
||||
CapsuleCollider:
|
||||
@@ -211,12 +184,12 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1342355430950628}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.00627, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4943038628811238}
|
||||
m_Father: {fileID: 2628037665683154556}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: -0, z: -0}
|
||||
--- !u!1 &1364623190328362
|
||||
GameObject:
|
||||
@@ -242,12 +215,12 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1364623190328362}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.0375, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4943038628811238}
|
||||
m_Father: {fileID: 2628037665683154556}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: -0, z: -0}
|
||||
--- !u!1 &1435124216471202
|
||||
GameObject:
|
||||
@@ -273,12 +246,12 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1435124216471202}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.05351, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4943038628811238}
|
||||
m_Father: {fileID: 2628037665683154556}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: -0, z: -0}
|
||||
--- !u!1 &1792318500355349
|
||||
GameObject:
|
||||
@@ -306,12 +279,12 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1792318500355349}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
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: 4943038628811238}
|
||||
m_Father: {fileID: 2628037665683154556}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: -0, z: -0}
|
||||
--- !u!33 &33680541704296896
|
||||
MeshFilter:
|
||||
@@ -369,3 +342,40 @@ MeshRenderer:
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!1 &1696436611728297872
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2628037665683154556}
|
||||
m_Layer: 0
|
||||
m_Name: bob
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2628037665683154556
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1696436611728297872}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: -0.04, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 4033285271709525}
|
||||
- {fileID: 4753668062539042}
|
||||
- {fileID: 4391537656274936}
|
||||
- {fileID: 4219322353105327}
|
||||
- {fileID: 4083127709589988}
|
||||
- {fileID: 4696959239802335}
|
||||
m_Father: {fileID: 4943038628811238}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ namespace NBF
|
||||
[SerializeField] private Rigidbody _rbody;
|
||||
|
||||
[SerializeField] private ConfigurableJoint joint;
|
||||
|
||||
[SerializeField] private Buoyancy _buoyancy;
|
||||
public Rigidbody rbody => _rbody;
|
||||
|
||||
public void SetJoint(Rigidbody rb)
|
||||
@@ -15,7 +15,7 @@ namespace NBF
|
||||
joint = joint == null ? GetComponent<ConfigurableJoint>() : joint;
|
||||
joint.connectedBody = rb;
|
||||
}
|
||||
|
||||
|
||||
public void SetJointDistance(float limit)
|
||||
{
|
||||
joint.linearLimit = new SoftJointLimit
|
||||
@@ -23,5 +23,16 @@ namespace NBF
|
||||
limit = limit
|
||||
};
|
||||
}
|
||||
|
||||
public void SetDetectCollisionEnabled(bool en)
|
||||
{
|
||||
_rbody.detectCollisions = en;
|
||||
_buoyancy.EnablePhysics(en);
|
||||
}
|
||||
|
||||
public void SetVelocity(Vector3 velocity)
|
||||
{
|
||||
_rbody.linearVelocity = velocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
209
Assets/Scripts/Test/Buoyancy.cs
Normal file
209
Assets/Scripts/Test/Buoyancy.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class Buoyancy : MonoBehaviour
|
||||
{
|
||||
// ====== No water plugin dependency ======
|
||||
[Header("Water (No Plugin)")]
|
||||
[Tooltip("Fallback flat water level (Y). Set this to match your scene water height for now.")]
|
||||
public float waterLevel = 0f;
|
||||
|
||||
[Tooltip("If false, buoyancy is disabled and rigidbody uses gravity.")]
|
||||
public bool waterAvailable = true;
|
||||
|
||||
// ====== Original fields (kept) ======
|
||||
public bool includeDeformation = true;
|
||||
|
||||
[Tooltip("Approxative radius of object for buoyancy.")]
|
||||
public float sphereRadiusApproximation = 0.25f;
|
||||
|
||||
[Tooltip("Specifies the multiplier for the movement induced by other deformation (waves, swell... etc).")]
|
||||
public float waveForceMultiplier = 1f;
|
||||
|
||||
[Tooltip("Specifies the multiplier for the movement induced by the current of the water surface.")]
|
||||
public float currentSpeedMultiplier = 1f;
|
||||
|
||||
[Tooltip("Specifies the multiplier for the drag forces induced by the viscosity of the mediums.")]
|
||||
public float dragMultiplier = 1f;
|
||||
|
||||
public float defaultRigidbodyDrag = 0.1f;
|
||||
|
||||
public float underwaterRigidbodyAngularDrag = 1f;
|
||||
|
||||
public float overwaterRigidbodyAngularDrag = 0.05f;
|
||||
|
||||
[Tooltip("Specifies the value for surface tension. A high value will stop the object bouncing faster on water.")]
|
||||
public float surfaceTensionDamping = 10f;
|
||||
|
||||
[Tooltip("When enabled, the net force is applied with a random offset to create an angular velocity.")]
|
||||
public bool applyForceWithRandomOffset;
|
||||
|
||||
// 原脚本里这个是 HDRP 的“自定义网格水面高度偏移”,这里保留字段但不再依赖水插件
|
||||
[Tooltip("Optional extra offset added to sampled water height. Useful if your water mesh pivot isn't at surface level.")]
|
||||
public float waterHeightOffset = 0f;
|
||||
|
||||
public bool drawDebug;
|
||||
|
||||
private Vector3 currentDirection;
|
||||
private Vector3 A;
|
||||
private Vector3 B;
|
||||
private Vector3 C;
|
||||
private Vector3 waterPosition;
|
||||
private Vector3 normal;
|
||||
private Vector3 deformationDirection;
|
||||
|
||||
private Rigidbody rigidbodyComponent;
|
||||
|
||||
private float h;
|
||||
private float hNormalized;
|
||||
|
||||
private bool _isEnabled = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rigidbodyComponent = GetComponent<Rigidbody>();
|
||||
rigidbodyComponent.useGravity = false;
|
||||
rigidbodyComponent.linearDamping = defaultRigidbodyDrag;
|
||||
}
|
||||
|
||||
public void EnablePhysics(bool set)
|
||||
{
|
||||
_isEnabled = set;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
// ✅ 关键:没有水 / 禁用时,回到“用Unity重力”
|
||||
if (!_isEnabled || !waterAvailable)
|
||||
{
|
||||
h = (hNormalized = 0f);
|
||||
rigidbodyComponent.useGravity = true;
|
||||
return;
|
||||
}
|
||||
|
||||
rigidbodyComponent.useGravity = false;
|
||||
|
||||
FetchWaterSurfaceData(transform.position, out waterPosition, out normal, out currentDirection);
|
||||
|
||||
deformationDirection = Vector3.ProjectOnPlane(normal, Vector3.up);
|
||||
|
||||
h = Mathf.Clamp(
|
||||
waterPosition.y - (transform.position.y - sphereRadiusApproximation),
|
||||
0f,
|
||||
2f * sphereRadiusApproximation
|
||||
);
|
||||
|
||||
hNormalized = h * 1f / (2f * sphereRadiusApproximation);
|
||||
|
||||
float num = MathF.PI * h * h / 3f * (3f * sphereRadiusApproximation - h);
|
||||
|
||||
rigidbodyComponent.angularDamping = Mathf.Lerp(overwaterRigidbodyAngularDrag, underwaterRigidbodyAngularDrag, hNormalized);
|
||||
|
||||
// === 以下保持原脚本单位/写法(尽量贴近原行为) ===
|
||||
Vector3 b = rigidbodyComponent.mass * Physics.gravity;
|
||||
Vector3 vector = Vector3.Lerp(Physics.gravity, b, hNormalized);
|
||||
|
||||
float num2 = 997f;
|
||||
float num3 = 0.001293f;
|
||||
float num4 = 1.81E-05f;
|
||||
float num5 = 0.001f;
|
||||
float num6 = 0.47f;
|
||||
|
||||
Vector3 vector2 = (0f - num2) * num * Physics.gravity;
|
||||
|
||||
Vector3 a = MathF.PI * 6f * sphereRadiusApproximation * num4 * -rigidbodyComponent.linearVelocity;
|
||||
Vector3 b2 = MathF.PI * 6f * sphereRadiusApproximation * num5 * -rigidbodyComponent.linearVelocity;
|
||||
Vector3 vector3 = Vector3.Lerp(a, b2, hNormalized) * dragMultiplier;
|
||||
|
||||
float num7 = Mathf.Lerp(
|
||||
b: Mathf.Sqrt(2f * rigidbodyComponent.mass * (0f - Physics.gravity.y) /
|
||||
(num2 * MathF.PI * Mathf.Pow(sphereRadiusApproximation, 2f) * num6)),
|
||||
a: Mathf.Sqrt(2f * rigidbodyComponent.mass * (0f - Physics.gravity.y) /
|
||||
(num3 * MathF.PI * Mathf.Pow(sphereRadiusApproximation, 2f) * num6)),
|
||||
t: hNormalized
|
||||
);
|
||||
|
||||
Vector3 force = vector + vector2 + vector3;
|
||||
|
||||
Vector3 vector4 = applyForceWithRandomOffset
|
||||
? (new Vector3(
|
||||
UnityEngine.Random.Range(-1f, 1f),
|
||||
UnityEngine.Random.Range(-1f, 1f),
|
||||
UnityEngine.Random.Range(-1f, 1f)
|
||||
) * sphereRadiusApproximation / 5f)
|
||||
: Vector3.zero;
|
||||
|
||||
rigidbodyComponent.AddForceAtPosition(force, transform.position + vector4, ForceMode.Acceleration);
|
||||
|
||||
if (hNormalized > 0f && hNormalized < 1f)
|
||||
{
|
||||
Vector3 force2 = -(Vector3.Dot(rigidbodyComponent.linearVelocity, Physics.gravity.normalized)
|
||||
* Physics.gravity.normalized) * surfaceTensionDamping;
|
||||
|
||||
rigidbodyComponent.AddForce(force2, ForceMode.Acceleration);
|
||||
|
||||
if (includeDeformation)
|
||||
{
|
||||
rigidbodyComponent.AddForce(deformationDirection * waveForceMultiplier, ForceMode.Acceleration);
|
||||
rigidbodyComponent.AddForce(currentDirection * currentSpeedMultiplier, ForceMode.Acceleration);
|
||||
}
|
||||
}
|
||||
|
||||
if (rigidbodyComponent.linearVelocity.magnitude > num7)
|
||||
{
|
||||
rigidbodyComponent.linearVelocity = rigidbodyComponent.linearVelocity.normalized * num7;
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 FetchWaterSurfaceData(Vector3 point, out Vector3 positionWS, out Vector3 normalWS, out Vector3 currentDirectionWS)
|
||||
{
|
||||
// ✅ 插件无关:统一从 GetWaterInfo 拿数据
|
||||
GetWaterInfo(point, out float waterHeight, out normalWS, out currentDirectionWS);
|
||||
|
||||
positionWS = new Vector3(point.x, waterHeight + waterHeightOffset, point.z);
|
||||
|
||||
if (normalWS == Vector3.zero) normalWS = Vector3.up;
|
||||
|
||||
return positionWS;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Water provider (no plugin dependency).
|
||||
/// 默认:水平水面,高度 = waterLevel
|
||||
/// 以后接 Crest5:你只要改这个函数即可。
|
||||
/// </summary>
|
||||
protected virtual void GetWaterInfo(Vector3 worldPoint, out float waterHeight, out Vector3 waterNormal, out Vector3 waterCurrentDir)
|
||||
{
|
||||
waterHeight = waterLevel; // 默认水面高度(可在Inspector里调对齐)
|
||||
waterNormal = Vector3.up; // 默认法线
|
||||
waterCurrentDir = Vector3.zero; // 默认水流方向
|
||||
}
|
||||
|
||||
public Vector3 GetCurrentWaterPosition() => waterPosition;
|
||||
|
||||
public float GetNormalizedHeightOfSphereBelowSurface() => hNormalized;
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
if (!drawDebug) return;
|
||||
|
||||
Gizmos.color = Color.magenta;
|
||||
Gizmos.DrawLine(transform.position, transform.position + normal);
|
||||
|
||||
Gizmos.color = Color.green;
|
||||
Gizmos.DrawLine(transform.position, transform.position + deformationDirection * 10f);
|
||||
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawLine(transform.position, transform.position + currentDirection);
|
||||
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawSphere(transform.position, sphereRadiusApproximation);
|
||||
|
||||
Gizmos.color = Color.blue;
|
||||
Gizmos.DrawSphere(A, sphereRadiusApproximation / 10f);
|
||||
Gizmos.DrawSphere(B, sphereRadiusApproximation / 10f);
|
||||
Gizmos.DrawSphere(C, sphereRadiusApproximation / 10f);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Test/Buoyancy.cs.meta
Normal file
2
Assets/Scripts/Test/Buoyancy.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd1aa9f0de8b435448c6893ecc60d021
|
||||
@@ -25,6 +25,7 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3272951baa974b2ab5e8de68d60bfc1e46ae00_003Fb3_003F93aaabe4_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F59bd7c40c082431db25e1e728ab6278946ae00_003Fb4_003F05ce572a_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F59bd7c40c082431db25e1e728ab6278946ae00_003Fb4_003F05ce572a_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExecuteInEditMode_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ff27f375161264267910e5cbe7a0862ec1f7600_003F51_003Fcd47b447_003FExecuteInEditMode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFullScreenMode_002Ecs_002Fl_003AC_0021_003FUsers_003Fbob_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F021f30a9a92b48ce98ae6b39956dd76a1df600_003F7c_003F0044d980_003FFullScreenMode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGameObjectInspector_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1acad9deef3549c4b9617dfa169c66599f7e00_003Fef_003F654c7b7e_003FGameObjectInspector_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGameObject_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F021f30a9a92b48ce98ae6b39956dd76a1df600_003F28_003F384825fa_003FGameObject_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
||||
@@ -9,31 +9,31 @@ EditorUserSettings:
|
||||
value: 18134705175a055722080a3115371d4a0d55006876786860616b0471b8b07a68ffab74f9ee2a3a30300cea1a11320d0beb1a0c25f7060f494b4cc80018eb09361fc211cb1f862d19c51d19dcc413d6ade0d8ddfcddf9f4d9d29195fcfde6ebeae6f0a9c9afa6f8c5b89ff7a1aacececac4eba4d7c9d28bda
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-0:
|
||||
value: 07060c5454040c0a545b547240700a441216417e7f2e7268752c4966b4b0663d
|
||||
value: 5403560050570a5a08085523137709114e15492e7c7f74677e2f4c61b0b3633e
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-1:
|
||||
value: 5309035757065a0a54575f7216265c4444151d28792e72627d2f1935bbb8673a
|
||||
value: 0700575604020d0a5c0a0a2643770d45134f487e74782031287d1f65b7b4623b
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-2:
|
||||
value: 5505015f5c515a085f5b092149760f441716407a787d7564287b1b36e7e1366e
|
||||
value: 535552075c510a595b5f557040770e484e164d792d7d75657d791e62b4e4366b
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-3:
|
||||
value: 515250075c0c595e5f5a5e71122159444e4e4a2f7a7d7f602f284d66b4b76661
|
||||
value: 550350030051080c080c0d21437759124716197b792977697a2b4936e6e26c3d
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-4:
|
||||
value: 005704520005080c5959542646205b4447154d2e7b7d7e34787f1e6ab0b56c3a
|
||||
value: 0104025352005d0f0e0d0d2741775c12401519287c297167282a1935b1b13269
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-5:
|
||||
value: 53525155015459595c5d5e7315700744174e1a7f7a797e627f2b4b6abab3326f
|
||||
value: 5409035450035e0e0c5d5a7a13770a40454e4f722f7f24347e2d1f30b0b76360
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-6:
|
||||
value: 5a09065056055c0e595d0a20447b0b4415164e2b297c75682f7c1866b0b3656c
|
||||
value: 07060c5454040c0a545b547240700a441216417e7f2e7268752c4966b4b0663d
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-7:
|
||||
value: 0750065f5d57580c5c0b5d7741275e44464e1d297b7e77342e784a64b3e13539
|
||||
value: 5309035757065a0a54575f7216265c4444151d28792e72627d2f1935bbb8673a
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-8:
|
||||
value: 01085257040c5f0e0c0d5f27457b0f444e4e192c7b2d7e6428794d67e3b36668
|
||||
value: 5505015f5c515a085f5b092149760f441716407a787d7564287b1b36e7e1366e
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-9:
|
||||
value: 0054045155060d5a5c575f7045270d44474f4e7c7f7924637e2a1832b1b5636d
|
||||
|
||||
Reference in New Issue
Block a user