[Question] How to use the docs. unity site

I know lecture 16 goes over it to an extent, but I still don’t know what information I am looking for or what information I need.

For example in Section 4 Lecture 52 we are asked to find out how to use Random.Range, when I looked, I was immediately confused by what I saw in the description, but the instructor didn’t seem to use anything in the description

he used Random.Range(min,max+1);

this is a screen shot of what I am talking about…

I’ll try to help if I can, not actually up to this lesson yet but here goes.
Random.Range returns a number of type float where Range returns a number of type Integer. If you look at the second example you see that they want to call a scene number, but scene numbers must be integers so you use Range instead of Random.Range.

Does that help? Just in case, a float number is a decimal number that can have an exponent in base 10, eg 15000 is 1.5 F 4, which is 1.5 times 10**4 = 1.5 * 10,000.

I hope this helps and that I haven’t made any mistakes.

I’m new to Unity (just started the course today), but not new to programming in general. I think I know what’s your confusion here.

Random.Range can be used in two ways here, and it all depends on the type of numbers what you feed to the function.
If you feed this function two float values, eg. Random.Range(0.0f, 10.0f), it returns a float value between 0 and 10.
If you feed this function two integer values, eg. Random.Range(0, 10), it returns an integer value between 0 and 9. (note the inclusive and exclusive remarks in the documentation)

I hope this helps.

1 Like

Yes sorry for the mistake - I tried this and its nice to see the flexibility for function calls

Privacy & Terms