Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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 Demigoth · Mar 23, 2014 at 02:02 AM · restartrestart game

Full scene restart

Hey guys, so I got this small game I am working on and I am using PoolManager, I am not getting any errors but when I use my restart button using this code...

 using UnityEngine;
 using System.Collections;
 
 public class FullRestart : MonoBehaviour 
 {
     void OnClick()
     {
         Application.LoadLevel ("Level_1");
     }
 }

I am not getting it to again start the enemies to spawn, they don't spawn ever again and I am not getting any error. The code for my spawning enemies is this and its set to false until I press a button in game...

 using UnityEngine;
 using System.Collections;
 using PathologicalGames;
 
 public class EnemySpawning : MonoBehaviour 
 {
     public float spawnTime = 3.0f;
     float timeLeft = 0.0f;
     public static bool isSpawning = false;
     
     public Transform español = null;
         
     void Update () 
     {
         if (isSpawning != false)
         {
             timeLeft -= Time.deltaTime;
             if (timeLeft <= 0.0f) 
             {
                 Transform t = PoolManager.Pools["Enemy"].Spawn(español, transform.position, Quaternion.identity);
                 
                 timeLeft = spawnTime;
             }
         }
         
     }
 }

So if you guys ever faced a problem like this please I would love to get some help, thank you all in advance!

Comment
Add comment · Show 8
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 Benproductions1 · Mar 23, 2014 at 02:20 AM 0
Share

Do you have any objects marked as "DontDestroyOnLoad"?

avatar image Demigoth · Mar 23, 2014 at 02:22 AM 0
Share

None... I am not using the DontDestroyOnLoad method anywhere!

avatar image supernat · Mar 23, 2014 at 02:43 AM 0
Share

static variables won't be re-initialized on scene change. Where do you set isSpawning? $$anonymous$$aybe check for any other static variables that impact isSpawning.

avatar image Demigoth · Mar 23, 2014 at 02:57 AM 0
Share

Yeah I restart all the static variables on the void Start() but still the spawning is not occurring from the pool, and I see the pool being created and the units instantiated!

avatar image Sildaekar · Mar 23, 2014 at 02:03 PM 0
Share

Can you show how you are re-initializing the static variables?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by iriegusto · Mar 03, 2021 at 02:00 AM

I had the same problem, and this simple code insert fixed it for me:

  public void Awake()
     {
         Time.timeScale = 1;
     }

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

26 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

Related Questions

How do I make Game Over text stay enabled for a few seconds before the Application Load function runs? 1 Answer

Creating a Restart Button 3 Answers

Simple Restart not working 0 Answers

My game keeps restarting at random 1 Answer

scene won't reset after restart 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