Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing error message #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cesarchamorro
Copy link

This fix error message "Object reference not set to an instance of an object", it used to happen when player re spawn.
The problem is most likely that Camera.main is not initialized (this commonly happens).

This fix error message "Object reference not set to an instance of an object", it used to happen when player re spawn.
The problem is most likely that Camera.main is not initialized (this commonly happens).
@@ -6,9 +6,11 @@ public class CameraFacingBillboard : MonoBehaviour {
// Update is called once per frame
void Update () {
Camera cam = Camera.main;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing so in every frame is not really a good way to do it. defining private camera inside the class and referencing Camera.main to it on Awake or on Start would be a nicer way to do . Also, the if statement is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants