LookAt调整
This commit is contained in:
@@ -51,7 +51,7 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 currentPosition = new Vector3(positionX.value, positionY.value, positionZ.value);
|
||||
targetTransformSubmodule.positionOffset.Add(currentPosition);
|
||||
targetTransformSubmodule.positionOffset += currentPosition;
|
||||
targetTransformSubmodule.positionDirtyMark = true;
|
||||
}
|
||||
else
|
||||
@@ -59,7 +59,7 @@ namespace Ichni.RhythmGame
|
||||
if (!EditorManager.instance.musicPlayer.isPlaying && animationReturnType != FlexibleReturnType.MiddleInterval)
|
||||
{
|
||||
Vector3 currentPosition = new Vector3(positionX.value, positionY.value, positionZ.value);
|
||||
targetTransformSubmodule.positionOffset.Add(currentPosition);
|
||||
targetTransformSubmodule.positionOffset += currentPosition;
|
||||
targetTransformSubmodule.positionDirtyMark = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,32 +43,32 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
}
|
||||
protected override void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
UpdateAnimation(EditorManager.instance.songInformation.songTime);
|
||||
(animatedObject as IHaveTransformSubmodule)?.UpdateLookAt(this);
|
||||
}
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
if (lookAtObject == null) return;
|
||||
|
||||
enabling.UpdateFlexibleBool(songTime);
|
||||
targetTransformSubmodule.eulerAnglesOffsetLock = enabling.value;
|
||||
|
||||
|
||||
enabling.UpdateFlexibleBool(EditorManager.instance.songInformation.songTime);
|
||||
|
||||
if (!targetTransformSubmodule.eulerAnglesOffsetLock || enabling.value)
|
||||
{
|
||||
targetTransformSubmodule.eulerAnglesOffsetLock = enabling.value;
|
||||
}
|
||||
|
||||
if (enabling.value)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
targetTransformSubmodule.eulerAnglesDirtyMark = true;
|
||||
gameCamera.UpdateLookAt(this);
|
||||
|
||||
}
|
||||
else if (animationReturnType != FlexibleReturnType.MiddleInterval)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleInterval;
|
||||
targetTransformSubmodule.eulerAnglesOffset.Add(Vector3.zero);
|
||||
targetTransformSubmodule.eulerAnglesDirtyMark = true;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,6 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
targetTransformSubmodule.eulerAnglesOffset.Add(Vector3.zero);
|
||||
targetTransformSubmodule.eulerAnglesDirtyMark = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
||||
targetTransformSubmodule.scaleOffset.Add(currentScale);
|
||||
targetTransformSubmodule.scaleOffset += currentScale;
|
||||
targetTransformSubmodule.scaleDirtyMark = true;
|
||||
}
|
||||
else
|
||||
@@ -59,7 +59,7 @@ namespace Ichni.RhythmGame
|
||||
if (!EditorManager.instance.musicPlayer.isPlaying && animationReturnType != FlexibleReturnType.MiddleInterval)
|
||||
{
|
||||
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
||||
targetTransformSubmodule.scaleOffset.Add(currentScale);
|
||||
targetTransformSubmodule.scaleOffset += currentScale;
|
||||
targetTransformSubmodule.scaleDirtyMark = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 currentEulerAngles = new Vector3(eulerAngleX.value, eulerAngleY.value, eulerAngleZ.value);
|
||||
targetTransformSubmodule.eulerAnglesOffset.Add(currentEulerAngles);
|
||||
targetTransformSubmodule.eulerAnglesOffset += currentEulerAngles;
|
||||
targetTransformSubmodule.eulerAnglesDirtyMark = true;
|
||||
}
|
||||
else
|
||||
@@ -58,7 +58,7 @@ namespace Ichni.RhythmGame
|
||||
if (!EditorManager.instance.musicPlayer.isPlaying && animationReturnType != FlexibleReturnType.MiddleInterval)
|
||||
{
|
||||
Vector3 currentRotation = new Vector3(eulerAngleX.value, eulerAngleY.value, eulerAngleZ.value);
|
||||
targetTransformSubmodule.eulerAnglesOffset.Add(currentRotation);
|
||||
targetTransformSubmodule.eulerAnglesOffset += currentRotation;
|
||||
targetTransformSubmodule.eulerAnglesDirtyMark = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ namespace Ichni.RhythmGame
|
||||
public Vector3 originalEulerAngles;
|
||||
public Vector3 originalScale;
|
||||
|
||||
public List<Vector3> positionOffset;
|
||||
public List<Vector3> eulerAnglesOffset;
|
||||
public List<Vector3> scaleOffset;
|
||||
public Vector3 positionOffset;
|
||||
public Vector3 eulerAnglesOffset;
|
||||
public Vector3 scaleOffset;
|
||||
|
||||
public Vector3 currentPosition;
|
||||
public Vector3 currentEulerAngles;
|
||||
@@ -38,10 +38,10 @@ namespace Ichni.RhythmGame
|
||||
this.originalEulerAngles = Vector3.zero;
|
||||
this.originalScale = Vector3.one;
|
||||
|
||||
positionOffset = new List<Vector3>();
|
||||
eulerAnglesOffset = new List<Vector3>();
|
||||
scaleOffset = new List<Vector3>();
|
||||
|
||||
positionOffset = Vector3.zero;
|
||||
eulerAnglesOffset = Vector3.zero;
|
||||
scaleOffset = Vector3.zero;
|
||||
|
||||
currentPosition = Vector3.zero;
|
||||
currentEulerAngles = Vector3.zero;
|
||||
currentScale = Vector3.one;
|
||||
@@ -66,10 +66,10 @@ namespace Ichni.RhythmGame
|
||||
this.originalEulerAngles = originalEulerAngles;
|
||||
this.originalScale = originalScale;
|
||||
|
||||
positionOffset = new List<Vector3>();
|
||||
eulerAnglesOffset = new List<Vector3>();
|
||||
scaleOffset = new List<Vector3>();
|
||||
|
||||
positionOffset = Vector3.zero;
|
||||
eulerAnglesOffset = Vector3.zero;
|
||||
scaleOffset = Vector3.zero;
|
||||
|
||||
currentPosition = originalPosition;
|
||||
currentEulerAngles = originalEulerAngles;
|
||||
currentScale = originalScale;
|
||||
@@ -158,32 +158,29 @@ namespace Ichni.RhythmGame
|
||||
|
||||
if (transformSubmodule.scaleDirtyMark)
|
||||
{
|
||||
Vector3 offset = transformSubmodule.scaleOffset.Sum();
|
||||
transformSubmodule.currentScale = transformSubmodule.originalScale + offset;
|
||||
transformSubmodule.currentScale = transformSubmodule.originalScale + transformSubmodule.scaleOffset;
|
||||
attachedGameElement.transform.localScale = transformSubmodule.currentScale;
|
||||
transformSubmodule.scaleDirtyMark = false;
|
||||
willRefresh = true;
|
||||
transformSubmodule.scaleOffset.Clear();
|
||||
transformSubmodule.scaleOffset = Vector3.zero;
|
||||
}
|
||||
|
||||
if (transformSubmodule.eulerAnglesDirtyMark)
|
||||
if (!transformSubmodule.eulerAnglesOffsetLock && transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
Vector3 offset = transformSubmodule.eulerAnglesOffset.Sum();
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + transformSubmodule.eulerAnglesOffset;
|
||||
attachedGameElement.transform.localEulerAngles = transformSubmodule.currentEulerAngles;
|
||||
transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
willRefresh = true;
|
||||
transformSubmodule.eulerAnglesOffset.Clear();
|
||||
transformSubmodule.eulerAnglesOffset = Vector3.zero;
|
||||
}
|
||||
|
||||
if (transformSubmodule.positionDirtyMark)
|
||||
{
|
||||
Vector3 offset = transformSubmodule.positionOffset.Sum();
|
||||
transformSubmodule.currentPosition = transformSubmodule.originalPosition + offset;
|
||||
transformSubmodule.currentPosition = transformSubmodule.originalPosition + transformSubmodule.positionOffset;
|
||||
attachedGameElement.transform.localPosition = transformSubmodule.currentPosition;
|
||||
transformSubmodule.positionDirtyMark = false;
|
||||
willRefresh = true;
|
||||
transformSubmodule.positionOffset.Clear();
|
||||
transformSubmodule.positionOffset = Vector3.zero;
|
||||
}
|
||||
|
||||
if(willRefresh)
|
||||
@@ -193,6 +190,28 @@ namespace Ichni.RhythmGame
|
||||
|
||||
}).AddTo(attachedGameElement);
|
||||
}
|
||||
|
||||
public void UpdateLookAt(LookAt lookAt) // 处理LookAt
|
||||
{
|
||||
Transform target = lookAt.lookAtObject.transform;
|
||||
Transform self = transformSubmodule.attachedGameElement.transform;
|
||||
|
||||
if (transformSubmodule.eulerAnglesOffsetLock && transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
Vector3 lookingDirection = (target.position - self.position).normalized;
|
||||
|
||||
Vector3 eulerAnglesOffset = Quaternion.LookRotation(lookingDirection).eulerAngles;
|
||||
|
||||
transformSubmodule.eulerAnglesOffset += eulerAnglesOffset;
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + transformSubmodule.eulerAnglesOffset;
|
||||
|
||||
self.localEulerAngles = transformSubmodule.currentEulerAngles;
|
||||
|
||||
transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
transformSubmodule.eulerAnglesOffsetLock = false;
|
||||
transformSubmodule.eulerAnglesOffset = Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
|
||||
@@ -93,29 +93,6 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public partial class GameCamera
|
||||
{
|
||||
public void UpdateLookAt(LookAt lookAt) // 处理LookAt
|
||||
{
|
||||
if (
|
||||
transformSubmodule.eulerAnglesOffsetLock &&
|
||||
transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
|
||||
Vector3 lookingDirection = (lookAt.lookAtObject.transform.position - transform.position).normalized;
|
||||
|
||||
Vector3 eulerAnglesOffse = Quaternion.LookRotation(lookingDirection).eulerAngles;
|
||||
|
||||
transformSubmodule.eulerAnglesOffset.Add(eulerAnglesOffse);
|
||||
Vector3 offset = transformSubmodule.eulerAnglesOffset.Sum();
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
|
||||
|
||||
// transform.LookAt(transformSubmodule.lookAt.lookAtObject.transform);
|
||||
transform.localEulerAngles = transformSubmodule.currentEulerAngles;
|
||||
|
||||
transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
transformSubmodule.eulerAnglesOffset.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTransformObserver()
|
||||
{
|
||||
Observable.EveryLateUpdate().Subscribe(_ =>
|
||||
@@ -129,22 +106,20 @@ namespace Ichni.RhythmGame
|
||||
|
||||
if (!transformSubmodule.eulerAnglesOffsetLock && transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
Vector3 offset = transformSubmodule.eulerAnglesOffset.Sum();
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + transformSubmodule.eulerAnglesOffset;
|
||||
transform.localEulerAngles = transformSubmodule.currentEulerAngles;
|
||||
transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
willRefresh = true;
|
||||
transformSubmodule.eulerAnglesOffset.Clear();
|
||||
transformSubmodule.eulerAnglesOffset = Vector3.zero;
|
||||
}
|
||||
|
||||
if (transformSubmodule.positionDirtyMark)
|
||||
{
|
||||
Vector3 offset = transformSubmodule.positionOffset.Sum();
|
||||
transformSubmodule.currentPosition = transformSubmodule.originalPosition + offset;
|
||||
transformSubmodule.currentPosition = transformSubmodule.originalPosition + transformSubmodule.positionOffset;
|
||||
transform.localPosition = transformSubmodule.currentPosition;
|
||||
transformSubmodule.positionDirtyMark = false;
|
||||
willRefresh = true;
|
||||
transformSubmodule.positionOffset.Clear();
|
||||
transformSubmodule.positionOffset = Vector3.zero;
|
||||
}
|
||||
|
||||
if (willRefresh)
|
||||
|
||||
Reference in New Issue
Block a user