Class AbstractPrimitiveColliderCast
Abstract class to optimize operations for a primitive shape collider cast.
Inheritance
Namespace: nickmaltbie.OpenKCC.Utils.ColliderCast
Assembly: cs.temp.dll.dll
Syntax
public abstract class AbstractPrimitiveColliderCast : MonoBehaviour, IColliderCast, IRaycastHelper
Fields
_collider
Collider associated with this primitive collider cast.
Declaration
protected Collider _collider
Field Value
Type | Description |
---|---|
Collider |
HitCache
Raycast hit cache.
Declaration
protected static RaycastHit[] HitCache
Field Value
Type | Description |
---|---|
RaycastHit[] |
OverlapCache
Overlap hit cache.
Declaration
protected static Collider[] OverlapCache
Field Value
Type | Description |
---|---|
Collider[] |
OverlapCacheSize
Cache size for collider overlap.
Declaration
public const int OverlapCacheSize = 25
Field Value
Type | Description |
---|---|
Int32 |
RaycastHitCacheSize
Cache size for raycast hit.
Declaration
public const int RaycastHitCacheSize = 25
Field Value
Type | Description |
---|---|
Int32 |
Properties
Collider
Primitive collider shape associated with this object.
Declaration
public Collider Collider { get; }
Property Value
Type | Description |
---|---|
Collider |
ColliderHideFlags
Hiding flags for the collider component.
Declaration
protected virtual HideFlags ColliderHideFlags { get; }
Property Value
Type | Description |
---|---|
HideFlags |
Methods
CastSelf(Vector3, Quaternion, Vector3, Single, out IRaycastHit, Int32, QueryTriggerInteraction, Single)
Cast self in a given direction and get the first object hit.
Declaration
public bool CastSelf(Vector3 position, Quaternion rotation, Vector3 direction, float distance, out IRaycastHit hit, int layerMask = -1, QueryTriggerInteraction queryTriggerInteraction = null, float skinWidth = 0.01F)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | Position of the object when it is being raycast. |
Quaternion | rotation | Rotation of the objecting when it is being raycast. |
Vector3 | direction | Direction of the raycast. |
Single | distance | Maximum distance of raycast. |
IRaycastHit | hit | First object hit and related information, will have a distance of Infinity if none is found. |
Int32 | layerMask | Layer mask for checking which objects to collide with. |
QueryTriggerInteraction | queryTriggerInteraction | Configuration for QueryTriggerInteraction when solving for collisions. |
Single | skinWidth | Buffer around player when casting object. |
Returns
Type | Description |
---|---|
Boolean | True if an object is hit within distance, false otherwise. |
DoRaycastInDirection(Vector3, Vector3, Single, out IRaycastHit, Int32, QueryTriggerInteraction)
Do a raycast in a given direction ignoring this object.
Declaration
public bool DoRaycastInDirection(Vector3 source, Vector3 direction, float distance, out IRaycastHit stepHit, int layerMask = -1, QueryTriggerInteraction queryTriggerInteraction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | source | Source point to check from. |
Vector3 | direction | Direction to search for step. |
Single | distance | Distance to search for step ahead of player. |
IRaycastHit | stepHit | Information about step hit ahead. |
Int32 | layerMask | Layer mask for checking which objects to collide with. |
QueryTriggerInteraction | queryTriggerInteraction | Configuration for QueryTriggerInteraction when solving for collisions. |
Returns
Type | Description |
---|---|
Boolean | Is something ahead hit. |
GetBottom(Vector3, Quaternion)
Gets the bottom of the bounds of the collider.
Declaration
public abstract Vector3 GetBottom(Vector3 position, Quaternion rotation)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | Position of the object when it is being checked. |
Quaternion | rotation | Rotation of the objecting when it is being checked. |
Returns
Type | Description |
---|---|
Vector3 | Bottom of the bounds of the collider. |
GetHits(Vector3, Quaternion, Vector3, Single, Int32, QueryTriggerInteraction, Single)
Cast self and get the objects hit that exclude this object.
Declaration
public abstract IEnumerable<RaycastHit> GetHits(Vector3 position, Quaternion rotation, Vector3 direction, float distance, int layerMask = -1, QueryTriggerInteraction queryTriggerInteraction = null, float skinWidth = 0.01F)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | Position of the object when it is being raycast. |
Quaternion | rotation | Rotation of the objecting when it is being raycast. |
Vector3 | direction | Direction to cast self collider. |
Single | distance | Distance to cast self collider. |
Int32 | layerMask | Layer mask for checking which objects to collide with. |
QueryTriggerInteraction | queryTriggerInteraction | Configuration for QueryTriggerInteraction when solving for collisions. |
Single | skinWidth | Buffer around player when computing collisions. |
Returns
Type | Description |
---|---|
IEnumerable<RaycastHit> | List of objects this hits when it is being raycast |
GetOverlapping(Vector3, Quaternion, Int32, QueryTriggerInteraction, Single)
Gets the list of objects overlapping with this object.
Declaration
public abstract IEnumerable<Collider> GetOverlapping(Vector3 position, Quaternion rotation, int layerMask = -1, QueryTriggerInteraction queryTriggerInteraction = null, float skinWidth = 0F)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | Position of the object when it is being checked. |
Quaternion | rotation | Rotation of the objecting when it is being checked. |
Int32 | layerMask | Layer mask for checking which objects to collide with. |
QueryTriggerInteraction | queryTriggerInteraction | Configuration for QueryTriggerInteraction when solving for collisions. |
Single | skinWidth | Buffer around player when computing overlapping objects. |
Returns
Type | Description |
---|---|
IEnumerable<Collider> | The list of overlapping objects with this object. |
PushOutOverlapping(Vector3, Quaternion, Single, Int32, QueryTriggerInteraction, Single)
Get the vector to push this object out of overlapping objects with a max distance.
Declaration
public virtual Vector3 PushOutOverlapping(Vector3 position, Quaternion rotation, float maxDistance, int layerMask = -1, QueryTriggerInteraction queryTriggerInteraction = null, float skinWidth = 0F)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | Position of the object when it is being raycast. |
Quaternion | rotation | Rotation of the objecting when it is being raycast. |
Single | maxDistance | Maximum distance the player can be pushed |
Int32 | layerMask | Layer mask for checking which objects to collide with. |
QueryTriggerInteraction | queryTriggerInteraction | Configuration for QueryTriggerInteraction when solving for collisions. |
Single | skinWidth | Buffer around player when computing overlapping objects. |
Returns
Type | Description |
---|---|
Vector3 | Direction to push the object, distance player was pushed. |
SetupCollider()
Setup the collider associated with this object.
Declaration
public void SetupCollider()
SetupColliderComponent()
Setup the collider component associated with this object.
Declaration
protected abstract Collider SetupColliderComponent()
Returns
Type | Description |
---|---|
Collider | Collider created (or one that already exists) for this object. |
Start()
Configure collider component.
Declaration
public virtual void Start()
UpdateColliderParameters()
Update the parameters of the collider on a configuration change.
Declaration
public virtual void UpdateColliderParameters()