Working EyeTracking with moving Hitpoint
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using GhostSystem;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
public class EyeTrackingCollisionPoints : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float rayDistance = 1.0f;
|
||||
|
||||
[SerializeField]
|
||||
private LayerMask layersToInclude;
|
||||
|
||||
public GameObject hitPointPrefab;
|
||||
|
||||
private GameObject hitPoint;
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
RaycastHit hit;
|
||||
|
||||
Vector3 rayCastDirection = transform.TransformDirection(Vector3.forward) * rayDistance;
|
||||
|
||||
if ( hitPoint != null && Physics.Raycast(transform.position, rayCastDirection, out hit, rayDistance, layersToInclude))
|
||||
{
|
||||
hitPoint.transform.position = new Vector3(hit.point.x, hit.point.y, hit.point.z);
|
||||
}
|
||||
}
|
||||
|
||||
public Transform SpawnHitPoint() // Wird durch LocalPlayerReferences aufgerufen, um nicht zu oft den GhostRecorder zu suchen.
|
||||
{
|
||||
hitPoint = Instantiate(hitPointPrefab);
|
||||
return hitPoint.transform;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user