mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-10 12:39:53 +00:00
SmartSmoothDamp for rotation
This commit is contained in:
parent
adad302ba0
commit
b0e15fb557
@ -137,7 +137,7 @@ namespace QSB.Syncs.Sectored.Rigidbodies
|
||||
if (UseInterpolation)
|
||||
{
|
||||
positionToSet = SmartSmoothDamp(AttachedObject.GetPosition(), targetPos);
|
||||
rotationToSet = QuaternionHelper.SmoothDamp(AttachedObject.GetRotation(), targetRot, ref _rotationSmoothVelocity, SmoothTime);
|
||||
rotationToSet = SmartSmoothDamp(AttachedObject.GetRotation(), targetRot);
|
||||
}
|
||||
|
||||
var hasMoved = CustomHasMoved(
|
||||
|
@ -86,7 +86,7 @@ namespace QSB.Syncs.Sectored.Transforms
|
||||
if (UseInterpolation)
|
||||
{
|
||||
AttachedObject.localPosition = SmartSmoothDamp(AttachedObject.localPosition, targetPos);
|
||||
AttachedObject.localRotation = QuaternionHelper.SmoothDamp(AttachedObject.localRotation, targetRot, ref _rotationSmoothVelocity, SmoothTime);
|
||||
AttachedObject.localRotation = SmartSmoothDamp(AttachedObject.localRotation, targetRot);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -104,8 +104,8 @@ namespace QSB.Syncs
|
||||
protected virtual float DistanceLeeway { get; } = 5f;
|
||||
private float _previousDistance;
|
||||
protected const float SmoothTime = 0.1f;
|
||||
protected Vector3 _positionSmoothVelocity;
|
||||
protected Quaternion _rotationSmoothVelocity;
|
||||
private Vector3 _positionSmoothVelocity;
|
||||
private Quaternion _rotationSmoothVelocity;
|
||||
protected bool _isInitialized;
|
||||
|
||||
protected abstract T SetAttachedObject();
|
||||
@ -246,6 +246,11 @@ namespace QSB.Syncs
|
||||
return Vector3.SmoothDamp(currentPosition, targetPosition, ref _positionSmoothVelocity, SmoothTime);
|
||||
}
|
||||
|
||||
protected Quaternion SmartSmoothDamp(Quaternion currentRotation, Quaternion targetRotation)
|
||||
{
|
||||
return QuaternionHelper.SmoothDamp(currentRotation, targetRotation, ref _rotationSmoothVelocity, SmoothTime);
|
||||
}
|
||||
|
||||
public void SetReferenceTransform(Transform referenceTransform)
|
||||
{
|
||||
if (ReferenceTransform == referenceTransform)
|
||||
|
@ -106,7 +106,7 @@ namespace QSB.Syncs.Unsectored.Rigidbodies
|
||||
if (UseInterpolation)
|
||||
{
|
||||
positionToSet = SmartSmoothDamp(AttachedObject.GetPosition(), targetPos);
|
||||
rotationToSet = QuaternionHelper.SmoothDamp(AttachedObject.GetRotation(), targetRot, ref _rotationSmoothVelocity, SmoothTime);
|
||||
rotationToSet = SmartSmoothDamp(AttachedObject.GetRotation(), targetRot);
|
||||
}
|
||||
|
||||
var hasMoved = CustomHasMoved(
|
||||
|
@ -60,7 +60,7 @@ namespace QSB.Syncs.Unsectored.Transforms
|
||||
if (UseInterpolation)
|
||||
{
|
||||
AttachedObject.position = SmartSmoothDamp(AttachedObject.position, targetPos);
|
||||
AttachedObject.rotation = QuaternionHelper.SmoothDamp(AttachedObject.rotation, targetRot, ref _rotationSmoothVelocity, SmoothTime);
|
||||
AttachedObject.rotation = SmartSmoothDamp(AttachedObject.rotation, targetRot);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user