Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialataullahkhusaidi
243 PointsSpawnArea or SpawnArena? My MonoDevelop doesn't have SpawnArea, but instead, it has SpawnArena.
So I tried to type
float positionX = Random.Range (-spawnArea, spawnArea) ; But when I debugged the script, it said that it doesn't exist. Please help!
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey There,
I'm guessing you probably have a typo near the top of the FlySpawner.cs file where we declared the float variable.
You should have (near the top) around line 12 the line
private float spawnArea = 25f;
This is where you probably typed "arena" instead of "area".
Then your
float positionX = Random.Range(-spawnArea, spawnArea);
float positionZ = Random.Range(-spawnArea, spawnArea);
should be fine. I've done that a few times... mis-naming a variable and trying to figure why it isn't auto-completing!.
Keep Coding! :)
Cindy Lea
Courses Plus Student 6,497 PointsWhy do you have -spawnArea?
Jason Anders
Treehouse Moderator 145,860 PointsBecause that's what's needed for the code to execute properly.
We need a Random number generated in the range from the negative value of spawnArea to the positive value of spawnArea.
Once you take the course, you will see how / why these values are used.