Contents

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

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

Declaration

@MainActor @preconcurrency 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:

    The convex shape to 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, collides with entities in the scene. To retrieve the hit entity from a returned CollisionCastHit, use the entity property.

Discussion

For objects that intersect the convex shape at its starting position and orientation, the returned collision cast hit result’s position is (0, 0, 0) and the normal points in the opposite direction of the sweep.

See Also

Detecting intersections