修改捏线逻辑
This commit is contained in:
@@ -77,6 +77,8 @@ MonoBehaviour:
|
||||
waterSampleStep: 2
|
||||
waterInterpolate: 1
|
||||
waterUpdateEvery: 1
|
||||
waterLiftStrength: 0.25
|
||||
keepStartAdjacentNodeFollow: 1
|
||||
waterPostConstraintIterations: 2
|
||||
renderSubdivisionsIdle: 6
|
||||
renderSubdivisionsMoving: 2
|
||||
@@ -209,7 +211,7 @@ GameObject:
|
||||
- component: {fileID: 135844594273256032}
|
||||
- component: {fileID: 1923684598771359451}
|
||||
- component: {fileID: 2475726686148443307}
|
||||
m_Layer: 7
|
||||
m_Layer: 15
|
||||
m_Name: Lure
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
@@ -494,7 +496,7 @@ GameObject:
|
||||
- component: {fileID: 153691655494134957}
|
||||
- component: {fileID: 2717383850592950062}
|
||||
- component: {fileID: 6678694395924494533}
|
||||
m_Layer: 16
|
||||
m_Layer: 15
|
||||
m_Name: Float
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
@@ -672,6 +674,9 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::BobberPresentationController
|
||||
fallbackWaterLevel: 0
|
||||
waterRenderer: {fileID: 0}
|
||||
waterCollisionLayer: 1
|
||||
waterQueryObjectWidth: 0.5
|
||||
waterProviderBehaviour: {fileID: 114112904742580403}
|
||||
enterWaterDepth: 0.002
|
||||
exitWaterDepth: -0.01
|
||||
@@ -699,10 +704,14 @@ MonoBehaviour:
|
||||
planarTiltThreshold: 0.3
|
||||
planarDominanceMultiplier: 1.2
|
||||
postureHysteresis: 0.04
|
||||
postureConfirmTime: 0.08
|
||||
postureSwitchCooldown: 0.1
|
||||
tiltedAngle: 38
|
||||
lyingAngle: 88
|
||||
uprightMaxTiltAngle: 8
|
||||
planarTiltFactor: 120
|
||||
planarDirectionDeadZone: 0.01
|
||||
planarDirectionLerpSpeed: 10
|
||||
rotationLerpSpeed: 8
|
||||
debugResetKey: 1
|
||||
debugTapKey: 1
|
||||
@@ -710,6 +719,8 @@ MonoBehaviour:
|
||||
debugLiftKey: 1
|
||||
debugBlackDriftKey: 1
|
||||
drawDebug: 1
|
||||
UseTestPosture: 0
|
||||
TestPosture: 0
|
||||
--- !u!1 &1933124697579601
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -787,6 +798,8 @@ MonoBehaviour:
|
||||
waterSampleStep: 2
|
||||
waterInterpolate: 1
|
||||
waterUpdateEvery: 1
|
||||
waterLiftStrength: 0.25
|
||||
keepStartAdjacentNodeFollow: 1
|
||||
waterPostConstraintIterations: 2
|
||||
renderSubdivisionsIdle: 6
|
||||
renderSubdivisionsMoving: 2
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
@@ -14,8 +15,11 @@ namespace NBF
|
||||
private Rigidbody rb;
|
||||
|
||||
|
||||
private float maxCatchupDuration = 0.5f;
|
||||
private Transform targetTransform;
|
||||
private float originalSpring;
|
||||
private float pinchElapsedTime;
|
||||
|
||||
|
||||
public bool isPinched { get; private set; }
|
||||
|
||||
@@ -31,27 +35,37 @@ namespace NBF
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (isPinched && targetTransform != null)
|
||||
if (isPinched && !moveToTargetDone && targetTransform != null)
|
||||
{
|
||||
transform.position =
|
||||
Vector3.MoveTowards(transform.position, targetTransform.position, Time.deltaTime * _speed);
|
||||
if (!moveToTargetDone)
|
||||
pinchElapsedTime += Time.fixedDeltaTime;
|
||||
// transform.position =
|
||||
// Vector3.MoveTowards(transform.position, targetTransform.position, Time.deltaTime * _speed);
|
||||
rb.MovePosition(Vector3.MoveTowards(transform.position, targetTransform.position,
|
||||
Time.deltaTime * _speed));
|
||||
if (Vector3.Distance(transform.position, targetTransform.position) < 0.1f ||
|
||||
pinchElapsedTime >= maxCatchupDuration)
|
||||
{
|
||||
if (Vector3.Distance(transform.position, targetTransform.position) < 0.1f)
|
||||
{
|
||||
moveToTargetDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (moveToTargetDone)
|
||||
{
|
||||
transform.position = targetTransform.position;
|
||||
moveToTargetDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
SyncPosition();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
SyncPosition();
|
||||
}
|
||||
|
||||
private void SyncPosition()
|
||||
{
|
||||
if (!isPinched) return;
|
||||
if (!moveToTargetDone) return;
|
||||
rb.MovePosition(targetTransform.position);
|
||||
}
|
||||
|
||||
// 外部调用:开始捏住流程
|
||||
public void StartPinch(Transform fingerTransform, float speed = 3)
|
||||
public void StartPinch(Transform fingerTransform, float speed = 3, float _maxCatchupDuration = 0.3f)
|
||||
{
|
||||
_speed = speed;
|
||||
Rigidbody fingerRb = fingerTransform.GetComponent<Rigidbody>();
|
||||
@@ -61,6 +75,8 @@ namespace NBF
|
||||
return;
|
||||
}
|
||||
|
||||
maxCatchupDuration = _maxCatchupDuration;
|
||||
pinchElapsedTime = 0f;
|
||||
isPinched = true;
|
||||
rb.useGravity = false;
|
||||
rb.isKinematic = true;
|
||||
|
||||
Reference in New Issue
Block a user