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;
CurrentRadius = 1000;
EndingRadius = 250;
Offset = 1;
Code for generating new circle:
// Determines maximum radius of a new circle
private _maxRadius = CurrentRadius * 0.7;
// Generates radius of the new circle
private _randomRadius = [_maxRadius * 0.6, _maxRadius] call BIS_fnc_randomNum;
// Generates new circle center
private _randomCenter = [CurrentRadius * 0.1, (CurrentRadius - _randomRadius)] call BIS_fnc_randomNum;
// Randomizes position of the new circle within the old one
FinalCenter = Center getPos [_randomCenter, random 360];
EndingRadius = _randomRadius;
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
CurrentRadius = CurrentRadius - ClosingSpeed;
// Gets the angle between two center points - in degrees
private _angle = ((FinalCenter select 1) - (Center select 1)) atan2 ((FinalCenter select 0) - (Center select 0));
if (CurrentRadius > EndingRadius) then {
// 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):