- Home /
Question by
Ragequit0605 · Feb 21, 2017 at 04:43 AM ·
networkingnetwork.instantiate
Unity 5 Networking prefab spawning not making child a local player.
#pragma strict
import UnityEngine.Networking;
class Queue extends NetworkBehaviour
{
var Car : GameObject;
var queueing : boolean;
var timer : GameObject;
var manager : GameObject;
function Start ()
{
ClientScene.RegisterPrefab(Car);
timer = GameObject.Find("GlobalTimer");
manager = GameObject.Find("NetworkManager");
}
function Update ()
{
ClientScene.RegisterPrefab(Car);
if(Input.GetKeyDown(KeyCode.F2))
{
queueing = !queueing;
Debug.Log(queueing);
}
if(queueing == true && timer.GetComponent(RaceTimer).starting == true)
{
var c = Instantiate(Car);
NetworkServer.Spawn(c);
Destroy(gameObject);
}
}
}
This is my script for spawning the vehicle and while it actually spawns, the vehicle detects that it's not a "local player" whereas spawning it first without being spawned by this script turns "local player" true. I have searched for countless hours for a solution but I haven't got anywhere.
Comment
Your answer
Follow this Question
Related Questions
Networking. How can I instantiate a different prefab in client and the server? 1 Answer
Network.Instantiate Problem. AI not behaving the same on all clients. 1 Answer
SpawnWithCLientAuthority Issues... 0 Answers
OnNetworkInstantiate is never called 1 Answer
Randomize the position of the player 2 Answers