- Home /
 
 
               Question by 
               Pawky · Mar 27, 2019 at 09:33 AM · 
                rigidbodynetworkinginstantiate  
              
 
              Can't Spawn Rigidbody over network with NetworkServer.Spawn();
 [Command]
 void Shoot()
 {
     Rigidbody bulletCreate;
     fireRate = playerTime + fireTime;
     bulletCreate = Instantiate(Bullet, BulletSpawn.position, BulletSpawn.rotation) as Rigidbody;
     bulletCreate.AddForce(BulletSpawn.forward * (BulletSpeed / 10f));
     fireRate = fireRate - playerTime;
     playerTime = 0f;
     NetworkServer.Spawn(bulletCreate);
 }
 
               }
Getting the can't convert rigidbody to game object error.
Thank you for the help.
               Comment
              
 
               
              Answer by dargonknight · Mar 27, 2019 at 11:12 AM
@Pawky the issue here is that you're bulletCreate is a Rigidbody and not a game object while the function you're using is made for game objects I would suggest doing the following:
  [Command]
  void Shoot()
  {
      GameObject bulletCreate;
      fireRate = playerTime + fireTime;
      bulletCreate = Instantiate(Bullet, BulletSpawn.position, BulletSpawn.rotation);
      bulletCreate.GetComponent<Rigidbody>().AddForce(BulletSpawn.forward * (BulletSpeed / 10f));
      fireRate = fireRate - playerTime;
      playerTime = 0f;
      NetworkServer.Spawn(bulletCreate);
  }
 
              Your answer