Photon Quantum 2.1.1

Public Member Functions | Public Attributes | Properties | List of all members
Quantum.Physics2D.Hit Struct Reference

Information returned from a valid hit of a physics query. More...

Public Member Functions

ref MapStaticCollider2D GetStaticCollider (FrameBase f)
 Gets a reference to the static collider hit. Does not perform additional safety checks. More...
 
ref StaticColliderData GetStaticData (FrameBase f)
 Gets a reference to the data of the static collider hit (MapStaticCollider2D.StaticData). Does not perform additional safety checks. More...
 
void SetHitEntity (EntityRef entity)
 Sets the entity that was hit. Automatically resets StaticColliderIndex to -1. More...
 
void SetHitStaticCollider (int staticColliderIndex, AssetRefMap mapRef)
 Sets the index of the static collider hit on the Map.StaticColliders2D array of the referenced map. More...
 
bool TryGetStaticCollider (FrameBase f, out MapStaticCollider2D collider)
 Tries to access the static collider that was hit. More...
 
bool TryGetStaticData (FrameBase f, out StaticColliderData data)
 Tries to access the data of the static collider that was hit (MapStaticCollider2D.StaticData). More...
 

Public Attributes

FP CastDistanceNormalized
 A normalized value (0 to 1) of the feature being casted when the hit occurs, relative to its full cast distance. More...
 
FPVector2 Normal
 The surface normal of the hit. More...
 
FP OverlapPenetration
 The penetration of a shape overlap query on the collider that was hit. More...
 
FPVector2 Point
 The point in world space where the collider is hit by the query. More...
 
ushort ShapeUserTag
 The Shape2D.UserTag field of the shape hit by the query. More...
 

Properties

EntityRefEntity [get]
 The reference of the entity hit by the query, EntityRef.None if hitting a static collider (IsDynamic false). More...
 
Boolean IsDynamic [get]
 If the collider hit by the query is not static, i.e. it belongs to an Entity. More...
 
Boolean? IsTrigger [get, set]
 If the collider hit by the query is Trigger. More...
 
int StaticColliderIndex [get]
 0-based index of the static collider on the Map.StaticColliders2D array of the map referenced by StaticColliderMapRef. If the hit IsDynamic, this value is -1. Tip: use TryGetStaticCollider(FrameBase, out MapStaticCollider2D), TryGetStaticData(FrameBase, out StaticColliderData), GetStaticCollider(FrameBase) or GetStaticData(FrameBase) in order to safely and conveniently access info about a static collider hit. More...
 
AssetRefMap StaticColliderMapRef [get]
 The reference to the map used by the physics engine when a static collider is hit. Otherwise, this value is default (hit IsDynamic). More...
 

Detailed Description

Information returned from a valid hit of a physics query.

Member Function Documentation

◆ SetHitEntity()

void Quantum.Physics2D.Hit.SetHitEntity ( EntityRef  entity)
inline

Sets the entity that was hit. Automatically resets StaticColliderIndex to -1.

Parameters
entityThe entity reference.

◆ SetHitStaticCollider()

void Quantum.Physics2D.Hit.SetHitStaticCollider ( int  staticColliderIndex,
AssetRefMap  mapRef 
)
inline

Sets the index of the static collider hit on the Map.StaticColliders2D array of the referenced map.

Parameters
staticColliderIndexA valid index of the static collider on the array of the map.
mapRefA reference to the map where the static collider hit is located.

◆ TryGetStaticCollider()

bool Quantum.Physics2D.Hit.TryGetStaticCollider ( FrameBase  f,
out MapStaticCollider2D  collider 
)
inline

Tries to access the static collider that was hit.

Parameters
fCurrent frame.
colliderA copy of the static collider data found. Default if the metadata is not valid (returns false).
Returns
False if the collider hit is not static or the collide index or referenced map are not valid. True otherwise.

◆ TryGetStaticData()

