Implement player spawning in predefined location in lobby and levels
This commit is contained in:
26
Assets/Scripts/Features/PlayerSpawner.cs
Normal file
26
Assets/Scripts/Features/PlayerSpawner.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user