升级6.4.升级水,升级天气
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
using UnityEngine;
|
||||
using WaveHarmonic.Crest.Internal;
|
||||
|
||||
namespace WaveHarmonic.Crest.Examples
|
||||
{
|
||||
@@ -11,12 +12,10 @@ namespace WaveHarmonic.Crest.Examples
|
||||
#if !CREST_DEBUG
|
||||
[AddComponentMenu("")]
|
||||
#endif
|
||||
sealed class RandomMotion : MonoBehaviour
|
||||
sealed class RandomMotion : CustomBehaviour
|
||||
{
|
||||
[SerializeField, HideInInspector]
|
||||
#pragma warning disable 414
|
||||
int _Version = 0;
|
||||
#pragma warning restore 414
|
||||
[SerializeField]
|
||||
bool _WorldSpace;
|
||||
|
||||
[Header("Translation")]
|
||||
|
||||
@@ -49,10 +48,11 @@ namespace WaveHarmonic.Crest.Examples
|
||||
Vector3 _Origin;
|
||||
Vector3 _OrthogonalAxis;
|
||||
|
||||
|
||||
void Start()
|
||||
private protected override void OnStart()
|
||||
{
|
||||
_Origin = transform.position;
|
||||
base.OnStart();
|
||||
|
||||
_Origin = _WorldSpace ? transform.position : transform.localPosition;
|
||||
|
||||
_OrthogonalAxis = Quaternion.AngleAxis(90f, Vector3.up) * _Axis;
|
||||
}
|
||||
@@ -64,10 +64,21 @@ namespace WaveHarmonic.Crest.Examples
|
||||
// Do circles in perlin noise
|
||||
var rnd = 2f * (Mathf.PerlinNoise(0.5f + 0.5f * Mathf.Cos(_Frequency * Time.time), 0.5f + 0.5f * Mathf.Sin(_Frequency * Time.time)) - 0.5f);
|
||||
|
||||
// Prevent jump at start.
|
||||
var amplitude = Mathf.Min(_Amplitude, _Amplitude * Time.timeSinceLevelLoad);
|
||||
|
||||
var orthoPhaseOff = Mathf.PI / 2f;
|
||||
var rndOrtho = 2f * (Mathf.PerlinNoise(0.5f + 0.5f * Mathf.Cos(_Frequency * Time.time + orthoPhaseOff), 0.5f + 0.5f * Mathf.Sin(_Frequency * Time.time + orthoPhaseOff)) - 0.5f);
|
||||
var position = _Origin + (_Axis * rnd + _OrthogonalMotion * rndOrtho * _OrthogonalAxis) * amplitude;
|
||||
|
||||
transform.position = _Origin + (_Axis * rnd + _OrthogonalMotion * rndOrtho * _OrthogonalAxis) * _Amplitude;
|
||||
if (_WorldSpace)
|
||||
{
|
||||
transform.position = position;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localPosition = position;
|
||||
}
|
||||
}
|
||||
|
||||
// Rotation
|
||||
|
||||
Reference in New Issue
Block a user