移除水

This commit is contained in:
2025-06-21 21:58:06 +08:00
parent d61516a576
commit e9f76d0f11
1566 changed files with 9218 additions and 300913 deletions

View File

@@ -1,6 +1,6 @@
using System;
using UnityEngine;
using WaveHarmonic.Crest;
// using WaveHarmonic.Crest;
namespace NBF
{
@@ -37,17 +37,17 @@ namespace NBF
/// </summary>
public Transform standPlace;
/// <summary>
/// 浮力组件
/// </summary>
private FloatingObject _floatingObject;
// /// <summary>
// /// 浮力组件
// /// </summary>
// private FloatingObject _floatingObject;
private float _BuoyancyFactor = 1f;
private void Awake()
{
boatCollider = GetComponent<Collider>();
if (_floatingObject == null) _floatingObject = GetComponent<FloatingObject>();
// if (_floatingObject == null) _floatingObject = GetComponent<FloatingObject>();
}
@@ -63,42 +63,42 @@ namespace NBF
public void BoatInput(Vector2 moveInput, bool isRun = false)
{
if (!_floatingObject.InWater) return;
var input = Vector3.zero;
input.x = moveInput.x; // 水平转向x轴
input.z = moveInput.y; // 前后移动y轴映射到z轴
var rb = _floatingObject.RigidBody;
var power = isRun ? _ThrustMaxPower : _ThrustPower;
// Thrust
var forcePosition = rb.worldCenterOfMass + _ForceHeightOffset * Vector3.up;
rb.AddForceAtPosition(power * input.z * transform.forward, forcePosition, ForceMode.Acceleration);
// Steer
var rotation = transform.up + _TurningHeel * transform.forward;
rb.AddTorque(_SteerPower * input.x * rotation, ForceMode.Acceleration);
if (input.y > 0f)
{
if (_BuoyancyFactor < 1f)
{
_BuoyancyFactor += Time.deltaTime * 0.1f;
_BuoyancyFactor = Mathf.Clamp(_BuoyancyFactor, 0f, 1f);
_floatingObject.BuoyancyForceStrength = _BuoyancyCurveFactor.Evaluate(_BuoyancyFactor);
}
}
else if (input.y < 0f)
{
if (_BuoyancyFactor > 0f)
{
_BuoyancyFactor -= Time.deltaTime * 0.1f;
_BuoyancyFactor = Mathf.Clamp(_BuoyancyFactor, 0f, 1f);
_floatingObject.BuoyancyForceStrength = _BuoyancyCurveFactor.Evaluate(_BuoyancyFactor);
}
}
// if (!_floatingObject.InWater) return;
//
// var input = Vector3.zero;
// input.x = moveInput.x; // 水平转向x轴
// input.z = moveInput.y; // 前后移动y轴映射到z轴
//
// var rb = _floatingObject.RigidBody;
//
// var power = isRun ? _ThrustMaxPower : _ThrustPower;
//
// // Thrust
// var forcePosition = rb.worldCenterOfMass + _ForceHeightOffset * Vector3.up;
// rb.AddForceAtPosition(power * input.z * transform.forward, forcePosition, ForceMode.Acceleration);
//
// // Steer
// var rotation = transform.up + _TurningHeel * transform.forward;
// rb.AddTorque(_SteerPower * input.x * rotation, ForceMode.Acceleration);
//
// if (input.y > 0f)
// {
// if (_BuoyancyFactor < 1f)
// {
// _BuoyancyFactor += Time.deltaTime * 0.1f;
// _BuoyancyFactor = Mathf.Clamp(_BuoyancyFactor, 0f, 1f);
// _floatingObject.BuoyancyForceStrength = _BuoyancyCurveFactor.Evaluate(_BuoyancyFactor);
// }
// }
// else if (input.y < 0f)
// {
// if (_BuoyancyFactor > 0f)
// {
// _BuoyancyFactor -= Time.deltaTime * 0.1f;
// _BuoyancyFactor = Mathf.Clamp(_BuoyancyFactor, 0f, 1f);
// _floatingObject.BuoyancyForceStrength = _BuoyancyCurveFactor.Evaluate(_BuoyancyFactor);
// }
// }
}
}
}