Quantcast
Channel: Recent Discussions — Photon Engine
Viewing all articles
Browse latest Browse all 15755

An annoyance With PhotonNetwork.Destroy()

$
0
0
Hey Guys! I am trying to find a way to fix my Issue. I do not know why but for some stupid reason Photon Decided to not add a time parameter to PhotonNetwork.Destroy So I have to find a way around delayed destruction; I am trying to make a gun that shoots (Which is simple enough) but not in Photon..

Here is my code so far..
[code]using UnityEngine;
using System.Collections;

public class Attack : MonoBehaviour
{

public GameObject Bullet_Emitter;

public float Bullet_Forward_Force;


void Start()
{

}


float maxTimer = 1;
float maxReloadTimer = 5;
float timer = 0;
float reloadTimer;
float intervealTimer;
float maxIntervealTimer = 2;
int shotsTaken = 0;
bool timerIsOn = false;
bool reloadFase = false;
bool Shoot = false;

void Update()
{
intervealTimer -= Time.deltaTime;
if (reloadFase)
reloadTimer -= Time.deltaTime;

if (timerIsOn)
timer -= Time.deltaTime;

if (Input.GetKeyDown(KeyCode.Mouse0))
{
if (!reloadFase)
{
shotsTaken++;
timer = maxTimer;
timerIsOn = true;
Debug.Log("Shots" + shotsTaken);
Debug.Log("Timer" + timer);
Shoot = true;
}
else
{
Debug.Log("ReloadFase On");
Debug.Log("Reload Timer" + reloadTimer);
}
}

if (shotsTaken == 3)
{
reloadTimer = maxReloadTimer;
reloadFase = true;
shotsTaken = 0;
}

if (reloadTimer < 0 && reloadFase == true)
{
reloadFase = false;
reloadTimer = 0;
}

if (Shoot && intervealTimer < 0)
{

GameObject Temporary_Bullet_Handler;
Temporary_Bullet_Handler = PhotonNetwork.Instantiate("projectile", Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation, 0) as GameObject;
intervealTimer = maxIntervealTimer;
Shoot = false;
}

if (timer < 0 && timerIsOn == true)
{
PhotonNetwork.Destroy();
timerIsOn = false;
timer = 0;
}
}
}

[/code]
My problem is on line 80, as you can see I cannot get Temporary_Bullet_Handler.. this would be much more simpler if Photon added the delay feature. What the script is in short:
The player can shoot in 3 bursts (shotsTaken) once shotsTaken is true, reloadFase turns true which turns on the reload timer, reloading it. The timer is how long it takes to destroy the bullet, and timerIsOn is just double checking that the timer is on. I have no real way of despawning the bullet with a delay (Well of to my knowledge) Please Help!

Viewing all articles
Browse latest Browse all 15755

Trending Articles