Projectile in online multiplayer

Hi everybody, I'm developing a simple shooter online game with unity. I developed first a single player demo in which player move into the scene and can fire projectile. Now I'm trying to make an online demo of the same game. I'll use a non-authoritative server created with Unity. When server and client is connected a player prefab is instantiated in the scene and it works.

Now I have a question, which is the best way to manage projectile? Projectile, in my singple-p game are instances of a little sphere. In the online mode I have to create a sphere prefab to instantiate for each player and make projectiles instances of it or it is better to create a unique sphere and make players' projectiles instances of this unique sphere?

Obviously I'm going to manage projectile collision with other players and game object scene adding special effect (for now I'm using detonetor) when a collision is detected.

Thank you!

Hi,

One way you could go about it is to send an RPC call to trigger a function to eject the projectile locally.

 GUI.Button(Rect(10,10,100,100),Fire)){
Fire();
network.RPC("SendFire",viewID");
}

@RPC
function SendFire(viewId : NetworkViewID){
print("sending fire");
}

then on the client side you have the same function like this

@RPC
function SendFire(viewID : NetworkViewID)
{
 var BulletClone : GameObject = Instantiate(BulletPrefab,transform.position,transform.rotation);
}

You cant copy and paste my code It wont work, you will have to look into RPC calls. But that is what I am using on my project and it works well. you will have to have some kind of even handler game object with a network view on it that sends out the functions to the game object like, Gun.BroadcastMessage("Fire");

I hope that helps, look at the RPC Details page in the help files for more info on how to use it.