Question by
_EP24_ · May 14, 2016 at 01:02 PM ·
javascripterrorscore
NullReferenceException: Object reference not set to an instance of an object ?
#pragma strict
import UnityEngine.UI;
import System;
import System.IO;
public class PlayerBorder extends MonoBehaviour {
public var player: ePlayer;
public var score : ScoreUI;
function OnCollisionEnter(col : Collision) {
var ball : Ball = col.gameObject.GetComponent.<Ball>();
if (ball != null){
ball.transform.position = new Vector3(0.0, 1.0, 0.0);
if (player == ePlayer.Right){
score.scorePlayerLeft = score.scorePlayerLeft+1;
}
else if (player == ePlayer.Left){
score.scorePlayerRight = score.scorePlayerRight+ 1;
}
}
}
}
i have this problem can anyone explain how to fix it? it always happen when somebody score....
NullReferenceException: Object reference not set to an instance of an object PlayerBorder.OnCollisionEnter (UnityEngine.Collision col) (at Assets/PlayerBorder.js:19)
Comment
You probably didn't assign the score variable. If that's a monobehavior you can just drag and drop in the inspector. If it's not that it would help if you showed us the ScoreUI script.
Your answer
Follow this Question
Related Questions
Trying to get animation to work. Problem with JS. 1 Answer
Javascript Script for Object Follow? 0 Answers
Function Update not working 1 Answer
Script error, cannot fix whatsoever! 1 Answer
How do I fix the following error? 1 Answer