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
0
Question by Daniel Girgis · Jan 28, 2011 at 06:05 AM · enemyspawndelay

delay first spawn

When I play the enemys spawn instantly from each spawnpoint then go to there normal delay time and i need a way to get rid of the first enemy spawned maybe a delay or a way to delete it.

Thankyou

var Enemy : GameObject; var DelayMin = 5.0; var DelayMax = 20.0;

 function Start () {
     SpawnRoutine();

}

 function SpawnRoutine () {
     while(true) {
     Instantiate (Enemy, transform.position, transform.rotation);
     yield WaitForSeconds(Random.Range(DelayMin, DelayMax)); 
 }

}

Comment
Add comment · 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 Jessy · Jan 28, 2011 at 06:52 AM 0
Share

Do what $$anonymous$$yth said, but Start itself can be a coroutine; you can get rid of SpawnRoutine if you like.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Myth · Jan 28, 2011 at 06:09 AM

not sure on the functionality s of yield but shouldn't it go before the instantiate?

Comment
Add comment · Show 3 · 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 Jessy · Jan 28, 2011 at 06:50 AM 0
Share

For not being knowledgeable about them, you sure do know exactly what the problem is. ;-)

avatar image Myth · Jan 29, 2011 at 01:01 AM 0
Share

I am a nerd by nature - and it just looked out of place!

avatar image Daniel Girgis · Jan 31, 2011 at 08:10 AM 0
Share

true i didn't take much notice to that but it worked.

avatar image
0

Answer by Phil 5 · Jan 28, 2011 at 02:09 PM

I would go with something like:

var Enemy : GameObject; var DelayMin = 5.0; var DelayMax = 20.0; var TimeLeft = 50.0; //initial delay here

function Update() { TimeLeft -= Time.deltaTime; if (TimeLeft <= 0.0) { Instantiate (Enemy, transform.position, transform.rotation); TimeLeft = Random.Range(DelayMin, DelayMax)); } }

Hope it helps.

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 Daniel Girgis · Jan 31, 2011 at 07:21 AM 0
Share

thats excellent thankyou is there any chance u could help me with possibly making the time left a random number aswell my game involves enemies spawning randomly around you thankyou

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

Problem with the enemy 0 Answers

Trying out a unique method of spawning enemies. Someone want to help sort out the logic of it? 1 Answer

enemy wave spawn script wont work 0 Answers

Spawning Objects at location 3 Answers

Shoot Bullet Delay Enemy 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