SWS-Smarta / project /Assets /Scripts /Game /DinoSpawnManager.cs
alfapro's picture
Clean deploy: Code only for SWS
defab59
Raw History Blame Contribute Delete
735 Bytes
using UnityEngine;
public class DinoSpawnManager : MonoBehaviour
{
public static DinoSpawnManager Instance { get; private set; }
public Transform[] spawnPoints;
public float laneWidth = 2f;
public float defaultZ = 0f;
public float defaultY = 0.5f;
void Awake()
{
Instance = this;
}
public Vector3 GetSpawnPosition(int playerId)
{
if (spawnPoints != null && spawnPoints.Length > 0)
{
Transform t = spawnPoints[Mathf.Abs(playerId) % spawnPoints.Length];
if (t != null) return t.position;
}
int lane = (playerId % 3) - 1; // -1, 0, 1
float x = lane * laneWidth;
return new Vector3(x, defaultY, defaultZ);
}
}