- Home /
Simple Script getting Errors.
Hello there :) I'm getting an error on the simplest of scripts that I cannot seem to fix :(
Here is the script :
private var ray : Ray;
private var rayCastHit : RaycastHit;
function Update()
{
if(Input.GetMouseButton(0))
{
ray = Camera.main.ScreenPointToRay (Input.mousePostion);
if (Physics.Raycast (ray, rayCastHit))
{
transform.position.x = rayCastHit.point.x;
}
}
}
I am getting this error :
NullReferenceException: Object reference not set to an instance of an object Paddle.Update () (at Assets/PongScripts/Paddle.js:8)
If anyone can tell me how to fix this that would be awesome ! :D
Comment
Have you checked Line 8 of Paddle.js? As you have had no mention of it here.