Structure

CollisionCastHit

A hit result of a collision cast.

Declaration

struct CollisionCastHit

Overview

You get a collection of collision cast hits from either the raycast(origin:direction:length:query:mask:relativeTo:) method, or the convexCast(convexShape:fromPosition:fromOrientation:toPosition:toOrientation:query:mask:relativeTo:) method. Each hit indicates where the ray or the convex shape, starting at a given point and traveling in a given direction, hit a particular entity in the scene.

The frame of reference for the position and normal of the hit depends on the reference entity parameter passed to the method that generated the hit. Pass nil as the reference to use world space.

Topics

Getting the Entity

var entity: Entity

The entity that was hit.

Characterizing the Collision Cast Hit

var position: SIMD3<Float>

The position of the hit.

var normal: SIMD3<Float>

The normal of the hit.

var distance: Float

The distance from the ray origin to the hit, or the convex shape travel distance.

Comparing Collision Cast Hits

static func == (CollisionCastHit, CollisionCastHit) -> Bool

Indicates whether two cast hits are equal.

static func != (CollisionCastHit, CollisionCastHit) -> Bool

Indicates whether two cast queries are not equal.

Relationships

Conforms To

See Also

Detecting Intersections

func raycast(origin: SIMD3<Float>, direction: SIMD3<Float>, length: Float, query: CollisionCastQueryType, mask: CollisionGroup, relativeTo: Entity?) -> [CollisionCastHit]

Performs a convex ray cast against all the geometry in the scene for a ray of a given origin, direction, and length.

func raycast(from: SIMD3<Float>, to: SIMD3<Float>, query: CollisionCastQueryType, mask: CollisionGroup, relativeTo: Entity?) -> [CollisionCastHit]

Performs a convex ray cast against all the geometry in the scene for a ray between two end points.

enum CollisionCastQueryType

The kinds of ray and convex shape cast queries that you can make.

struct CollisionGroup

A bitmask used to define the collision group to which an entity belongs, and with which it can collide.