Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Rickasheye · Mar 16, 2018 at 07:02 AM · leveldesignintegerprogress

how to make a progressive/dynamic integer

i want to make a random int in between 0 and the array length and the level number so the more higher the level the more harder the enemy is in the array or the more higher the array count is but when it reaches the max in the array length i want it to stop which i could do with

if(currentprogressionint <= enemy.length){ //stop }else{ //progression mark }

Comment
Add comment · Show 11
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 hexagonius · Mar 16, 2018 at 07:56 AM 1
Share

The if would be something like int result = Random.Range(currentProgressionInt, enemy.Length);

I think you meant stop if currentProgressionInt >= enemy.Length

avatar image Rickasheye hexagonius · Mar 16, 2018 at 07:59 AM -1
Share

@hexagonius umm i didnt want a random int i want something like the more higher level the more harder the prefab is spawned based on the array index

avatar image Harinezumi Rickasheye · Mar 16, 2018 at 08:42 AM 0
Share

If you organise your enemy array based on difficulty that's exactly what a random int will give you.
If this is not what you want, please rephrase your question and add more information.

Show more comments

3 Replies

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

Answer by Harinezumi · Mar 17, 2018 at 10:03 AM

Please update the question with more information. It is still not clear what is it exactly that you would like to achieve.
If you want to generate monsters at most the current level difficulty, then the following code will work:

 enemyIndex = Random.Range(0, Mathf.Min(currentProgressionInt + 1, enemy.Length)); // +1 needed to include currentProgressionInt as possible value
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 Rickasheye · Mar 17, 2018 at 10:57 AM 0
Share

ask it in a answer and i will accept it as it seems like it worked

avatar image
0

Answer by tormentoarmagedoom · Mar 16, 2018 at 09:49 AM

Good day.

You need to use this tools:

  1. Random.Range (To random select a number from a minimum to a maximum)

  2. Array.Lenght (Determinate the number of elements in an array)

  3. Mathf.Max (Determinate the higher number inside an array)

Using this 3 tools you should be able to determinate what you need.

 If helped, accept the answer :D


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 Rickasheye · Mar 17, 2018 at 09:04 AM 0
Share

the problem with Random.Range is that it could spawn the hardest enemy on Level 1 which is a pain

avatar image Harinezumi · Mar 17, 2018 at 10:06 AM 1
Share

Why $$anonymous$$athf.$$anonymous$$ax? If I understand it correctly, Rickasheye wants to limit from above.

avatar image Bunny83 Harinezumi · Mar 17, 2018 at 11:41 AM 0
Share

Right, he needs $$anonymous$$ath.$$anonymous$$in to avoid an index out of bounds exception.

avatar image
0

Answer by FM-Productions · Mar 17, 2018 at 10:10 AM

You could use Random.Range but you make the minimum value depending on the level. for example:

 int levelNumber = ...
 int enemyDiffculty = Random.Range(levelNumber, difficultyMax);

The levelNumber should not exceed the difficultyMax of course, and difficulty max can be your Array.Length value

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 Harinezumi · Mar 17, 2018 at 10:26 AM 0
Share

This can cause issues if levelNumber is less than difficulty$$anonymous$$ax.

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

83 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Making the floor/ground of a map 1 Answer

What is the best way to create 3D tile based levels in Unity ? 1 Answer

Collision problems with level design 1 Answer

Very weird dark level loading? 4 Answers

Level designer Méthode question 2 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