Instance Method

convexCast(convexShape:fromPosition:fromOrientation:toPosition:toOrientation:query:mask:relativeTo:)

Performs a convex shape cast against all the geometry in the scene.

Declaration

func convexCast(convexShape: ShapeResource, fromPosition: SIMD3<Float>, fromOrientation: simd_quatf, toPosition: SIMD3<Float>, toOrientation: simd_quatf, query: CollisionCastQueryType = .all, mask: CollisionGroup = .all, relativeTo referenceEntity: Entity? = nil) -> [CollisionCastHit]

Parameters

convexShape

A convex shape used to perform the cast.

fromPosition

The starting position of convexShape relative to referenceEntity.

fromOrientation

The starting orientation of convexShape relative to referenceEntity.

toPosition

The ending position of convexShape relative to referenceEntity.

toOrientation

The ending orientation of convexShape relative to referenceEntity.

query

The query type.

mask

A collision mask that you can use to prevent collisions with certain objects.

referenceEntity

An entity that defines the frame of reference. The method returns results relative to this entity. Set to nil to use the world space origin (0, 0, 0).

Return Value

An array of collision cast hit results. Each hit indicates where the convex shape, starting at a given point and traveling in a given direction, hit a particular entity in the scene.

Discussion

The method ignores entities that lack a CollisionComponent.

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.

struct CollisionCastHit

A hit result of a collision cast.

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.