Question by
NicolasRobles · Oct 05, 2016 at 09:42 PM ·
null reference exception
NullReferenceException: Object reference not set to an instance of an object
using UnityEngine; using System.Collections; public class MoverPrueba : MonoBehaviour {
Vector3 pos = new Vector3();
float x;
float y;
float z;
public GameObject basura;
void Start () {
pos.x = 9.9f;
pos.y = -91f;
pos.z = -60f;
}
void Update () {
pos.x = Input.mousePosition.x;
}
void OnMouseDrag() {
transform.position = Camera.main.ScreenToWorldPoint (pos);
}
},using UnityEngine; using System.Collections;
public class MoverPrueba : MonoBehaviour {
Vector3 pos = new Vector3();
float x;
float y;
float z;
public GameObject basura;
void Start () {
pos.x = 9.9f;
pos.y = -91f;
pos.z = -60f;
}
void Update () {
pos.x = Input.mousePosition.x;
}
void OnMouseDrag() {
transform.position = Camera.main.ScreenToWorldPoint (pos);
}
}
Comment
On what line is the error occurring? What do you want to do with the scripts? Are there public variables that you have to set in the inspector?
Your answer
Follow this Question
Related Questions
null reference Exception object reference not set i did not understand the prob. please help me 1 Answer
Unity3d Script does not work anymore 1 Answer
[SOLVED] NullReferenceException in a script that calls another object's script variable 1 Answer
NullReferenceException when attempting to call a GameObject from within PointerEventData 1 Answer
Why do I keep getting a null reference? Its not null! 0 Answers