So I’m not good at all at math but I’m trying to Instantiate a prefab in a half circle
eg. Spawning randomly on the X axis in 180 degrees eg. the top half of a circle
I have no idea how to do it other than using Sin/Cos but I don’t know the theory behind them or how it should look code wise so I was hoping for someone to provide the correct math or code but I would also like to understand what is actually going on
I did something similar, but with a full circle:
UnityEngine Random insideUnitCircle normalized * radius;
This will take a random position inside a circle and then normalize it (so that the distance to the center is always the same). Then multiply that random position with radius to get a circle of the size you want.
The only difference between my code and yours, is that you will have to do an extra if check. For instance:
Vector3 position;
do{ position = UnityEngine Random insideUnitCircle normalized * radius }
while(position.y > 0)