playMaker

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

Splankton

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Random vector within a clamped area
« on: May 31, 2015, 04: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?