- Home /
NullReferenceException
Hello. I got an error
firepoint.Update () (at Assets/firepoint.js:5) My firepoint.js: var FirePoint1 : GameObject;NullReferenceException: Object reference not set to an instance of an object
function Update () { FirePoint1.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width/2, Screen.height/2, Camera.main.nearClipPlane) ); } Please, help! Any help would be aprecciated
Answer by Nick4 · Mar 07, 2014 at 11:27 AM
You don't need to change your camera's tag. It's probably because you have 2 cameras in the scene and you are not using your main camera when this script runs.
Answer by haim96 · Mar 07, 2014 at 11:13 AM
did you drag the game object to the correct place in the editor? you need to assign a model to FirePoint1.
Yep, i`m dragged. I`m already fix it with setting tag "$$anonymous$$ainCamera" to main camera :)
Your answer
Follow this Question
Related Questions
NULL REFERENCE EXCEPTION,NULL REFERENCE EXCEPTION while accessing child objects unity2D 0 Answers
Find transform.position of Another Game Object 1 Answer
Need help updating camera position to go above the player 2 Answers
Camera to follow a target within a circle? 1 Answer
Gameobject to stay within the view of the camera - c# 3 Answers