Random.Range code problem or problem with Unity?
Hello, so I'm trying to have random waypoints generated with this code:
waypoint = waypoints[Random.Range(0, waypoints.Length)];
But I continously get the error '"GhostTeleport.Random()' is a 'method', which is not valid in the given context" I then tried to just generate a random number to pass through as a point in the array but I still get this error. I've tried using a simple code like this as well:
int myRandomNumber = Random.Range(0, 1);
But I still get the error. Is this a problem with my code or is there another issue at play?
Answer by Dave-Carlile · Oct 12, 2015 at 06:05 PM
This code is in a script called GhostTeleport? You must have a method in your GhostTeleport script named Random. If you do, I would suggest renaming it.
If you don't want to rename it, then you have to qualify your reference to Unity's Random class...
int myRandomNumber = UnityEngine.Random.Range(0, 1);
Your answer
Follow this Question
Related Questions
Random Scenes Without Repetition 1 Answer
Can no1 help me??? 1 Answer
How to generate a random color? 5 Answers
Need help with specifics in Random.Range 1 Answer
Random Object Spawn 0 Answers