Files
dungeons/Assets/Scripts/Features/PlayerSpawner.cs

27 lines
624 B
C#

using HurricaneVR.Framework.Core.Player;
using Sirenix.OdinInspector;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.VisualScripting;
using UnityEngine;
public class PlayerSpawner : MonoBehaviour
{
[SerializeField]
[ReadOnly]
private Transform[] spawns = new Transform[0];
private void Awake()
{
spawns = GetComponentsInChildren<Transform>()
.Where((x) => x != transform)
.ToArray();
}
public void Spawn(GameObject player)
{
player.GetComponent<HVRTeleporter>().Teleport(spawns.First().position);
}
}