I am getting this error message each time I touch an object on an ios platform with the remote app.
NullReferenceException: Object reference not set to an instance of an object
test-unity-5.Update () (at Assets/my-scripts/test-unity-5.js:14)
I don't know how to solve it, and don't even know why it is occurring. ( I have a general idea, but...)
My code is:
#pragma strict
private var JumpH = 8;
// Jump Hieght 8 units
private var IsFalling = false;
// Is not falling start
var particle : GameObject;
function Update ()
{
for (var touch : Touch in Input.touches) {
if (touch.phase == TouchPhase.Began) {
var ray = Camera.main.ScreenPointToRay (touch.position);
if (Physics.Raycast (ray)) {
//ad effects here
rigidbody.velocity.y = JumpH;
IsFalling = true;
}
}
}
}
I am touching a button I imported that is stacked in the camera, my player's view.
I am new to unity, so please don't be spiteful. Any help is appreciated!
↧