Class KaijuAgentsNearest
Extension methods to get the nearest object to a given position along the X and Z axes. All three-dimensional vectors will be flattened via methods in KaijuAgentsFlatten.
Inheritance
Namespace: KaijuSolutions.Agents.Extensions
Syntax
public static class KaijuAgentsNearest
Methods
Nearest(Component, IEnumerable<GameObject>, out Single)
The nearest instance to a position.
Declaration
public static GameObject Nearest(this Component position, IEnumerable<GameObject> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Component | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<GameObject> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| GameObject | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Nearest(Component, IEnumerable<Transform>, out Single)
The nearest instance to a position.
Declaration
public static Transform Nearest(this Component position, IEnumerable<Transform> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Component | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Transform> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Transform | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Nearest(Component, IEnumerable<Vector2>, out Single)
The nearest instance to a position.
Declaration
public static Vector2 Nearest(this Component position, IEnumerable<Vector2> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Component | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Vector2> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Vector2 | The nearest instance from the targets to the position. Will be the starting position if the targets list is empty. |
Nearest(Component, IEnumerable<Vector3>, out Single)
The nearest instance to a position.
Declaration
public static Vector3 Nearest(this Component position, IEnumerable<Vector3> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Component | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Vector3> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Vector3 | The nearest instance from the targets to the position. Will be the starting position if the targets list is empty. |
Nearest(GameObject, IEnumerable<GameObject>, out Single)
The nearest instance to a position.
Declaration
public static GameObject Nearest(this GameObject position, IEnumerable<GameObject> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<GameObject> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| GameObject | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Nearest(GameObject, IEnumerable<Transform>, out Single)
The nearest instance to a position.
Declaration
public static Transform Nearest(this GameObject position, IEnumerable<Transform> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Transform> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Transform | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Nearest(GameObject, IEnumerable<Vector2>, out Single)
The nearest instance to a position.
Declaration
public static Vector2 Nearest(this GameObject position, IEnumerable<Vector2> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Vector2> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Vector2 | The nearest instance from the targets to the position. Will be the starting position if the targets list is empty. |
Nearest(GameObject, IEnumerable<Vector3>, out Single)
The nearest instance to a position.
Declaration
public static Vector3 Nearest(this GameObject position, IEnumerable<Vector3> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Vector3> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Vector3 | The nearest instance from the targets to the position. Will be the starting position if the targets list is empty. |
Nearest(Transform, IEnumerable<GameObject>, out Single)
The nearest instance to a position.
Declaration
public static GameObject Nearest(this Transform position, IEnumerable<GameObject> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<GameObject> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| GameObject | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Nearest(Transform, IEnumerable<Transform>, out Single)
The nearest instance to a position.
Declaration
public static Transform Nearest(this Transform position, IEnumerable<Transform> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Transform> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Transform | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Nearest(Transform, IEnumerable<Vector2>, out Single)
The nearest instance to a position.
Declaration
public static Vector2 Nearest(this Transform position, IEnumerable<Vector2> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Vector2> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Vector2 | The nearest instance from the targets to the position. Will be the starting position if the targets list is empty. |
Nearest(Transform, IEnumerable<Vector3>, out Single)
The nearest instance to a position.
Declaration
public static Vector3 Nearest(this Transform position, IEnumerable<Vector3> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Vector3> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Vector3 | The nearest instance from the targets to the position. Will be the starting position if the targets list is empty. |
Nearest(Vector2, IEnumerable<GameObject>, out Single)
The nearest instance to a position.
Declaration
public static GameObject Nearest(this Vector2 position, IEnumerable<GameObject> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<GameObject> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| GameObject | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Nearest(Vector2, IEnumerable<Transform>, out Single)
The nearest instance to a position.
Declaration
public static Transform Nearest(this Vector2 position, IEnumerable<Transform> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Transform> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Transform | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Nearest(Vector2, IEnumerable<Vector2>, out Single)
The nearest instance to a position.
Declaration
public static Vector2 Nearest(this Vector2 position, IEnumerable<Vector2> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Vector2> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Vector2 | The nearest instance from the targets to the position. Will be the starting position if the targets list is empty. |
Nearest(Vector2, IEnumerable<Vector3>, out Single)
The nearest instance to a position.
Declaration
public static Vector3 Nearest(this Vector2 position, IEnumerable<Vector3> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Vector3> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Vector3 | The nearest instance from the targets to the position. Will be the starting position if the targets list is empty. |
Nearest(Vector3, IEnumerable<GameObject>, out Single)
The nearest instance to a position.
Declaration
public static GameObject Nearest(this Vector3 position, IEnumerable<GameObject> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<GameObject> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| GameObject | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Nearest(Vector3, IEnumerable<Transform>, out Single)
The nearest instance to a position.
Declaration
public static Transform Nearest(this Vector3 position, IEnumerable<Transform> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Transform> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Transform | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Nearest(Vector3, IEnumerable<Vector2>, out Single)
The nearest instance to a position.
Declaration
public static Vector2 Nearest(this Vector3 position, IEnumerable<Vector2> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Vector2> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Vector2 | The nearest instance from the targets to the position. Will be the starting position if the targets list is empty. |
Nearest(Vector3, IEnumerable<Vector3>, out Single)
The nearest instance to a position.
Declaration
public static Vector3 Nearest(this Vector3 position, IEnumerable<Vector3> targets, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<Vector3> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| Vector3 | The nearest instance from the targets to the position. Will be the starting position if the targets list is empty. |
Nearest<T>(Component, IEnumerable<T>, out Single)
The nearest instance to a position.
Declaration
public static T Nearest<T>(this Component position, IEnumerable<T> targets, out float distance)
where T : Component
Parameters
| Type | Name | Description |
|---|---|---|
| Component | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<T> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| T | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Type Parameters
| Name | Description |
|---|---|
| T |
Nearest<T>(GameObject, IEnumerable<T>, out Single)
The nearest instance to a position.
Declaration
public static T Nearest<T>(this GameObject position, IEnumerable<T> targets, out float distance)
where T : Component
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<T> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| T | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Type Parameters
| Name | Description |
|---|---|
| T |
Nearest<T>(Transform, IEnumerable<T>, out Single)
The nearest instance to a position.
Declaration
public static T Nearest<T>(this Transform position, IEnumerable<T> targets, out float distance)
where T : Component
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<T> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| T | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Type Parameters
| Name | Description |
|---|---|
| T |
Nearest<T>(Vector2, IEnumerable<T>, out Single)
The nearest instance to a position.
Declaration
public static T Nearest<T>(this Vector2 position, IEnumerable<T> targets, out float distance)
where T : Component
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<T> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| T | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Type Parameters
| Name | Description |
|---|---|
| T |
Nearest<T>(Vector3, IEnumerable<T>, out Single)
The nearest instance to a position.
Declaration
public static T Nearest<T>(this Vector3 position, IEnumerable<T> targets, out float distance)
where T : Component
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | position | The position to get the nearest target instance to. |
| System.Collections.Generic.IEnumerable<T> | targets | The targets to get the nearest of. |
| System.Single | distance | The distance to the nearest target. |
Returns
| Type | Description |
|---|---|
| T | The nearest instance from the targets to the position. Will be NULL if the targets list is empty. |
Type Parameters
| Name | Description |
|---|---|
| T |