• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by SAclovet · Aug 15, 2017 at 01:20 PM · cameragame development

Game is saying "No Cameras Rendering". (Heavily based on the 2D Basic Dungeon Generation tutorial on youtube)

I'm trying to make a roguelike game for my school project. I tried to follow this tutorial: https://youtu.be/wnoLaui3uO4 This is my first time using Unity but I have a bit of experience with C#. My problem is that every time I play my scene, I get a "No cameras rendering" error on my game window. But sometimes, when I just keep clicking the play button, it works. What can I do to resolve this?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by flagrama · Sep 02, 2017 at 06:40 PM

I think the issue is this bit of code

 if (i == rooms.Length * .5f)
 {
     Vector3 playerPos = new Vector3(rooms[i].xPos, rooms[i].yPos, 0);
     Instantiate(player, playerPos, Quaternion.identity);
 }

As this checks that i is equivalent to half of the rooms being generated. On an even number this works fine, 10 / 2 = 5 so room 5 is where the player is placed. However, when done when there is an odd number of rooms this condition is never met because 5 / 2 = 2.5 and there is no room 2.5. Something like that. This means that approximately half the time your player is never instantiated.

I'm using this code now and haven't seen any issues since

 private bool playerPlaced = false;

 if (i >= rooms.Length * .5f && !playerPlaced)
 {
     Vector3 playerPos = new Vector3(rooms[i].xPos, rooms[i].yPos, 0);
     Instantiate(player, playerPos, Quaternion.identity);
     playerPlaced = true;
 }

You should also be able to round the rooms.Length * .5f and have it work as well though I haven't tried this one. It might still be possible for two different values to be returned, one that rounds up and one that rounds down, which could cause issues still.

 if (i == Mathf.RoundToInt(rooms.Length * .5f))
 {
     Vector3 playerPos = new Vector3(rooms[i].xPos, rooms[i].yPos, 0);
     Instantiate(player, playerPos, Quaternion.identity);
 }

Always a good idea to keep in mind you should never use == when dealing with floating point values and should use >= or <= instead or round the value to the nearest integer. It's not an uncommon mistake when writing code on the spot though.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SAclovet · Sep 06, 2017 at 03:54 PM 0
Share

Yeah this was definitely my problem. Thanks a bunch!

avatar image
0

Answer by sunderplugs11 · Aug 15, 2017 at 01:43 PM

that means your camera isnt active. Idk why your camera isnt active, but its not.

if you have a Player, make sure his camera is turned on or add one to him

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SAclovet · Aug 16, 2017 at 03:50 AM 0
Share

I think my camera is active? Here's what my scene looks like. I just put the Player prefab on the scene just so I can show the $$anonymous$$ain Camera inspector, I remove it when I play the scene. alt text

Edit: I think I have a problem with my loader? When I watched the tutorial, he made the new loader game object on the scene but he did it in pause mode. So when he unpaused, the loader disappeared. Is the new loader object even relevant?

unitymaincamera.png (65.1 kB)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

147 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Play a game on a screen within game 0 Answers

Camera Unet Problem 0 Answers

CRT Shader how optimize?! 1 Answer

Rendering a Canvas as Screen Space - Camera - Google Cardboard 0 Answers

My character walks slower when looking down? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges