40 lines
1011 B
C#
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);
|
|
}
|
|
}
|
|
}
|