- Home /
A cubes most positive and negative x values
Hello, im creating a 3D snake game and I'm trying a new way to spawn the food on the game area. Until now I had borders and I instantiated the food in a random range between those 2 borders. I want to build a little bit more complicated levels now that have areas that are not just a square and i was wondering if i could set the area in which the food spawns in another way. What i tried is creating a cube which would be used as the floor and im trying to get a random x and z value on the cube. I thought maybe there was a way to get the most positive x and the most negative x of the cube and use those two for the random range. Is there a way to do this? Or do you have me a much simpler way to achieve what i want?
You could try $$anonymous$$esh.bounds (local bounds) or Renderer.bounds (global bounds)
http://docs.unity3d.com/ScriptReference/$$anonymous$$esh-bounds.html
http://docs.unity3d.com/ScriptReference/Renderer-bounds.html
Answer by YoungDeveloper · Apr 16, 2015 at 09:33 PM
You could build a grid and for each level define which chunks can be used and which are busy.
Your answer

Follow this Question
Related Questions
How to get the width of a cube in "coordinate units" 1 Answer
How can I scale an object with keyinput and return old scale when I do not press like Mario crunch 1 Answer
scale to vector3 point 1 Answer
Make an object rotate instantly upon an event occuring in C# 1 Answer
instantiating a cube so a side is parallel with a Vector 1 Answer