Hello all! Thanks for reading, and I am sorry that I am foolishly new to both using Unity and C# while asking this kind of question with limited knowledge of formal terminology.
I’m trying to spawn falling objects within the parameters/boundaries(I don’t know if these are the correct words) of the room I created, but I don’t know how to properly express the boundaries(sorry I know this is another term I don’t fully grasp in C#) of the area that I want things to spawn and fall within. the room(s) that I’ve created are not squares or circles, and I don’t feel comfortable throwing a bunch of collider boxes together to express the shape of the room.
Specifically I would like to know how to instantiate objects within a specific shape of the room, or any room(which is NOT a square or circle, but rather a specific shape).
I’ve tried reading as much as I could fit in my brain, and ‘feel’ that the best of two ways is either to hardcode the parameters within a general spawning script not attached to any in-game object, but rather defined mathematically, or to ‘attach?’ the code to a poly-mesh that is created using the pro-builder tool in Unity(pictures also attached). My issue is that I don’t know how to express either scenarios beyond this point and my drawing a blank.
It was suggested that I ‘Serialize’ the coordinates of the ‘poly shape’ of the room, but after looking things up, I don’t think serializing the coordinates will help me define the parameters of the area I want the random things spawned within(at least not without further explanation). After comparing my code to others, I think(and I’m not confident in typing/saying this at all) that the red-circled area is the part of the code I need to change to define the area that I want things to spawn inside of/amongs?
I went and got the exact x/y/z coordinates that define the ‘edges’ or ‘vertices?’(point at which each line that defines the outside lines of the room shape) of the area I want things to spawn in, but I don’t know if that’s the information I need. Is there indeed a way to link what I want spawned to the shape of the room, or to a script/line that defines the boundaries of the room? I am unsure if this is the most efficient(or if it’s even a possible) way to go about it, or if I am just too lacking in basic math to understand this.
I kind of get that it wants to know the shape of the room using triangles, but I’m also struggling with interpreting that properly. would anyone be able to point in me in direction of a forum, or notes that might help me figure this out? Thanks again!
TL:DR: How do I get things to spawn in ‘custom’ area?
Edit: UgaBuga Language
-Me not trying to raycast anything
-Me not trying to have my code distribute any probability, nor distribution, amongst each individual triangle that defines the entire area
-Me not understand how to break a crazy shape into triangles in 5 seconds, but if can point me to direction to understand, me will read for several months then understand.
-Me want things to fall from sky of room, only in room not outside, but me not understand how to define room in code.
-How I convert shape, or points at edges of shape, into expression that make sense within the context of code?
-Is this the wrong place to ask for help on my code?