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 nicktheuma · Sep 14, 2012 at 08:25 PM · randomspawngenerateblocks

How do you make a spawner block?

To be more specific, I would like to make a block which will spawn other pre-defined blocks within a certain radius, and I would like to apply limits to what radius certain blocks can spawn..For example, like in minecraft, diamonds only spawn from levels 5 till 15, I would like to do something similar for the blocks which will spawn around the central spawner block. Any help will be appreciated :) Thanks in advance!

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

1 Reply

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

Answer by dorpeleg · Sep 16, 2012 at 02:05 PM

  • the following code is written in C#.

  • this code wasn't tested.

  • this code is not complete or perfect. you might need to work on it a bit.

  • this code should be on your spawner block.

  • you should drag the block prefabs into their right locations in the inspector.

  • the code will only spawn one block. you will have to make it spawn more on your own

       public GameObject DirtBlock,StoneBlock,DiamondBlock;
    
         private Vector3 Position;
    
         public float RndMin,RndMax;
     
         void Start() {
    
             RndMin = this.transform.position.y - 10.0f; //the closest location to the spawner blcok
    
             RndMax = this.transform.position.y - 70.0f; //the farthest location from the spawner block
    
             position = new Vector3(0, Random.Range(RndMin, RndMax),0);
    
             Instantiate (DiamondBlock, position, Quaternion.identity);
    
         } 
    
Comment
Add comment · Show 4 · 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 nicktheuma · Sep 16, 2012 at 03:07 PM 0
Share

thanks! Ill try my best..not very good with code..

avatar image nicktheuma · Sep 16, 2012 at 03:09 PM 0
Share

is it possible to give me the same thing in javascript please?

avatar image dorpeleg · Sep 16, 2012 at 03:19 PM 0
Share

sorry im not to familiar with js. go here: http://docs.unity3d.com/Documentation/ScriptReference/index.html just look st some of the codes in their js format. shouldn't be hard to change.

avatar image nicktheuma · Sep 18, 2012 at 03:46 PM 0
Share

thanks very much!

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

10 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

Related Questions

Generate new blocks to land on 1 Answer

Choosing given numbers randomly 1 Answer

How to generate random pickup items on EasyRoads3D? 2 Answers

Generating objects randomly, only one will Instantiate 0 Answers

How to make levels spawn randomly? 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