- Home /
please help NullReferenceException object
Hi all. please help past fixed script
Error NullReferenceException UnityEngine.Transform.get_position () (at C:/BuildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/Editor/UnityEngineTransform.cs:19) PriesoAI.Update () (at Assets/skriptai/PriesoAI.cs:26)
sript
using UnityEngine; using System.Collections;
public class PriesoAI : MonoBehaviour { public Transform taikinys; public int judesiogreitis; public int rotationgreitis; private Transform myTransform;
void budrus(){ myTransform = transform;
}
// Use this for initialization void Start () { GameObject go = GameObject.FindGameObjectWithTag("Player");
taikinys = go.transform;
} // Update is called once per frame void Update () { Debug.DrawLine(taikinys.position, myTransform.position, Color.yellow); //ziureti i taikini myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(taikinys.position - myTransform.position), rotationgreitis * Time.deltaTime); } }
Answer by james flowerdew · Nov 12, 2012 at 11:08 AM
found your post with same problem, then found apparent solution. referencing the position or rotation in an undefined transform gives me the same error right now. Don't know why it comes through as such a weird error.
for some reason "go" or "taikinys " aren't found. I suspect a misspelt tag or something. or budrus isn't called perhaps? I'd use : GameObject go = (GameObject)FindGameObjectWithTag("Player"); taikinys = go.transform;
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
ERROR unity expected. insert a semicolon at the end 2 Answers
Errors with script using Javascript. 2 Answers
Script error help ? 1 Answer
NullReferenceException trouble 1 Answer