Hey guys! I am using this timer script that I have used many times and have worked, but for some reason it is not working now… Please help!
void Update()
{
bool TimerTrue = false;
float timer = 1;
if (TimerTrue)
timer -= Time.deltaTime;
if (Input.GetKeyDown(KeyCode.Mouse0))
{
GameObject Temporary_Bullet_Handler;
Temporary_Bullet_Handler = PhotonNetwork.Instantiate("projectile", Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation, 0) as GameObject;
Temporary_Bullet_Handler.GetComponent<BulletAttributes>().Owner = this.gameObject;
TimerTrue = true;
Rigidbody Temporary_RigidBody;
Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent<Rigidbody>();
Temporary_RigidBody.AddForce(transform.forward * Bullet_Forward_Force);
if (timer < 0)
{
PhotonNetwork.Destroy(Temporary_Bullet_Handler);
TimerTrue = false;
}
}
}
The bullet successfully shoots but never despawns, I would do Destroy(Temporary_Bullet_Handler, 1.0f); but I am doing multiplayer and Photon does not have that feature for some reason