FututeWand初步
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Cielonos.MainGame.Buffs.Character;
|
||||
using Opsive.BehaviorDesigner.Runtime;
|
||||
using SLSUtilities.General;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
@@ -18,10 +19,74 @@ namespace Cielonos.MainGame.Characters
|
||||
navMeshAgent.isStopped = true;
|
||||
animatorMoveSpeedX = new LerpFloat(0f, 5f);
|
||||
animatorMoveSpeedZ = new LerpFloat(0f, 5f);
|
||||
//owner.selfTimeSm.timeScaleObservable.Subscribe(OnTimeScaleChanged).AddTo(owner);
|
||||
}
|
||||
|
||||
private Vector3 lastDirection;
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────
|
||||
// Time Scale Sync
|
||||
// ────────────────────────────────────────────────────────────────────
|
||||
|
||||
private float unscaledNavSpeed;
|
||||
private float unscaledNavAccel;
|
||||
private float unscaledNavAngularSpeed;
|
||||
private bool wasNavStoppedBeforePause;
|
||||
private float lastTimeScale = -1f;
|
||||
private bool isTimePaused = false;
|
||||
|
||||
private void OnTimeScaleChanged(float timeScale)
|
||||
{
|
||||
if (navMeshAgent == null || !navMeshAgent.enabled)
|
||||
{
|
||||
if (timeScale == 0f && !isTimePaused)
|
||||
{
|
||||
isTimePaused = true;
|
||||
}
|
||||
else if (timeScale > 0f && isTimePaused)
|
||||
{
|
||||
isTimePaused = false;
|
||||
}
|
||||
lastTimeScale = timeScale;
|
||||
return;
|
||||
}
|
||||
|
||||
if (timeScale == 0f)
|
||||
{
|
||||
if (!isTimePaused)
|
||||
{
|
||||
isTimePaused = true;
|
||||
wasNavStoppedBeforePause = navMeshAgent.isStopped;
|
||||
navMeshAgent.isStopped = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
navMeshAgent.isStopped = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isTimePaused)
|
||||
{
|
||||
isTimePaused = false;
|
||||
navMeshAgent.isStopped = wasNavStoppedBeforePause;
|
||||
}
|
||||
|
||||
if (Mathf.Abs(navMeshAgent.speed - (unscaledNavSpeed * timeScale)) > 0.01f)
|
||||
{
|
||||
unscaledNavSpeed = navMeshAgent.speed;
|
||||
unscaledNavAccel = navMeshAgent.acceleration;
|
||||
unscaledNavAngularSpeed = navMeshAgent.angularSpeed;
|
||||
}
|
||||
|
||||
navMeshAgent.speed = unscaledNavSpeed * timeScale;
|
||||
navMeshAgent.acceleration = unscaledNavAccel * timeScale;
|
||||
navMeshAgent.angularSpeed = unscaledNavAngularSpeed * timeScale;
|
||||
}
|
||||
|
||||
lastTimeScale = timeScale;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Reference in New Issue
Block a user