fix floater FINALLY

This commit is contained in:
Lillith Rose 2026-02-21 16:24:16 -05:00
parent 452faae79a
commit 084c5eab2f
2 changed files with 37 additions and 48 deletions

View file

@ -5,7 +5,8 @@ using gay.lilyy.aacshared.runtimecomponents;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
namespace gay.lilyy.aacshared.layers { namespace gay.lilyy.aacshared.layers
{
[InitializeOnLoad] [InitializeOnLoad]
public class Floater : LayerGroup public class Floater : LayerGroup
{ {
@ -14,7 +15,7 @@ namespace gay.lilyy.aacshared.layers {
public override bool shouldWarnIfNotApplicable => false; public override bool shouldWarnIfNotApplicable => false;
private static readonly Floater _instance = new(); private static readonly Floater _instance = new();
static Floater() {} static Floater() { }
public override string DisplayName => "Floater"; public override string DisplayName => "Floater";
public override string SystemName => "floater"; public override string SystemName => "floater";
@ -54,52 +55,39 @@ namespace gay.lilyy.aacshared.layers {
.Easing(multiDef.Definition.loopInSeconds, t.transform.localPosition.y); .Easing(multiDef.Definition.loopInSeconds, t.transform.localPosition.y);
}); });
} }
if (multiDef.Definition.spinCycles > 0) if (multiDef.Definition.spinCycles > 0)
{ {
string axis = multiDef.Definition.spinAxis.ToLower(); string axis = multiDef.Definition.spinAxis.ToLower();
string prop = $"m_LocalEulerAngles.{axis}"; string prop = $"m_LocalEulerAnglesRaw.{axis}";
float segment = multiDef.Definition.loopInSeconds / multiDef.Definition.spinCycles; float duration = multiDef.Definition.loopInSeconds;
float totalRotation = 360f * multiDef.Definition.spinCycles;
for (int cycle = 0; cycle < multiDef.Definition.spinCycles; cycle++) action.Animates(t, prop).WithSecondsUnit(unit =>
{ {
action.Animates(t, prop).WithSecondsUnit(unit => unit
{ .Linear(0f, 0f)
float baseAngle = 0f; // ignore quaternion components entirely .Linear(duration, totalRotation);
float startTime = cycle * segment; });
float endTime = (cycle + 1) * segment;
float startAngle = baseAngle + 360f * cycle; // Lock the other axes
float endAngle = baseAngle + 360f * (cycle + 1); foreach (var other in new[] { "x", "y", "z" })
{
if (other == axis) continue;
Logger.LogDebug($"Floater system: Animating {t.name} {prop} on cycle {cycle} from {startAngle} to {endAngle} between {startTime}s and {endTime}s"); float current =
unit other == "x" ? t.transform.localEulerAngles.x :
.Linear(startTime, startAngle) other == "y" ? t.transform.localEulerAngles.y :
.Linear(endTime, endAngle); t.transform.localEulerAngles.z;
Logger.LogDebug($"unit.Linear({startTime}, {startAngle}).Linear({endTime}, {endAngle})"); action.Animates(t, $"m_LocalEulerAnglesRaw.{other}")
}); .WithSecondsUnit(unit =>
} {
unit
// Fill OTHER Euler axes with constant values .Linear(0f, current)
foreach (var other in new[] { "x", "y", "z" }) .Linear(duration, current);
{ });
if (other == axis) continue; }
float current = }
other == "x" ? t.transform.localEulerAngles.x :
other == "y" ? t.transform.localEulerAngles.y :
t.transform.localEulerAngles.z;
Logger.LogDebug($"Floater system: Setting constant {t.name} {other} to {current}");
action.Animates(t, $"m_LocalEulerAngles.{other}")
.WithSecondsUnit(unit =>
{
unit
.Linear(0f, current)
.Linear(multiDef.Definition.loopInSeconds, current);
});
}
}
} }
}).Looping()); }).Looping());
@ -140,7 +128,8 @@ namespace gay.lilyy.aacshared.layers {
Definition = def, Definition = def,
Transforms = new List<Transform>() Transforms = new List<Transform>()
}; };
} else }
else
{ {
Logger.LogInfo($"Floater system: Adding additional transform to definition '{def.name}'"); Logger.LogInfo($"Floater system: Adding additional transform to definition '{def.name}'");
} }

View file

@ -11,7 +11,7 @@ namespace gay.lilyy.aacshared.runtimecomponents
void Start(){} void Start(){}
public float floatHeight = 0; public float floatHeight = 0;
[Tooltip("Time in seconds for one full spin cycle")] [Tooltip("Time in seconds for one full spin cycle")]
public float loopInSeconds = 10f; public float loopInSeconds = 60f;
[Tooltip("Number of times object spins in one loop")] [Tooltip("Number of times object spins in one loop")]
public int spinCycles = 2; public int spinCycles = 2;
[Tooltip("Axis to spin around (x, y, or z)")] [Tooltip("Axis to spin around (x, y, or z)")]