Skip to content

Collisions

Narta Xaymar Dirks edited this page Oct 28, 2026 · 6 revisions
Blitz3D

Collisions

Collisions:Void source_type:Int32, destination_type:Int32, method:Int32, response:Int32
Parameter Mode Type Default Description
source_type In Int32 required Collision type of the entities that move.
destination_type In Int32 required Collision type of the entities they can hit.
method In Int32 required 1 ellipsoid, 2 polygon, 3 box, see the table.
response In Int32 required 1 stop, 2 slide, 3 slide without slipping down slopes. Any other value slides without limiting how far, like the original.

Description

Switches on collision checking between two entity types, and says how it should work. All checking, and the movement that follows from it, happens inside UpdateWorld. Between calls, the entity can be moved freely with MoveEntity, TranslateEntity and so on; UpdateWorld then walks the entity from where it was at the last update to where you put it, and stops or slides it if something is in the way.

The source type is the one that moves and gets pushed back. The destination type is what it bumps into. A pair of types can only have one rule: if you call Collisions again for the same pair, the new call is ignored until ClearCollisions removes the rules. Collisions work in one direction only, so Collisions 2, 1, ... does not make type 1 react to type 2.

Method The source ellipsoid hits Destination needs
1 The destination's ellipsoid EntityRadius
2 The triangles of the destination mesh Nothing, but it has to be a mesh
3 The destination's box EntityBox
Response What the source does
1 Stops where it hit.
2 Slides along the surface.
3 Slides, but only sideways and upwards: it does not slip down slopes.

Hidden entities, and entities with a hidden parent, are not collided with.

Differences

  • Types outside 0 to 999, or a method outside 1 to 3, stop the program with a runtime error.

Examples

Graphics3D 320, 240, 0, 2
SetBuffer BackBuffer()
camera = CreateCamera()
CameraClsColor camera, 30, 40, 70
PositionEntity camera, 0, 14, 0
RotateEntity camera, 90, 0, 0
light = CreateLight()
RotateEntity light, 60, 30, 0

; A wall of type 1 and two balls of type 2 and 3.
wall = CreateCube()
ScaleEntity wall, 0.5, 1, 5
PositionEntity wall, 3, 0, 0
EntityColor wall, 200, 200, 200
EntityType wall, 1

stopper = CreateSphere(16)
EntityColor stopper, 220, 70, 60
EntityRadius stopper, 1
EntityType stopper, 2
PositionEntity stopper, -6, 0, -1.5

slider = CreateSphere(16)
EntityColor slider, 70, 200, 110
EntityRadius slider, 1
EntityType slider, 3
PositionEntity slider, -6, 0, 1.5

; Polygon collisions with the wall; type 2 stops, type 3 slides.
Collisions 2, 1, 2, 1
Collisions 3, 1, 2, 2

For frame = 0 To 49
	TranslateEntity stopper, 0.2, 0, -0.08
	TranslateEntity slider, 0.2, 0, 0.08
	UpdateWorld
	RenderWorld
	Color 255, 255, 255
	Text 8, 8, "red: Collisions 2, 1, 2, 1 (stop)"
	Text 8, 24, "green: Collisions 3, 1, 2, 2 (slide)"
	Flip
Next

Media

Collisions

Related Commands

ClearCollisions, CollisionNY, CollisionNZ, CountCollisions

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally