Here is the code for my Fireball. The fireball prefab has a Network View and this script attached to it. The fireball will be destroyed fine after its lifetimer expires however if it collides with something before it dies from the timer It will not destroy immediatley and will destroy with an error when its lifetimer expires.
Error: Could’nt perform remote Network.Destroy because the netwrok view 'ID here" could not be located.
using UnityEngine;
using System.Collections;
public class Fireball : MonoBehaviour {
private float moveSpeed = 15f;
private Transform myTransform;
private float lifespan = 10f;
private int damage;
private PlayerScript PS;
void Awake()
{
myTransform = transform;
}
// Use this for initialization
void Start () {
damage = -21;
}
// Update is called once per frame
void Update () {
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
lifespan -= Time.deltaTime;
if(lifespan < 0)
{
Network.Destroy(this.gameObject);
}
}
void OnTriggerEnter(Collider other)
{
//PS = other.gameObject.GetComponent<PlayerScript>();
//PS.AdjustCurHealth(damage);
Network.Destroy(this.gameObject);
}
}