Pawky
March 27, 2019, 9:33am
1
[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.
@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);
}