修改提交
This commit is contained in:
@@ -219,9 +219,9 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 3116177874895914436}
|
- component: {fileID: 3116177874895914436}
|
||||||
- component: {fileID: 1033618195002336566}
|
- component: {fileID: 1033618195002336566}
|
||||||
- component: {fileID: 9117070148710828175}
|
|
||||||
- component: {fileID: 4152162740525283091}
|
- component: {fileID: 4152162740525283091}
|
||||||
- component: {fileID: 2513762410452133691}
|
- component: {fileID: 2513762410452133691}
|
||||||
|
- component: {fileID: 3049258369283796050}
|
||||||
m_Layer: 15
|
m_Layer: 15
|
||||||
m_Name: Bobber
|
m_Name: Bobber
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -271,29 +271,6 @@ Rigidbody:
|
|||||||
m_Interpolate: 0
|
m_Interpolate: 0
|
||||||
m_Constraints: 0
|
m_Constraints: 0
|
||||||
m_CollisionDetection: 0
|
m_CollisionDetection: 0
|
||||||
--- !u!136 &9117070148710828175
|
|
||||||
CapsuleCollider:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 5252216124238432432}
|
|
||||||
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.003
|
|
||||||
m_Height: 0.02
|
|
||||||
m_Direction: 1
|
|
||||||
m_Center: {x: 0, y: 0.03, z: 0}
|
|
||||||
--- !u!114 &4152162740525283091
|
--- !u!114 &4152162740525283091
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -373,6 +350,27 @@ MonoBehaviour:
|
|||||||
invertTiltDirection: 0
|
invertTiltDirection: 0
|
||||||
rotationLerpSpeed: 8
|
rotationLerpSpeed: 8
|
||||||
waterAngularDamping: 999
|
waterAngularDamping: 999
|
||||||
|
--- !u!65 &3049258369283796050
|
||||||
|
BoxCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5252216124238432432}
|
||||||
|
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: 3
|
||||||
|
m_Size: {x: 0.02, y: 0.02, z: 0.02}
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &5438655829551842420
|
--- !u!1 &5438655829551842420
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -500,7 +498,7 @@ LineRenderer:
|
|||||||
m_Curve:
|
m_Curve:
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
time: 0
|
time: 0
|
||||||
value: 0.002
|
value: 0.001
|
||||||
inSlope: 0
|
inSlope: 0
|
||||||
outSlope: 0
|
outSlope: 0
|
||||||
tangentMode: 0
|
tangentMode: 0
|
||||||
@@ -580,8 +578,6 @@ MonoBehaviour:
|
|||||||
sleepDistanceThreshold: 0.002
|
sleepDistanceThreshold: 0.002
|
||||||
stableFramesBeforeSleep: 4
|
stableFramesBeforeSleep: 4
|
||||||
wakeDistanceThreshold: 0.001
|
wakeDistanceThreshold: 0.001
|
||||||
tautSegmentThreshold: 0.002
|
|
||||||
tautTransitionRange: 0.03
|
|
||||||
smoothCorners: 1
|
smoothCorners: 1
|
||||||
minCornerAngle: 12
|
minCornerAngle: 12
|
||||||
maxCornerSmoothDistance: 0.03
|
maxCornerSmoothDistance: 0.03
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ namespace NBF
|
|||||||
private bool _waterStateInitialized;
|
private bool _waterStateInitialized;
|
||||||
private float _defaultAngularDamping;
|
private float _defaultAngularDamping;
|
||||||
private bool _defaultUseGravity;
|
private bool _defaultUseGravity;
|
||||||
|
private RigidbodyConstraints _defaultConstraints;
|
||||||
|
|
||||||
private float _draftVelocity;
|
private float _draftVelocity;
|
||||||
private float _currentDraftDepth;
|
private float _currentDraftDepth;
|
||||||
@@ -195,6 +196,8 @@ namespace NBF
|
|||||||
private float _biteOffsetY;
|
private float _biteOffsetY;
|
||||||
private float _biteOffsetYVelocity;
|
private float _biteOffsetYVelocity;
|
||||||
|
|
||||||
|
private bool _uprightPoseCached;
|
||||||
|
private Quaternion _cachedUprightRotation;
|
||||||
private Quaternion _uprightReferenceRotation;
|
private Quaternion _uprightReferenceRotation;
|
||||||
private Quaternion _targetRotation;
|
private Quaternion _targetRotation;
|
||||||
|
|
||||||
@@ -284,8 +287,9 @@ namespace NBF
|
|||||||
|
|
||||||
UpdateBiteAnimation(deltaTime);
|
UpdateBiteAnimation(deltaTime);
|
||||||
UpdateDraft(deltaTime);
|
UpdateDraft(deltaTime);
|
||||||
UpdateVerticalPosition(deltaTime);
|
var nextRotation = CalculateNextRotation(deltaTime);
|
||||||
UpdateRotation(deltaTime);
|
UpdateVerticalPosition(deltaTime, nextRotation);
|
||||||
|
ApplyRotation(nextRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -360,6 +364,7 @@ namespace NBF
|
|||||||
{
|
{
|
||||||
_defaultAngularDamping = _rb.angularDamping;
|
_defaultAngularDamping = _rb.angularDamping;
|
||||||
_defaultUseGravity = _rb.useGravity;
|
_defaultUseGravity = _rb.useGravity;
|
||||||
|
_defaultConstraints = _rb.constraints;
|
||||||
_defaultsCached = true;
|
_defaultsCached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,12 +373,15 @@ namespace NBF
|
|||||||
_ySmoothVelocity = 0f;
|
_ySmoothVelocity = 0f;
|
||||||
_biteOffsetY = 0f;
|
_biteOffsetY = 0f;
|
||||||
_biteOffsetYVelocity = 0f;
|
_biteOffsetYVelocity = 0f;
|
||||||
_targetRotation = transform.rotation;
|
_targetRotation = _rb.rotation;
|
||||||
|
|
||||||
if (!_waterStateInitialized)
|
if (!_uprightPoseCached)
|
||||||
{
|
{
|
||||||
_uprightReferenceRotation = transform.rotation;
|
_cachedUprightRotation = _rb.rotation;
|
||||||
|
_uprightPoseCached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_uprightReferenceRotation = _cachedUprightRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnterWaterPresentationMode()
|
private void EnterWaterPresentationMode()
|
||||||
@@ -385,8 +393,8 @@ namespace NBF
|
|||||||
|
|
||||||
_mode = FishingBobberControlMode.WaterPresentation;
|
_mode = FishingBobberControlMode.WaterPresentation;
|
||||||
_waterStateInitialized = true;
|
_waterStateInitialized = true;
|
||||||
_uprightReferenceRotation = transform.rotation;
|
_uprightReferenceRotation = _cachedUprightRotation;
|
||||||
_targetRotation = transform.rotation;
|
_targetRotation = _rb.rotation;
|
||||||
_draftVelocity = 0f;
|
_draftVelocity = 0f;
|
||||||
_ySmoothVelocity = 0f;
|
_ySmoothVelocity = 0f;
|
||||||
_biteOffsetYVelocity = 0f;
|
_biteOffsetYVelocity = 0f;
|
||||||
@@ -394,6 +402,8 @@ namespace NBF
|
|||||||
|
|
||||||
_rb.useGravity = false;
|
_rb.useGravity = false;
|
||||||
_rb.angularDamping = waterAngularDamping;
|
_rb.angularDamping = waterAngularDamping;
|
||||||
|
_rb.constraints = _defaultConstraints | RigidbodyConstraints.FreezeRotation;
|
||||||
|
_rb.angularVelocity = Vector3.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExitWaterPresentationMode()
|
private void ExitWaterPresentationMode()
|
||||||
@@ -411,6 +421,7 @@ namespace NBF
|
|||||||
|
|
||||||
_rb.useGravity = _defaultUseGravity;
|
_rb.useGravity = _defaultUseGravity;
|
||||||
_rb.angularDamping = _defaultAngularDamping;
|
_rb.angularDamping = _defaultAngularDamping;
|
||||||
|
_rb.constraints = _defaultConstraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetSubmergeDepth()
|
private float GetSubmergeDepth()
|
||||||
@@ -442,10 +453,10 @@ namespace NBF
|
|||||||
deltaTime);
|
deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateVerticalPosition(float deltaTime)
|
private void UpdateVerticalPosition(float deltaTime, Quaternion targetRotation)
|
||||||
{
|
{
|
||||||
var position = transform.position;
|
var position = _rb.position;
|
||||||
var targetY = waterLevel - _currentDraftDepth - bottomOffsetLocalY + _biteOffsetY;
|
var targetY = waterLevel - _currentDraftDepth - GetBottomOffsetWorldY(targetRotation) + _biteOffsetY;
|
||||||
|
|
||||||
if (Mathf.Abs(position.y - targetY) < yDeadZone)
|
if (Mathf.Abs(position.y - targetY) < yDeadZone)
|
||||||
{
|
{
|
||||||
@@ -463,7 +474,7 @@ namespace NBF
|
|||||||
deltaTime);
|
deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
transform.position = position;
|
_rb.MovePosition(position);
|
||||||
|
|
||||||
var velocity = _rb.linearVelocity;
|
var velocity = _rb.linearVelocity;
|
||||||
if (Mathf.Abs(velocity.y) > 0f)
|
if (Mathf.Abs(velocity.y) > 0f)
|
||||||
@@ -473,7 +484,7 @@ namespace NBF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateRotation(float deltaTime)
|
private Quaternion CalculateNextRotation(float deltaTime)
|
||||||
{
|
{
|
||||||
var targetTiltAngle = EvaluateTargetTiltAngle();
|
var targetTiltAngle = EvaluateTargetTiltAngle();
|
||||||
var signedAngle = invertTiltDirection ? -targetTiltAngle : targetTiltAngle;
|
var signedAngle = invertTiltDirection ? -targetTiltAngle : targetTiltAngle;
|
||||||
@@ -481,12 +492,22 @@ namespace NBF
|
|||||||
|
|
||||||
_targetRotation = _uprightReferenceRotation * Quaternion.AngleAxis(signedAngle, localAxis);
|
_targetRotation = _uprightReferenceRotation * Quaternion.AngleAxis(signedAngle, localAxis);
|
||||||
_rb.angularVelocity = Vector3.zero;
|
_rb.angularVelocity = Vector3.zero;
|
||||||
transform.rotation = Quaternion.Slerp(
|
return Quaternion.Slerp(
|
||||||
transform.rotation,
|
_rb.rotation,
|
||||||
_targetRotation,
|
_targetRotation,
|
||||||
1f - Mathf.Exp(-Mathf.Max(0.01f, rotationLerpSpeed) * deltaTime));
|
1f - Mathf.Exp(-Mathf.Max(0.01f, rotationLerpSpeed) * deltaTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ApplyRotation(Quaternion nextRotation)
|
||||||
|
{
|
||||||
|
_rb.rotation = nextRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float GetBottomOffsetWorldY(Quaternion rotation)
|
||||||
|
{
|
||||||
|
return (rotation * new Vector3(0f, bottomOffsetLocalY, 0f)).y;
|
||||||
|
}
|
||||||
|
|
||||||
private float EvaluateTargetTiltAngle()
|
private float EvaluateTargetTiltAngle()
|
||||||
{
|
{
|
||||||
if (currentBottomWeight <= lyingWeightThreshold)
|
if (currentBottomWeight <= lyingWeightThreshold)
|
||||||
|
|||||||
Reference in New Issue
Block a user