Files
RoomAwareVR/Assets/_Scripts/Utility/LocalPlayerReference.cs
T
2025-10-02 00:07:11 +02:00

50 lines
1.3 KiB
C#

using GhostSystem;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
// Zur unterscheideung des localen Player-Rigs von adneren aus dem Multiplayer. Aktuell nicht in Benutzung.
public class LocalPlayerReference : NetworkBehaviour
{
public static LocalPlayerReference Instance { get; private set; }
public List<Transform> myObjects;
public EyeTrackingCollisionPoints collisionPoints;
public static event Action OnPlayerReady;
public override void OnNetworkSpawn()
{
if (IsOwner)
{
Instance = this;
Debug.Log("[LocalPlayerReference] Lokaler Spieler registriert.");
// Optional: Liste von Transforms vorbereiten
GhostRecorderBatch ghostRecorder = FindFirstObjectByType<GhostRecorderBatch>();
if (ghostRecorder != null)
{
foreach (Transform obj in myObjects)
{
ghostRecorder.TrackedObjects.Add(obj);
}
}
ghostRecorder.TrackedObjects.Add(collisionPoints.SpawnHitPoint());
OnPlayerReady?.Invoke();
Debug.LogError("Invoked OnPlayerReady");
}
}
private void OnDestroy()
{
if (IsOwner && Instance == this)
{
Instance = null;
}
}
}