Hi, so I basically am trying to make a spaceship dog fighting game. I have gotten ships to instantiate on all machines but I am having trouble making it so that one ship is controlled by an individual player. I used an RPC call to instantiate the ships on all machines because I was having trouble adding/modifying components to them in the code when I was using Network.Instantiate().
I have a feeling I might just be approaching this whole thing wrong, but from what I can guess I basically need to tell the machines that if I press this command, check and see if the ship was first made by the player that was inputing the command, if so then move the ship. however I am not sure of how to get this info because the data types of NetworkViewID and NetworkPlayer are different. I figure if I can sync them up I can do something about passing the value of the network player that called the RCP and just pass it into one of the scripts I have attached to the ship so I can allways know who was the player to make it and then just check against that. any help would be appreciated
Send another RPC after instantiating the player object that reads something like this (C#):
[RPC]
void SetOwner (NetworkPlayer owner)
{
if(Network.player != owner)
{
enabled = false;
GetComponent<yourPredictionScript>.enabled = true;
}
else
{
GetComponent<yourPredictionScript>.enabled = false;
}
}
This RPC method needs to be in a script attached to the player, probably in the control script, and called from the Instantiate RPC.
By the way, I personally believe working with RPCs is better than Network.Instantiate
, exactly for the reason you have much more control with RPCs.