using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VRTK;
public class RingTeleportation : VRTK_HeightAdjustTeleport
{
#region Read-Only Fields
///
/// Direction from Centre of ship to CameraRig
///
public Vector3 DownDirection => m_ring.getDownDirection(playArea.position);
#endregion Read-Only Fields
#region Inspector Fields
[Header("Ring Settings")]
[SerializeField, Tooltip("Reference to the Ship which is being teleported on. If left empty will try and find one in scene")]
private RotationController m_ring;
#endregion Inspector Fields
protected override void OnEnable()
{
base.OnEnable();
if (m_ring == null)
m_ring = FindObjectOfType();
}
protected override Vector3 GetNewPosition(Vector3 tipPosition, Transform target, bool returnOriginalPosition)
{
Vector3 basePosition = base.GetNewPosition(tipPosition, target, true);
return basePosition;
}
protected override Quaternion SetNewRotation(Quaternion? rotation)
{
Debug.Log("Setting new rotation");
return Quaternion.FromToRotation(Vector3.down, DownDirection);
}
protected override void ProcessOrientation(object sender, DestinationMarkerEventArgs e, Vector3 targetPosition, Quaternion targetRotation)
{
base.ProcessOrientation(sender, e, targetPosition, targetRotation);
Quaternion newRotation = Quaternion.FromToRotation(Vector3.down, m_ring.getDownDirection(targetPosition));
playArea.rotation = newRotation;
}
}