Salut tout le monde

j'essaye d'envoyer un projectile avec mon perso dès que mon joueur lance l'animation de tire j'ai cette erreur

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
MissingReferenceException: The object of type 'Rigidbody' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.

voila le code du prefabe projectile

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public int LazerDammage = 50 ;
 
 
void Start () {
		Destroy (gameObject,10);
 
	}
 
 
	public void OnCollisionEnter (Collision Col){
 
		if (Col.gameObject.name == "Monster") {
			Col.gameObject.GetComponent<SciptAI> ().ApplyDammage (LazerDammage);
 
	}
		Destroy (gameObject);
 
	}


voila la fonction de dégât subis par ce lancer

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
	public void ApplyDammage ( float LazerDammage){
 
		if (!IsDead) {
			Anim.Play ("TheDamage");
			HPM = HPM - 50f;
			if (HPM <= 0) {
 
				Dead ();
			}
 
		}
	}
et la coroutine d'instanciation du perso

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
	IEnumerator Feu(){
 
		Rigidbody Instance ;
		Instance  = Instantiate (Arm, Fire.transform.position, Fire.transform.rotation) as Rigidbody;
		yield return new WaitForSeconds (0.5f);
		Instance .AddForce (Fire.transform.forward * SpeedFire);
 
 
	}