- Home /
Question by
K_Legacy · Apr 07, 2017 at 03:00 PM ·
unity 5networkinginstantiatemultiplayer
Make object show on client side in multiplayer
My issue is that I have a paintball multiplayer game, When I spawn a ball both players can see it but only the host can see the splats. Both ink1 and bullet are prefabs.
[Command]
public void CmdFire()
{
// Create the Bullet from the Bullet Prefab
var bullet = (GameObject)Instantiate (
bulletPrefab,
bulletSpawn.position,
bulletSpawn.rotation);
bullets.Add (bullet);
// Add velocity to the bullet
bullet.GetComponent<Rigidbody>().velocity = bullet.transform.forward * 12;
NetworkServer.Spawn (bullet);
// Destroy the bullet after 200 seconds
Destroy(bullet, 200.0f);
}
[Command]
public void CmdcreateSplat(int i){
int r = Random.Range (1, 7);
Debug.Log (r);
var bullet = bullets[i];
var splatter = (GameObject)Instantiate (
ink1,
bullet.transform.position,
bullet.transform.rotation);
NetworkServer.Spawn (splatter);
bullet.GetComponent<Bullet> ().destroy ();
bullets.RemoveAt (i);
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612114901im_/https://answers.unity.com/themes/thub/images/avi.jpg)