Search Unity

Third Party Photon spawning players with Mapbox?

Discussion in 'Multiplayer' started by dravrom1123, Apr 13, 2022.

  1. dravrom1123

    dravrom1123

    Joined:
    Jun 15, 2021
    Posts:
    1
    I'm trying to make a multiplayer game with Mapbox and Photon using Device GPS location. This is a sample code of what I'm going off of to try and spawn players in using Photon.

    public class SpawnPlayers : MonoBehaviour
    {
    public GameObject playerPrefab;

    public float minX;
    public float maxX;
    public float minY;
    public float maxY;

    private void Start()
    {
    Vector2 randomPosition = new Vector2(Random.Range(minX, maxX), Random.Range(minY, maxY));
    PhotonNetwork.Instantiate(playerPrefab.name, randomPosition, Quaternion.identity);
    }
    }

    In the code above, it's spawning players in a random X & Y position in the game. I'd like it to be able to spawn players at their current GPS location in relation to one another. I've heard about using Mapbox conversions, but I'm not certain that I understand how to use them properly. Any help would be appreciated. Thanks