# Moving and shrinking circle to a circle inside of it (PUBG like zone)

I am trying to create a battle royale circle gamemode within Arma3 that would work like in PUBG.

For anyone who doesn't know how it looks like:

Red circle should smoothly shrink into the blue one (that means sides that close to each other should move very slowly by adjusting speed of the red circle center)

Global variables:

Center = (getMarkerPos "marker_start"); // eg. [1000, 1000]
ClosingSpeed = 0.5;
Offset = 1;


Code for generating new circle:

// Determines maximum radius of a new circle
// Generates radius of the new circle
// Generates new circle center
// Randomizes position of the new circle within the old one
FinalCenter = Center getPos [_randomCenter, random 360];
ClosingSpeed = ClosingSpeed / 2;
// This number should be somehow calculated to make the closing circle animation work properly
Offset = 0.75;


Shrinking code, executed every 100 ms:

// Decreases radius
// Gets the angle between two center points - in degrees
private _angle = ((FinalCenter select 1) - (Center select 1)) atan2 ((FinalCenter select 0) - (Center select 0));
// This sets new position of the circle
Center set [0, (Center select 0) + ((Offset * ClosingSpeed) * cos (_angle))];
Center set [1, (Center select 1) + ((Offset * ClosingSpeed) * sin (_angle))];
};


Without the correct Offset it shrinks like this - center points (red circle center was moving at a wrong velocity):

This could be solved using a parametric equation.

P' = P + (t * D)

Where: P is the starting position of the outer circle. P' is the current position of the circle. t is (elapsed time / time it takes to shrink the circle) D is a vector from P to the center of the inner circle. Note: do not normalize this vector.

If t > 1, the circle has finished moving, so use that to trigger the next circle.

This will smoothly interpolate the position of the center and guarantee it ends where you want it.

• Hello, could you please show an example in pseudo code? I have trouble understanding your explanation. Commented Jul 16, 2020 at 16:56
• I had a mistake in my code, your solutions works. Thank you very much kind sir. Commented Jul 16, 2020 at 17:23
• Glad it worked and thanks for the vote. I may add a drawing to this answer later and some formulas. Commented Jul 16, 2020 at 23:56