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 /
  • Help Room /
This question was closed Feb 21, 2018 at 01:33 AM by jodyruben for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by jodyruben · Nov 25, 2016 at 04:11 AM · random.rangerandomize

Randoming in a Randomed variable

Hi! Got a new problem. I got several int, which is already randomed. example:

int one = Random.Range(0, 5); int two = Random.Range(6, 10); int three = Random.Range(11, 15);

Now , what i need is the int one two three randomed once again. in my project is got more variable but i think this enough for describing what i am confused about.

Edit: Sorry for haven't make this clear. What i want to do is an example :

the variable above already done randomed, the one = 3; the two = 8; the three = 13;

now i want to randoming between the 3, 8 and 13. for an example a new variable called Final only can get 3,8 and 13. sorry for bad explanation , english not my main languange thou. thanks for any help !

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

  • Sort: 
avatar image
2
Best Answer

Answer by dacarrera · Nov 25, 2016 at 11:15 AM

To randomize again, you'll want to create a function for randomizing your variables. Right now when your script is executed, Random.Range(0,5) runs and assigns a value to one. This only happens once. A workaround for this is to create a function for creating a random int and call it whenever you need your variables to be randomized.

 // Randomize a declared variable
 
 public void newRandomInt(){
     one = Random.Range(0,5);
     two = Random.Range(6,10);
     three = Random.Range(11,15);
 }

Now, whenever you want your variables to be randomized again, just call newRandomInt(); to reassign the values.

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 jodyruben · Nov 28, 2016 at 02:04 AM 0
Share

i'm sorry i think i didn't make my question pretty clear. english not my main languange thou. so what i want is like we rando$$anonymous$$g again between one two and three. for an example, one got values at 3, two got values at 7 and three got values at 13 after rando$$anonymous$$g. now i only want rando$$anonymous$$g from 3,7, or 13 to show up.

Follow this Question

Answers Answers and Comments

79 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

Related Questions

Random.Range code problem or problem with Unity? 1 Answer

how to load random / shuffle scene without repeating current scene? (when button next level pressed) 0 Answers

Random platform Generator 1 Answer

Random Scenes Without Repetition 1 Answer

one default and 2 random answers. 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