bool Quantum.Physics2D.Hit.TryGetStaticData ( FrameBase  f,
out StaticColliderData  data 
)
inline

Tries to access the data of the static collider that was hit (MapStaticCollider2D.StaticData).

Parameters
fCurrent frame.
dataA copy of the static collider data found. Default if the metadata is not valid (returns false).
Returns
False if the collider hit is not static or the collide index or referenced map are not valid. True otherwise.

◆ GetStaticCollider()

ref MapStaticCollider2D Quantum.Physics2D.Hit.GetStaticCollider ( FrameBase  f)
inline

Gets a reference to the static collider hit. Does not perform additional safety checks.

Parameters
fCurrent frame.
Exceptions
NullReferenceExceptionIf the StaticColliderMapRef does not reference a valid asset.
IndexOutOfRangeExceptionIf the hit is not static (IsDynamic) or the collider index is not valid for the array of static colliders on the referenced map.
Returns
A reference to the static collider hit.

◆ GetStaticData()

ref StaticColliderData Quantum.Physics2D.Hit.GetStaticData ( FrameBase  f)
inline

Gets a reference to the data of the static collider hit (MapStaticCollider2D.StaticData). Does not perform additional safety checks.

Parameters
fCurrent frame.
Exceptions
NullReferenceExceptionIf the StaticColliderMapRef does not reference a valid asset.
IndexOutOfRangeExceptionIf the hit is not static (IsDynamic) or the collider index is not valid for the array of static colliders on the referenced map.
Returns
A reference to the static collider hit.

Member Data Documentation

◆ ShapeUserTag

ushort Quantum.Physics2D.Hit.ShapeUserTag

The Shape2D.UserTag field of the shape hit by the query.

◆ OverlapPenetration

FP Quantum.Physics2D.Hit.OverlapPenetration

The penetration of a shape overlap query on the collider that was hit.

This field is not computed unless QueryOptions.ComputeDetailedInfo is used in the query options and only applies to Shape Overlap queries. It overlaps in memory and is mutually exclusive with CastDistanceNormalized.

◆ CastDistanceNormalized

FP Quantum.Physics2D.Hit.CastDistanceNormalized

A normalized value (0 to 1) of the feature being casted when the hit occurs, relative to its full cast distance.

This field only applies to Ray, Line or Shape casts. It overlaps in memory and is mutually exclusive with OverlapPenetration.

◆ Point

FPVector2 Quantum.Physics2D.Hit.Point

The point in world space where the collider is hit by the query.

◆ Normal

FPVector2 Quantum.Physics2D.Hit.Normal

The surface normal of the hit.

This field is not computed unless QueryOptions.ComputeDetailedInfo is used in the query options.

Property Documentation

◆ IsDynamic

Boolean Quantum.Physics2D.Hit.IsDynamic
get

If the collider hit by the query is not static, i.e. it belongs to an Entity.

◆ StaticColliderIndex

int Quantum.Physics2D.Hit.StaticColliderIndex
get

0-based index of the static collider on the Map.StaticColliders2D array of the map referenced by StaticColliderMapRef. If the hit IsDynamic, this value is -1. Tip: use TryGetStaticCollider(FrameBase, out MapStaticCollider2D), TryGetStaticData(FrameBase, out StaticColliderData), GetStaticCollider(FrameBase) or GetStaticData(FrameBase) in order to safely and conveniently access info about a static collider hit.

◆ StaticColliderMapRef

AssetRefMap Quantum.Physics2D.Hit.StaticColliderMapRef
get

The reference to the map used by the physics engine when a static collider is hit. Otherwise, this value is default (hit IsDynamic).

◆ IsTrigger

Boolean? Quantum.Physics2D.Hit.IsTrigger
getset

If the collider hit by the query is Trigger.

◆ Entity

EntityRef? Quantum.Physics2D.Hit.Entity
get

The reference of the entity hit by the query, EntityRef.None if hitting a static collider (IsDynamic false).