namespace Zinnia.Tracking.Follow.Modifier.Property.Rotation
{
using UnityEngine;
///
/// Updates the transform rotation of the target to match the source.
///
public class TransformRotation : SmoothedRestrictableTransformPropertyModifier
{
///
/// Modifies the target rotation to match the given source rotation.
///
/// The source to utilize in the modification.
/// The target to modify.
/// The offset of the target against the source when modifying.
protected override void DoModify(GameObject source, GameObject target, GameObject offset = null)
{
SaveOriginalPropertyValue(target.transform.eulerAngles);
Quaternion targetRotation = offset == null ? source.transform.rotation : source.transform.rotation * Quaternion.Inverse(offset.transform.localRotation);
target.transform.rotation = Smooth(target.transform.rotation, targetRotation);
if (HasAxisRestrictions)
{
target.transform.rotation = Quaternion.Euler(RestrictPropertyValue(target.transform.eulerAngles));
}
}
}
}