RayCollide()

Syntax

Result = RayCollide(x, y, z, DestinationX, DestinationY, DestinationZ [, CollisionGroup , CollisionMask]])
Description
Casts a ray between the first point and the second point, and checks if an entity is colliding the ray. This function relies on the physic engine, which needs to be activated with EnableWorldPhysics() before using this command. Only entities with bodies will react to the ray. To get the position about the collide point, use PickX(), PickY() and PickZ(). The normals values at the collide point are available with NormalX(), NormalY() and NormalZ().

Parameters

x, y, z The first point coordinates, in world unit.
DestinationX, DestinationY, DestinationZ The second point coordinates, in world unit.
CollisionGroup, CollisionMask (optional) The collision group and collision mask to use. Can be useful to filter which entity should collide to the ray. Collision group and mask can be changed with SetEntityCollisionFilter().

Return value

Returns the entity number if the ray has collided with one, or -1 if no collision has occurred.

See Also

NormalX(), NormalY(), NormalZ(), SetEntityCollisionFilter()

Supported OS

All

<- RayCast() - Engine3D Index - RayPick() ->