Class KaijuCastSensor
KaijuSensor to perform ray or sphere casts. This will cast from this transform in the forward direction of this transform.
Inherited Members
Namespace: KaijuSolutions.Agents.Sensors
Syntax
public class KaijuCastSensor : KaijuSensor
Fields
editorHit
The visualizations color for hits in the editor.
Declaration
public Color editorHit
Field Value
| Type | Description |
|---|---|
| Color |
editorMiss
The visualizations color for misses in the editor.
Declaration
public Color editorMiss
Field Value
| Type | Description |
|---|---|
| Color |
mask
What layers to collide with on the casts.
Declaration
public LayerMask mask
Field Value
| Type | Description |
|---|---|
| LayerMask |
triggers
How casts should handle hitting triggers.
Declaration
public QueryTriggerInteraction triggers
Field Value
| Type | Description |
|---|---|
| QueryTriggerInteraction |
Properties
Angle
What angle to cast along.
Declaration
public float Angle { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Casts
The number of casts to make. These will be evenly distributed across the KaijuSolutions.Agents.Sensors.KaijuCastSensor.angle, unless there is only one cast in which case it will cast directly forward.
Declaration
public int Casts { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
ConnectedHits
The Hits data only for points which hit, removing all NULL entries.
Declaration
public IEnumerable<RaycastHit?> ConnectedHits { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<System.Nullable<RaycastHit>> |
ConnectedTransforms
et transforms for the ConnectedHits.
Declaration
public IEnumerable<Transform> ConnectedTransforms { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<Transform> |
Distance
How far to cast.
Declaration
public float Distance { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
HasHits
If at least one ray has hit something.
Declaration
public bool HasHits { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Hits
The data from left to right of what the rays have hit, with NULL entries being rays that did not hit.
Declaration
public IReadOnlyList<RaycastHit?> Hits { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyList<System.Nullable<RaycastHit>> |
HitsTotal
The total number of casts which hit something.
Declaration
public int HitsTotal { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Radius
The radius of the casts.
Declaration
public float Radius { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Transforms
Get transforms for the Hits. Misses will be NULL.
Declaration
public IEnumerable<Transform> Transforms { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<Transform> |
Methods
Cleanup()
Perform any needed resetting of the KaijuSensor.
Declaration
protected override void Cleanup()
Overrides
Distances(Boolean)
Get the distances of all rays.
Declaration
public IEnumerable<float> Distances(bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | normalize | If distances should be normalized between [0, 1]. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<System.Single> | The distances of all rays. |
EditorVisualize(Vector3)
Allow for visualizing in the editor. The position of the Agent.
Declaration
public override void EditorVisualize(Vector3 position)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | position |
Overrides
Farthest(out Single, Boolean)
The farthest ConnectedTransforms instance to the Agent.
Declaration
public Transform Farthest(out float farthest, bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | farthest | The distance to the farthest ConnectedTransforms instance. |
| System.Boolean | normalize | If the distance should be normalized between [-1, 1]. |
Returns
| Type | Description |
|---|---|
| Transform | The farthest ConnectedTransforms instance. Will be NULL if the ConnectedTransforms list is empty. |
Farthest3(out Single, Boolean)
The farthest ConnectedTransforms instance across all axes to the Agent.
Declaration
public Transform Farthest3(out float farthest, bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | farthest | The distance to the farthest ConnectedTransforms instance. |
| System.Boolean | normalize | If the distance should be normalized between [-1, 1]. |
Returns
| Type | Description |
|---|---|
| Transform | The farthest ConnectedTransforms instance. Will be NULL if the ConnectedTransforms list is empty. |
FarthestDistance(Boolean)
The farthest Distances(Boolean) instance to the Agent.
Declaration
public float FarthestDistance(bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | normalize | If the distance should be normalized between [0, 1]. |
Returns
| Type | Description |
|---|---|
| System.Single | The farthest Distances(Boolean) instance. |
FarthestPosition(Boolean)
The farthest Positions(Boolean) instance to the Agent.
Declaration
public Vector2 FarthestPosition(bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | normalize | If the positions should be normalized between [-1, 1]. |
Returns
| Type | Description |
|---|---|
| Vector2 | The farthest Positions(Boolean) instance. Will be a zero vector if the Positions(Boolean) list is empty. |
FarthestPosition3(Boolean)
The farthest Positions(Boolean) instance to the Agent.
Declaration
public Vector3 FarthestPosition3(bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | normalize | If the positions should be normalized between [-1, 1]. |
Returns
| Type | Description |
|---|---|
| Vector3 | The farthest Positions(Boolean) instance. Will be a zero vector if the Positions(Boolean) list is empty. |
Nearest(out Single, Boolean)
The nearest ConnectedTransforms instance to the Agent.
Declaration
public Transform Nearest(out float nearest, bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | nearest | The distance to the nearest ConnectedTransforms instance. |
| System.Boolean | normalize | If the distance should be normalized between [-1, 1]. |
Returns
| Type | Description |
|---|---|
| Transform | The nearest ConnectedTransforms instance. Will be NULL if the ConnectedTransforms list is empty. |
Nearest3(out Single, Boolean)
The nearest ConnectedTransforms instance across all axes to the Agent.
Declaration
public Transform Nearest3(out float nearest, bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | nearest | The distance to the nearest ConnectedTransforms instance. |
| System.Boolean | normalize | If the distance should be normalized between [-1, 1]. |
Returns
| Type | Description |
|---|---|
| Transform | The nearest ConnectedTransforms instance. Will be NULL if the ConnectedTransforms list is empty. |
NearestDistance(Boolean)
The nearest Distances(Boolean) instance to the Agent.
Declaration
public float NearestDistance(bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | normalize | If the distance should be normalized between [0, 1]. |
Returns
| Type | Description |
|---|---|
| System.Single | The nearest Distances(Boolean) instance. |
NearestPosition(Boolean)
The nearest Positions(Boolean) instance to the Agent.
Declaration
public Vector2 NearestPosition(bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | normalize | If the positions should be normalized between [-1, 1]. |
Returns
| Type | Description |
|---|---|
| Vector2 | The nearest Positions(Boolean) instance. Will be a zero vector if the Positions(Boolean) list is empty. |
NearestPosition3(Boolean)
The nearest Positions(Boolean) instance to the Agent.
Declaration
public Vector3 NearestPosition3(bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | normalize | If the positions should be normalized between [-1, 1]. |
Returns
| Type | Description |
|---|---|
| Vector3 | The nearest Positions(Boolean) instance. Will be a zero vector if the Positions(Boolean) list is empty. |
Positions(Boolean)
The positions corresponding to the Hits, with Hits that missed being set to the maximum casting distance.
Declaration
public IEnumerable<Vector2> Positions(bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | normalize | If positions should be normalized between [-1, 1]. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<Vector2> |
Positions3(Boolean)
The positions corresponding to the Hits, with Hits that missed being set to the maximum casting distance.
Declaration
public IEnumerable<Vector3> Positions3(bool normalize = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | normalize | If positions should be normalized between [-1, 1]. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<Vector3> |
Run()
Run the KaijuSensor.
Declaration
protected override void Run()
Overrides
Operators
Implicit(GameObject to KaijuCastSensor)
Implicit conversion from a GameObject.
Declaration
public static implicit operator KaijuCastSensor(GameObject o)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | o | The GameObject. |
Returns
| Type | Description |
|---|---|
| KaijuCastSensor | The KaijuAgentsVisionSensor attached to the GameObject if there was one. |
Implicit(KaijuCastSensor to KaijuAgent)
Implicit conversion to a KaijuAgent.
Declaration
public static implicit operator KaijuAgent(KaijuCastSensor s)
Parameters
| Type | Name | Description |
|---|---|---|
| KaijuCastSensor | s |
Returns
| Type | Description |
|---|---|
| KaijuAgent | The KaijuAgent attached to the KaijuAgentsVisionSensor if there was one. |
Implicit(Transform to KaijuCastSensor)
Implicit conversion from a transform.
Declaration
public static implicit operator KaijuCastSensor(Transform t)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | t | The transform. |
Returns
| Type | Description |
|---|---|
| KaijuCastSensor | The KaijuAgentsVisionSensor attached to the transform if there was one. |