Home > Enterprise >  Use of unassigned local variable 'Random'
Use of unassigned local variable 'Random'

Time:02-02

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

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?

CodePudding user response:

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);
  •  Tags:  
  • Related