Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Use of unassigned local variable 'Random'

I made an spawner in Unity but I got some errors:

error CS0165: Use of unassigned local variable ‘Random’

error CS1061: ‘float’ does not contain a definition for ‘Range’ and no accessible extension method ‘Range’ accepting a first argument of type ‘float’ could be found

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

all these error’s says that this line of code:

float Random = Random.Range(0,100) / 100;

doesn’t work.

Why these errors appeard?
How to repair it?

>Solution :

I can’t comment so I will post my assumption here

You named float Random witch is a class

Try naming it rnd like this:

 float rnd = Random.Range(0f, 1f);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading