SimFlight

Category: Objects / Movement
Since engine version: 4.9.5.0 CE

Description

Simulates the motion of a falling object with a given starting position and initial speed. If the projected trajectory encounters a material of the specified density, the simulation will stop and the function will return 'true'. Otherwise the function will return 'false'.
If the return value is 'true', the x and y coordinates of the point of interception will be stored in the specified variables for iX and iY, the horizontal and vertical speed at the time of interception in iXDir and iYDir respectively. See references for details.

Syntax

bool SimFlight (int &iX, int &iY, int &iXDir, int &iYDir, int iMinDensity, int iMaxDensity, int iIteration, int iPrecision);

Parameters

iX:
X coordinate of the starting position. Always global.
iY:
Y coordinate of the starting position. Always global.
iXDir:
Initial horizontal speed.
iYDir:
Initial vertical speed.
iMinDensity:
[opt] Mininum density of the material which will stop the projected trajectory. If not specified or 0 this will default to value 50 (solid material).
iMaxDensity:
[opt] Maximum density of the material which will stop the projected trajectory. If not specified or 0 this will default to value 100 (Vehicle).
iIteration:
[opt] Number of simulated frames for which the projection runs. If not specified or 0 the simultion will run indefinitely until material or the limits of the landscape are encountered.
iPrecision:
[opt] Precision. Default 10 if not specified or 0.

Example

var iX = GetX(), iY = GetY(), iXDir = GetXDir(), iYDir = GetYDir();
if (GetAction()eq"Jump")
  if (SimFlight(iX, iY, iXDir, iYDir))
    if (iYDir >= 80)
      Message("Oh oh, das wird ein harter Aufprall!", this());
If the calling clonk is situated in mid-air and it appears that he will hit the ground at high speed, he will call out.
Newton, März 2004