playMaker

Author Topic: Random vector within a clamped area  (Read 1236 times)

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Random vector within a clamped area
« on: May 31, 2015, 07:26:55 AM »
Hi, I have 2 questions.
1. (see attached pic) At position (A) I want to set a random position (B) inside the red semi circle.  How can I clamp the random position so only a vector inside gets picked?

2.  Whenever (B) is picked, I'll be setting that position to the new origin (A), so then I can loop through it all again.  Problem is, I have a collider set at each side of the screen, (see 2nd pic) so if the origin (A) is close to one of the walls, I need to clamp the area so the random position cannot go past the collider.

I know this involves a bit of maths, can anyone point me in the right direction?