Skip to content

FindRandomMovePos()

inkoalawetrust edited this page Sep 15, 2023 · 2 revisions

FindRandomMovePos ([Vector3 RelativeTo = Null, Int Attempts = 32, Double CheckRad = 128, Int Filter = FRMP_FURTHEST])

Parameters:

  • RelativeTo: The position that the Filter should measure distance relative to. If left as (Double.NaN, Double.NaN, Double.NaN), then only the FRMP_RANDOM filter will work.
  • Attempts: How many random positions should be generated around the callers' CheckRad. Default is 32.
  • CheckRad: The radius around which random positions will be picked. Default is 128 map units.
  • Filter: What is the criteria for the random position to return ? Criteria include:
    • FRMP_FURTHEST: Return the random position that is the furthest from RelativeTo. This is the default filter.
    • FRMP_CLOSEST: Return the random position that is the closest to RelativeTo.
    • FRMP_RANDOM: Return a totally random position. As long as the caller can actually go to it.

Return type(s):

  • Returns a Vector3 that matches the criteria of the Filter.

Function:

Generates a number of random positions around the caller, filtering out the invalid ones. Then the final position out of the valid ones to be returned is determined by the Filter parameter. It's used by KAI_Wander() and KAI_MoveAway() to find positions for NPCs to move to after the current ones have been reached. Therefore this function is mostly useful if you want to make a custom movement function.

Example:

This is how KAI_MoveAway() uses the function. It picks a random position that is the furthest from the actor the NPC needs to run from. And runs there.

	NextMovePos = FindRandomMovePos (Other.Pos,Attempts,RunRad,FRMP_FURTHEST); //Pick whichever position is the furthest from Other.

See also

Clone this wiki locally