Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Mar 23, 2012 at 03:47 PM by Graham-Dunnett for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Herve_Simard · Mar 23, 2012 at 03:34 PM · prefabspawnunity3.5

Help: script that worked don't work with Unity 3.5

Hello everyone,

I need help with a spawnscript I made that worked earlie,r but with the recent updates on Unity, it does not seems to work.

Here's the script:

using UnityEngine; using System.Collections;

public class SpawnScript : MonoBehaviour { public int AmountEnemyInWave; public float SpawnCountdown = 1.0f; public GameObject[] spawnPoints; public GameObject[] enemy;

 private float SpawnTimer;
 private int CurrentEnemyNumber = 0;
 private bool hasFinished = false;
 
 void Start()
 {
     SpawnTimer = 0.0f;
 }
 
 void SpawnEnemy()
 {    
     if(!hasFinished)
     {    
         SpawnTimer += Time.deltaTime;
         
         // Debug.Log("SpawnTimer value " + SpawnTimer);
         // Debug.Log("SpawnCountdown value " + SpawnCountdown);
         // Debug.Log("SpawnTimer value >= SpawnCountdown value : " + (SpawnTimer >= SpawnCountdown));
             
         if(SpawnTimer >= SpawnCountdown)
         {
             // Debug.Log ("Hi darling");
             
             Debug.Log(enemy[0]);
             Debug.Log(spawnPoints[0]);
             
             Instantiate(enemy[0], (spawnPoints[0].transform.position), (spawnPoints[0].transform.rotation));
             CurrentEnemyNumber += 1;
             SpawnTimer = 0.0f;
         }
     }
 }
 
 void Update() 
 {
     SpawnEnemy();
     
     if(CurrentEnemyNumber >= AmountEnemyInWave)
     {
         // Debug.Log("CurrentEnemyNumber >= AmountEnemyInWave : " + (CurrentEnemyNumber >= AmountEnemyInWave));
         
         hasFinished = true;
     }
 }

}

Notice that all the Debug.Log are in comments, but I can attest that they work. I've seen them all print their message at the console screen.

In the enemy array, I put a prefab of my enemy. It's important to take this into account because the main problem is that Unity seems to detect the spawn thing (since the debug.log // Debug.Log("CurrentEnemyNumber >= AmountEnemyInWave : " + (CurrentEnemyNumber >= AmountEnemyInWave)); does show in console) But no physical enemy appears.

Any clues, someone? This is a major issue for me. Thanks a lot!

Comment
Comments Locked · Show 1
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 Herve_Simard · Mar 23, 2012 at 03:35 PM 0
Share

Problem has been solved, it was external to the script. Thank you for ignoring this question. :)

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Spawn a prefab 1 Answer

Setting Position of Spawned Prefab 2 Answers

Check if with a spawned gameobject 1 Answer

Randomly spawn the same object with different properties consistently. 2 Answers

Communicating between objects in the same prefab? 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