Camera.main.transform.eulerAngles

everytime i add → Camera.main.transform.eulerAngles to my script , i always get a NullReferenceException

please help :l

Read the docs about what Camera.main does.

–Eric

Correct me if I’m wrong but camera.main references to the camera component of the camera gameobject, which does not contain a transform component. You might try GameObject.FindWithTag(“MainCamera”) instead

You are wrong steel arm :slight_smile:
The camera component or any component to be accurate has a transform property etc (see Script Reference on the Component class)

the reason this fails potentially is cause

  1. No camera was tagged as main camera
  2. you try to call it at a point where the scene is not fully instantiated (don’t try it before start and don’t do it with scripts that execute in edit mode unless the camera does so too).

ok i think i understand now , im pretry sure theres no camera taged as main camera , cause it was working b4

, Any tips on taging a camera? :>

That’s what camera.main already does.

Come on, you can figure that out. It’s not hard. :slight_smile:

–Eric

rofl , took me a 30 minutes but i found it xD

sorry for my suckyness , im more of an artist and i just need a place to render my models xD