Skip to content

PhysicsRayCast

Narta Xaymar Dirks edited this page Nov 14, 2026 · 1 revision
BlitzLLVM

PhysicsRayCast 〔BlitzLLVM〕

PhysicsRayCast:Int32 x1:Float32, y1:Float32, z1:Float32, x2:Float32, y2:Float32, z2:Float32, mask_low:Int32=-1, mask_high:Int32=-1, sensors:Int32=0, world:Int32=0
Parameter Mode Type Default Description
x1 In Float32 required Where the ray starts, x.
y1 In Float32 required Where the ray starts, y.
z1 In Float32 required Where the ray starts, z.
x2 In Float32 required Where the ray ends, x. Bodies behind this point are not hit.
y2 In Float32 required Where the ray ends, y.
z2 In Float32 required Where the ray ends, z.
mask_low In Int32 -1 The layers to look at, as bits 0 to 31 of a mask (bit n is layer n). -1 (default) looks at all layers.
mask_high In Int32 -1 The layers 32 to 63, as bits 0 to 31 of a mask. -1 (default) looks at all layers.
sensors In Int32 0 1 also finds sensors (see PhysicsSensor); 0 (default) leaves them out.
world In Int32 0 The physics world, 0 (default) for the default world.

Returns: The entity of the body that was hit, or 0 if there is none.

Description

〔BlitzLLVM〕 This command does not exist in the original Blitz products. BlitzLLVM adds it.

Sends a ray from one point to another through the bodies of a physics world and returns the closest body it hits. All points are in the world. The ray sees bodies where their entities are now, including a body that the program moved since the last PhysicsUpdate. It does not see legacy colliders or the meshes of LinePick, which are a different world.

What was hit is kept for GetPhysicsHitEntity, GetPhysicsHitX, GetPhysicsHitY, GetPhysicsHitZ, GetPhysicsHitNX, GetPhysicsHitNY, GetPhysicsHitNZ and GetPhysicsHitDistance until the next ray or point query.

Differences

  • The original has no such command. This is an extension; programs that use it do not compile with the original Blitz3D.

Examples

body = PhysicsRayCast(0, 10, 0, 0, -10, 0)
If body
	Print "Hit at height " + GetPhysicsHitY()
EndIf

Related Commands

PhysicsAngularDamping 〔BlitzLLVM〕, PhysicsAngularVelocity 〔BlitzLLVM〕, PhysicsApplyAngularImpulse 〔BlitzLLVM〕, PhysicsApplyForce 〔BlitzLLVM〕, PhysicsApplyForceAt 〔BlitzLLVM〕, PhysicsApplyImpulse 〔BlitzLLVM〕, PhysicsApplyImpulseAt 〔BlitzLLVM〕, PhysicsApplyTorque 〔BlitzLLVM〕

Home · Command Index


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

Clone this wiki locally