Skip to content

Commit 37d5092

Browse files
committed
Combine accuracy fixes, mitigated rotate NAN issue
1 parent 25d6009 commit 37d5092

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

Assets/SlimTween/Scripts/TweenClasses.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,13 @@ void ISlimTween.UpdateTransform()
732732
}
733733
else
734734
{
735-
float weight = 0.5f; // You can adjust this value based on your requirements
735+
//float weight = 1f; // You can adjust this value based on your requirements
736736
// Calculate weighted average of the positions
737-
Vector3 weightedAverage = interp.from * (1 - weight) + transform.position * weight;
738-
interp.SetFrom(Vector3.Lerp(interp.from, Vector3.Lerp(weightedAverage, interp.to, tick), tick));
737+
//Vector3 weightedAverage = interp.from * (1 - weight) + transform.position * weight;
738+
//interp.SetFrom(Vector3.Lerp(interp.from, Vector3.Lerp(weightedAverage, interp.to, tick), tick));
739+
var a = Vector3.LerpUnclamped(interp.from, transform.position, tick);
740+
var b = Vector3.LerpUnclamped(interp.previousPos, a, tick);
741+
interp.SetFrom(b);
739742
}
740743
}
741744
else if (type == TransformType.Scale)
@@ -858,17 +861,10 @@ void LerpRotateAround(float value)
858861
var localto = interp.to.normalized;
859862
transform.rotation = Quaternion.Euler(localto * interp.angle * value);
860863
}
861-
Vector3 tmp;
862864
void LerpRotateAroundLocal(float value)
863865
{
864-
if (tmp == Vector3.zero)
865-
{
866-
tmp = transform.position;
867-
}
868-
Vector3 pivotOffset = tmp - interp.from;
869-
Quaternion rotation = Quaternion.AngleAxis(interp.angle * value, interp.to);
870-
Vector3 rotatedOffset = rotation * pivotOffset;
871-
transform.position = transform.TransformPoint(interp.from) + rotatedOffset;
866+
var localto = transform.InverseTransformDirection(interp.to).normalized;
867+
transform.localRotation = Quaternion.Euler(localto * interp.angle * value);
872868
}
873869

874870
/// <summary>Rotates based on target point.</summary>

0 commit comments

Comments
 (0)