using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using VRTK;
|
|
|
|
public class RingBezierPointer : VRTK_BezierPointerRenderer
|
|
{
|
|
|
|
#region Read-Only Fields
|
|
/// <summary>
|
|
/// Direction from Centre of ship to CameraRig
|
|
/// </summary>
|
|
public Vector3 DownDirection => m_ring.getDownDirection(transform.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<RotationController>();
|
|
}
|
|
|
|
|
|
protected override Vector3 ProjectDownBeam(Vector3 jointPosition)
|
|
{
|
|
Vector3 downPosition = Vector3.zero;
|
|
Ray projectedBeamDownRaycast = new Ray(jointPosition, DownDirection);
|
|
RaycastHit collidedWith;
|
|
|
|
bool downRayHit = VRTK_CustomRaycast.Raycast(customRaycast, projectedBeamDownRaycast, out collidedWith, defaultIgnoreLayer, maximumLength.y);
|
|
|
|
if (!downRayHit || (destinationHit.collider && destinationHit.collider != collidedWith.collider))
|
|
{
|
|
if (destinationHit.collider != null)
|
|
{
|
|
PointerExit(destinationHit);
|
|
}
|
|
destinationHit = new RaycastHit();
|
|
downPosition = projectedBeamDownRaycast.GetPoint(0f);
|
|
}
|
|
|
|
if (downRayHit)
|
|
{
|
|
downPosition = projectedBeamDownRaycast.GetPoint(collidedWith.distance);
|
|
PointerEnter(collidedWith);
|
|
destinationHit = collidedWith;
|
|
}
|
|
return downPosition;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|