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 /
avatar image
1
Question by JasonT · Jan 02, 2011 at 02:50 AM · randomspawn

Spawn Script not working on Iphone.

So I have the script below. It works fine when i test it on my game, on my computer. But when I put it on an actual Iphone it stops spawning completely.

What I am looking for is I have 4 things that need to be spawned randomly it does not matter which one comes first. And as the time goes by for them to be spawned faster. More time more objects less time less objects. The problem once again is that it works on my computer but does not work on the Iphone. Any suggestions?

// SPAWNER // the object we want to spawn var prefabToSpawn:Transform; var prefabToSpawn1:Transform; var prefabToSpawn2:Transform; var prefabToSpawn3:Transform;

/*var redBtn:Transform; var yellowBtn:Transform; var greenBtn:Transform; var blueBtn:Transform; blueBtn.transform.position.y = 4; blueBtn.transform.position.x = -13;

var blueExplosion:Transform; */ // how long to wait between spawns var spawnTime:int ; // the amount of random time in each spawn cycle delay // the timer private var spawnTimer:int; var x:int=2; function Awake() { // initialize our timer ResetSpawnTimer(x); }

function Update(){ // count the timer down at the rate the game is updating spawnTimer -= Time.deltaTime;

// if we've hit or passed zero
if(spawnTimer == 0.0){
    // create the object from our prefab blueprint
    spawnTimer = ResetSpawnTimer(x);
    Debug.Log(spawnTimer);
    if(spawnTimer<75){
        Instantiate(prefabToSpawn, transform.position, Quaternion.identity);
    }else if (spawnTimer>76 && spawnTimer<150){
        Instantiate(prefabToSpawn1, transform.position, Quaternion.identity);
    }else if(spawnTimer>151 && spawnTimer<225){
        Instantiate(prefabToSpawn2, transform.position, Quaternion.identity);
    }else if(spawnTimer>226 && spawnTimer<300){
        Instantiate(prefabToSpawn3, transform.position, Quaternion.identity);
    }
// tell the timer to reset so we can count down again
ResetSpawnTimer(x);
}

}

function ResetSpawnTimer(x) { // initialize spawn timer with randomness spawnTimer = Random.Range(0, 300); spawntime = spawnTime + 1; return spawnTimer; }

Comment
Add comment · Show 2
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 Justin Warner · Jan 02, 2011 at 03:06 AM 0
Share

answers.unity3d.com/questions/4685/ sounds like the same problem =).

avatar image Justin Warner · Jan 02, 2011 at 03:15 AM 0
Share

http://answers.unity3d.com/questions/4685/instantiate-problem-on-the-iphone

Sorry.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Jaap Kreijkamp · Jan 02, 2011 at 05:05 AM

Try changing == to <= in (spawnTimer == 0.0)

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

No one has followed this question yet.

Related Questions

Random Spawning 1 Answer

simplified spawn script? 1 Answer

How to set up random spawnpoints? 1 Answer

Room generator spawn 1 unique room 1 Answer

How do I make a game object spawn several times in semi-random locations? 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