File size: 735 Bytes
defab59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
    }
}