Fill Regular or irregular Shape made by 4 gameobjects with Prefabs or Primitive Types
Hello, I'm doing some bin packing problem on unity c# but i'm kinda lost right now, and i don't know where to go, i'm just trying to fill an area made by 4 Points with Primitive type Objects (it could be prefabs though) And i see every adaptation of it on Youtube, googled a lot, and i dind't find anything. gonna attach some photos of what i have do until this day Photo of what is working
Active Code :
void fillthearea() { Vector3 Retangle; Retangle = EndPoint - StartPoint; float width = Retangle.x / radius; float height = Retangle.z / radius; Vector2 d = new Vector2(0.5f, 1); if (width < 0) { width = -width; d.x = -1; } if (height < 0) { height = -height; d.y = -1; } for (int x = 0; x < width; x++) { for (int z = 0; z < height; z++) { float px = StartPoint.x + (x * radius * d.x); float pz = StartPoint.z + (z * radius * d.y); Instantiate(pepe, new Vector3(px, 0, pz), pepe.transform.rotation); } } itsreadytospawn = false; }
Your answer
Follow this Question
Related Questions
Anyone wanna help? 0 Answers
How to have audio play once picked item up? 0 Answers
How do you create a game compatible or friendly for the oculus rift? 0 Answers
How to write better AI code? 0 Answers
2 idle poses? 1 Answer