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 Nathan Bennett · Sep 11, 2010 at 10:35 AM · randomspawnpoints

how to freeze a random position?

hello. i know how to create a random position, but i don't know how to freeze my spawn point, to that random position, while it Instantiate's some enemies to play with. here's my script:

private var randStop = 0; private var enemy_Spawned = 0; var enemy_Prefab : GameObject; private var numberOfWaves = 0;

//Variable to do with enemy fuction var point1: Transform; private var point1_Check : boolean = false;

function enemy() { //three different spawn points on spawning area

  if(!point1_Check) 
  {
      Instantiate(enemy_Prefab, transform.position, Quaternion.identity);
      enemy_Spawned ++;
      point1_Check = true;
  }

}

function Update () {

//setup for spawn point random position, and stop. if(randStop == 0) { transform.position.x = Random.Range(-55, 48); randStop = 1; }

//load enemy fucntion, when spawnpoint has stoped if (randStop == 1) { enemy(); }

//when there are three spawned enemies, random the spawnpoint again if(enemy_Spawned == 1) { randStop = 0; numberOfWaves ++; }

if (numberOfWaves == 3) { randStop = 3; }

}

if it's too complicated to read, i'm basically, setting a rand_Stop varible, and using if statement's when the variable is at a particular value. so when it's at 0, it generate a new radom spawnpoint, and sets it to 1, when set to 1, 1 enemy_Prefab will be instantiated. then i set another varible to something simular, when there are X amount of enemies spawned, turned rand_Stop to 0 again and add 1 to NumberOfWaves, where, finally, at the 3 number of waves, rand_Stop will be set to 3, where the loop will be broken.

the only problem is, is that all it does, is create one enemy, and kepp setting a random position for my spawnpoint. what do i do?

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 Jesse Anders · Sep 11, 2010 at 12:19 PM 0
Share

The code is a little convoluted, but as for why only one enemy is being spawned, it looks like it's because an enemy is only spawned when 'point1_Check' is false, but in the block of code that spawns the enemy, you set 'point1_Check' to true (meaning that no more enemies will be spawned).

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Nathan Bennett · Sep 12, 2010 at 06:46 AM

i have redone this script 5 times now, to make it as easy as i could. what i need is a Random.Seed number, which i don't know how to set, and don't know what to set it to. (i'm trying System.DateTime.Now.Ticks)

looks like more G.O.o.g.l.e for me

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

Multiple spawn points without spawning in the same place. 2 Answers

Quaternion.identity problem at random spawn 1 Answer

multiple object in multiple spawn Point with out repeat 0 Answers

How to set up random spawnpoints? 1 Answer

Can't figure out next step for this code ? 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