Implement player spawning in predefined location in lobby and levels

This commit is contained in:
2024-08-20 19:38:32 +02:00
parent 3f64f82464
commit 1a9e2a3ee8
23 changed files with 559 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
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);
}
}