Helper Scripts Collection 1.3.1
API documentation for the helper scripts compatible with Unity3D
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
NikosAssets.Helpers.RandomPointsHelper Class Reference

A helper class to determine random points in the 3D space More...

Public Member Functions

virtual Vector3 GetRandomPointInSphere ()
 Get a random point inside a unit sphere multiplied by and within bounds of minMaxDistance More...
 
virtual Vector3 GetRandomPointInSphereArea (Transform target)
 Get a random point inside a limited sphere area based on minAngleFromLookDir, maxAngleFromLookDir, minMaxDistance and shiftAngleClockwise for the given target s position and orientation More...
 
virtual Vector3 GetRandomPointOnStraightLine (Vector3 originPoint, Vector3 normalizedLookDirection)
 Get a random Vector3 point on a straight line based on the originPoint and the normalizedLookDirection multiplied by and in bounds of minMaxDistance More...
 

Static Public Member Functions

static Vector3 GetRandomPointOnStraightLine (Vector3 originPoint, Vector3 normalizedLookDirection, float minDist, float maxDist)
 Get a random Vector3 point on a straight line based on the originPoint and the normalizedLookDirection multiplied by and in bounds of minDist and maxDist More...
 
static Vector3 GetRandomPointInSphereArea (Vector3 position, Vector3 localUp, Vector3 localFwd, float minAngle, float maxAngle, float minDist, float maxDist, float shiftAngleClock)
 Get a random point inside a limited sphere area based on the given params for the given position and local orientations. Look into the non-static GetRandomPointInSphereArea(UnityEngine.Transform) method to understand the required params of this method. More...
 
static Vector3 GetRandomUnitPointInSphereArea (float minAngle=0, float maxAngle=180)
 Spawn a random point inside a unit sphere without any position or orientation context More...
 
static Vector3 GetClosestPointOnSurface (Vector3 airPoint, Vector3 shootDir, float maxDist=50, params string[] layerMasks)
 Try to get the closest point on a surface with the accepted layerMasks based on the starting airPoint , the shootDir and the maxDist More...
 
static Vector3 GetRandomPointOnSurface (Vector3 airPoint, Vector3 offsetAirPoint, Vector3 shootDir, float maxDist=50, params string[] layerMasks)
 
static Vector3 GetClosestPointOnNavmesh (Vector3 pointSomewhere, float searchRadiusOfPoint=5, int navMeshArea=-1)
 

Public Attributes

Vector2 minMaxDistance = new Vector2(1, 2)
 The random distance is generated based on the minimum (x) and maximum (y) float value (both inclusive)
 
float minAngleFromLookDir = 0
 Used in the GetRandomPointInSphereArea(UnityEngine.Transform) method to determine the minimum spawn angle from the Transform's look dir
 
float maxAngleFromLookDir = 180
 Used in the GetRandomPointInSphereArea(UnityEngine.Transform) method to determine the maximum spawn angle from the Transform's look dir
 
float shiftAngleClockwise = 0
 Used in the GetRandomPointInSphereArea(UnityEngine.Transform) method to shift the spawn point relative to the Transform clockwise
 

Detailed Description

A helper class to determine random points in the 3D space

Member Function Documentation

◆ GetClosestPointOnSurface()

static Vector3 NikosAssets.Helpers.RandomPointsHelper.GetClosestPointOnSurface ( Vector3  airPoint,
Vector3  shootDir,
float  maxDist = 50,
params string[]  layerMasks 
)
static

Try to get the closest point on a surface with the accepted layerMasks based on the starting airPoint , the shootDir and the maxDist

Parameters
airPointThe floating starting point
shootDirTry to hit a surface based on this dir
maxDistHow far shoot we shoot?
layerMasksWhat colliders are accepted?
Returns
If no surface found, the airPoint , otherwise a surface hit Vector3 point

◆ GetRandomPointInSphere()

virtual Vector3 NikosAssets.Helpers.RandomPointsHelper.GetRandomPointInSphere ( )
virtual

Get a random point inside a unit sphere multiplied by and within bounds of minMaxDistance

Returns
A random Vector3 point

◆ GetRandomPointInSphereArea() [1/2]

virtual Vector3 NikosAssets.Helpers.RandomPointsHelper.GetRandomPointInSphereArea ( Transform  target)
virtual

Get a random point inside a limited sphere area based on minAngleFromLookDir, maxAngleFromLookDir, minMaxDistance and shiftAngleClockwise for the given target s position and orientation

Parameters
target
Returns
A random Vector3 point

◆ GetRandomPointInSphereArea() [2/2]

static Vector3 NikosAssets.Helpers.RandomPointsHelper.GetRandomPointInSphereArea ( Vector3  position,
Vector3  localUp,
Vector3  localFwd,
float  minAngle,
float  maxAngle,
float  minDist,
float  maxDist,
float  shiftAngleClock 
)
static

Get a random point inside a limited sphere area based on the given params for the given position and local orientations. Look into the non-static GetRandomPointInSphereArea(UnityEngine.Transform) method to understand the required params of this method.

Parameters
positionThe starting position
localUpThe targets normalized local up vector
localFwdThe targets normalized local fwd vector
minAngleThe minimum spawn-point angle of the imaginary sphere
maxAngleThe maximum spawn-point angle of the imaginary sphere
minDistThe minimum spawn distance radius
maxDistThe maximum spawn distance radius
shiftAngleClockShift the spawn point clockwise
Returns
A random Vector3 point

◆ GetRandomPointOnStraightLine() [1/2]

virtual Vector3 NikosAssets.Helpers.RandomPointsHelper.GetRandomPointOnStraightLine ( Vector3  originPoint,
Vector3  normalizedLookDirection 
)
virtual

Get a random Vector3 point on a straight line based on the originPoint and the normalizedLookDirection multiplied by and in bounds of minMaxDistance

Parameters
originPoint
normalizedLookDirection
Returns
A random Vector3 point

◆ GetRandomPointOnStraightLine() [2/2]

static Vector3 NikosAssets.Helpers.RandomPointsHelper.GetRandomPointOnStraightLine ( Vector3  originPoint,
Vector3  normalizedLookDirection,
float  minDist,
float  maxDist 
)
static

Get a random Vector3 point on a straight line based on the originPoint and the normalizedLookDirection multiplied by and in bounds of minDist and maxDist

Parameters
originPoint
normalizedLookDirection
minDist
maxDist
Returns
A random Vector3 point

◆ GetRandomUnitPointInSphereArea()

static Vector3 NikosAssets.Helpers.RandomPointsHelper.GetRandomUnitPointInSphereArea ( float  minAngle = 0,
float  maxAngle = 180 
)
static

Spawn a random point inside a unit sphere without any position or orientation context

Parameters
minAngle
maxAngle
Returns
A random Vector3 point without context