Okay so I’m in the middle of building an open world multiplayer car game, you can see it here.
So what I’m wanting to achieve is in my scene, having a vehicle selector, that can change the vehicle on the spot, and that every other player can see.
The closest thing I found to what I want is in BeamNG.drive, if you watch until about 0:40 you can see what I want to achieve.
This is my script so far
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class ChangeCar : NetworkBehaviour {
public GameObject[] vehicles;
[SerializeField]
private GameObject currentVehicle;
void Start()
{
currentVehicle = GetComponent<GameObject>();
}
public void ChangeVehicle(int vehicle)
{
if (isLocalPlayer)
{
Network.Instantiate((vehicles[vehicle]), transform.position, transform.rotation, 0);
Destroy(currentVehicle);
}
}
}