Collisions command single-handedly crashing the entire program  

👉 BlitzCoder will be building a new platform and other plans to preserve and continue the Blitz legacy.

To be able to achieve this goal, we need your support by becoming a Patreon Paid Member 👈



As I'm coding a simple pad and ball game (essentially breakout game without the blocks to break) I try to put in a collision command but it crashes the program when I run it, before it was working perfectly fine (albeit the collision not working), what could be the reason that the collision command is breaking the program entirely and how could it be fixed? Thanks!
Code below if helps:

Graphics3D 1280,720,16

SetBuffer BackBuffer()

pad_col = 1
ball_col = 2
wall_col = 3
flor_col = 4
ceil_col = 5

camera = CreateCamera()
PositionEntity camera,0,2.5,-5

light = CreateLight()

pad = CreateCube()
ScaleEntity pad,1.25,0.5,0.75
PositionEntity pad,0,0,5
EntityColor pad,255,0,0
EntityType pad,pad_col

ball = CreateSphere()
ScaleEntity ball,0.75,0.75,0.75
PositionEntity ball,0,5,5
EntityColor ball,0,75,255
EntityType ball,ball_col

wall1 = CreateCube()
ScaleEntity wall1,10,10,5
PositionEntity wall1,-15,0,5
EntityColor wall1,0,255,0
EntityType wall1,wall_col

wall2 = CreateCube()
ScaleEntity wall2,10,10,5
PositionEntity wall2,15,0,5
EntityColor wall2,0,255,0
EntityType wall2,wall_col

flor = CreateCube()
ScaleEntity flor,10,1,10
PositionEntity flor,0,-2,0
EntityColor flor,190,255,172
EntityType flor,flor_col

ciel = CreateCube()
ScaleEntity ciel,10,1,10
PositionEntity ciel,0,8,0
EntityColor ciel,100,100,172
EntityType ciel,ceil_col

Collisions pad,wall_col,1,1 ;this Collisions is somehow crashing the entire program

While Not KeyDown(1)
If KeyDown (30) Or KeyDown (203) Then TranslateEntity pad,-0.025,0,0
If KeyDown (32) Or KeyDown (205) Then TranslateEntity pad,0.025,0,0

x = x + 0.01

If EntityCollided (pad,wall_col) And KeyDown (30) Then
MoveEntity pad,1,0,0
EndIf ;collision not working pls fix


  Hrobo88 commented:

Nevermind, I found the solution, that being to make it so that its entitytypes i.e. Collisions pad_col,wall_col instead of entity and entitytype i.e. Collisions pad,wall_col, though I'm still facing the issue of collisions not working

RemiD commented:

this is because the blitz3d collisions system only allows collisions detection between ellipsoid (sphere) and sphere, between ellipsoid (sphere) and box, between ellipsoid (sphere) and mesh.

and 'pad' is a cube...

so you need to set a entityradius() for each ellipsoid (sphere)

also the collisions() command has only 3 parameters, collisions( ellipsoid (collisiongroup), collided sphere / box / mesh (collisiongroup), response )

here is an example :
and another example :

CraigTheCoder commented:

Your code assumes that colliders are automatically assigned, which is not the case in Blitz3D.

The pad object needs a box value via EntityBox. The ball needs a radius value via EntityRadius. Since collisions are always sphere to something else(sphere/polygon/box) the ball needs to be the source object in the collisions call.

Also consider making the ball always move in one direction via MoveEntity, and then changing its direction via TurnEntity when it collides with an object

I recommend downloading and reading the documentation for Blitz3D. It has code examples for most functions, which helps you to minimize errors.

Reply To Topic (minimum 10 characters)

Please log in to reply