• 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 /
avatar image
0
Question by DualOnGames · 6 days ago · vrscene-loading

Problem loading the main level scene from the main menu

I honestly don't know what is wrong, when I load the main game scene from the main menu scene, it is very broken, shaders don't work, and one of the scripts seems to not work either.

The script is supposed to spawn sections of the level, but doesn't do anything.

The game scene works fine when I enter play mode on it.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
 public class MapGenerator : MonoBehaviour{
     // Start is called before the first frame update
 
     public GameObject fpiece;
     public GameObject apiece;
     public GameObject spiece;
     public Vector3 spos;
     public float rate;
     public int dirRate;
     public Quaternion dir;
     public int i;
     public float speed;
     public int spawnTimer;
     public int spawnTimer2;
     public float timer;
     public GameObject rightCon;
     public GameObject leftCon;
     public float totalVelocity;
 
     void Start(){
         StartCoroutine("generator");
         StartCoroutine("genObst");
         StartCoroutine("genObst2");
     }
 
     void Update(){
         rate = 1;
         timer = 30;
         totalVelocity = Mathf.Abs(rightCon.GetComponent<ControllerVelocity>().velocity.magnitude) + Mathf.Abs(leftCon.GetComponent<ControllerVelocity>().velocity.magnitude);
         speed = (0-totalVelocity) / 8;
         rate /= (0-speed) * 15;
         timer /= (0-speed) * 500;
         if(timer > 30){
             timer = 30;
         }
         if(rate > 1){
             rate = 1;
         }
     }
 
     IEnumerator generator (){
         print("what");
         while(true){
             if(totalVelocity < -0.01f){
             for(i =0; i < dirRate; i++){
             Instantiate(fpiece, spos, transform.rotation);
             spawnTimer ++;
             spawnTimer2 ++;
             yield return new WaitForSeconds(rate);
             }
             if(Random.Range(0,2) == 0){
                 for(int c = Random.Range(4, 30); c > 0; c--){
                     transform.Rotate(0, Random.Range(1, 2), 0);
                     Instantiate(fpiece, spos, transform.rotation);
                     spawnTimer ++;
                     spawnTimer2 ++;
                     yield return new WaitForSeconds(rate);
                 }
             }else if(Random.Range(0,2) == 1){
                 for(int c = Random.Range(4, 30); c > 0; c--){
                     transform.Rotate(0, Random.Range(-1, -2), 0);
                     Instantiate(fpiece, spos, transform.rotation);
                     spawnTimer ++;
                     spawnTimer2 ++;
                     yield return new WaitForSeconds(rate);
                 }
             }
             yield return new WaitForSeconds(0.01f);
             i = 0;
             }
             yield return new WaitForSeconds(0.01f);
     }
 }
 
     IEnumerator genObst (){
         while(true){
             int t = Random.Range(1, 10);
             while(spawnTimer < t){
                 yield return new WaitForSeconds(0.01f);
             }
             Instantiate(apiece, spos, transform.rotation);
             spawnTimer = 0;
         }
     }
     IEnumerator genObst2 (){
         while(true){
             int t = Random.Range(1, 10);
             while(spawnTimer2 < t){
                 yield return new WaitForSeconds(0.01f);
             }
             Instantiate(spiece, spos, transform.rotation);
             spawnTimer2 = 0;
         }
     }
 
 }

Comment
Add comment · Show 3
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 DualOnGames · 6 days ago 0
Share

Update - I noticed that the script doesn't work at all, even when I start on it. I'm even more confused, It was after I added another spawning coroutine that it stopped. Actually the whole thing is broken, even when I revert the code.

avatar image logicandchaos DualOnGames · 6 days ago 0
Share

maybe if you show your code someone can help.

avatar image DualOnGames logicandchaos · 6 days ago 0
Share

Yeah, Probably

0 Replies

· Add your reply
  • Sort: 

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

206 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 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

Unity Oculus VR: objects that are held when reloading the scene can not be picked up in the next scene 0 Answers

[VR] VIVE controller press to load scene 0 Answers

How to save position of stereo vrcameras 0 Answers

how to translate normal 3d project to VR? 1 Answer

Oculus Quest scene transition 0 Answers


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