- Home /
script error help
i have this script :
var velocita : float = 100;
var danno : float = 0;
var target : Transform;
private var posiY : float;
function Start () {
posiY = transform.position.y;
transform.rotation.x = 0;
yield WaitForSeconds (3);
Destroy(gameObject);
}
function Update () {
transform.position.y = posiY;
transform.position += transform.forward * velocita * Time.deltaTime;
}
function OnCollisionEnter(col : Collision) {
if(col.gameObject.tag == "enemy"){
col.gameObject.GetComponent(MyNavMesh).armatura -= danno;
}
Destroy(gameObject);
}
but i have this error on playing game :
NullReferenceException: Object reference not set to an instance of an object proiettile.OnCollisionEnter (UnityEngine.Collision col) (at Assets/script/proiettile.js:23)
how can i fix it? sorry for horrible english, i'm italian (y)
This would fail if the "enemy" game object did not have a '$$anonymous$$yNav$$anonymous$$esh' component on it.
Have you checked the game object for having the '$$anonymous$$yNav$$anonymous$$esh' component you have made attached?
Did the object being collided with have the '$$anonymous$$yNav$$anonymous$$esh' attached to it?
Sorry, not sure I understand what you mean.
Your answer
Follow this Question
Related Questions
Unity Gui lable problem with showing js var using C# 2 Answers
script error 1 Answer
send message object variable 1 Answer
How do I change the text of a gui image text 1 Answer
Cant acces function in other script 2 Answers