Files
beyond/Assets/Scripts/Debug/SpawnTelepoerter.cs
2024-11-20 15:21:28 +01:00

40 lines
1011 B
C#

using System.Collections;
using System.Collections.Generic;
using RootMotion;
using UnityEngine;
namespace Beyond
{
public class SpawnTelepoerter : Singleton<SpawnTelepoerter>
{
public static SpawnTelepoerter Instance { get; private set; }
[SerializeField]
private Transform[] m_spawnPoints;
private void Awake()
{
Instance = this;
}
public void SpawnToPoint(int id)
{
if (m_spawnPoints.Length > id && id >= 0)
{
var sp = m_spawnPoints[id];
if (sp != null)
{
var player = Player.Instance.transform;
if (player)
{
player.position = sp.position;
player.rotation = sp.rotation;
return;
}
}
}
Debug.LogError("Couldn't find spawn point: " + id);
}
}
}