namespace Zinnia.Tracking.Modification { using UnityEngine; using Zinnia.Cast; using Zinnia.Extension; /// /// Rotates the to look into a normal direction. /// public class PointNormalRotator : MonoBehaviour { [Tooltip("The target to apply the rotations to.")] [SerializeField] private GameObject target; /// /// The target to apply the rotations to. /// public GameObject Target { get { return target; } set { target = value; } } /// /// Clears . /// public virtual void ClearTarget() { if (!this.IsValidState()) { return; } Target = default; } /// /// Handles the provided data to rotate the . /// /// The data to take the rotation info from. public virtual void HandleData(PointsCast.EventData data) { if (!this.IsValidState() || Target == null || data.HitData == null) { return; } Target.transform.rotation = Quaternion.FromToRotation(Vector3.up, data.HitData.Value.normal); } } }