Asteroids example file is broken

Blitz3D Forums/Blitz3D Programming/Asteroids example file is broken

Ddawg747(Posted 2017) [#1]
I was examining the asteroids sample game file and i noticed that the player to asteroid collision detection isnt working. How would i fix it? Ive tried everything i possibly could but nothing worked. Thanks!


RemiD(Posted 2017) [#2]
Try to be more vague, maybe this will help.


Rick Nasher(Posted February) [#3]
'Gambling' he means this one:
C:\Program Files (x86)\Blitz3D\Games\bb3d_asteroids

Yep, indeed asteroids appear to not be causing any damage, apparently only the shots of the UFO's.


Ddawg747(Posted February) [#4]
Does anyone know how to fix it?


RemiD(Posted February) [#5]
Wait a moment, i am taking a look at the bb code...


RemiD(Posted February) [#6]
The way this code checks for collisions, is not the best way since it checks for a collision between an entity and a group of entities of a collisiongroup.
A better way is to check for a collision between a turning moving bullet and each spaceship/asteroid, (for such a simple game there is no need to do others optimizations).
Then if a collision is detected, destroy the bullet, destroy the spaceship/asteroid, create explosions particles, update explosions particles.

To detect collisions between a bullet and a spaceship/asteroid, you can use
a distance3d calculation (with entitydistance())
or
ellipsoids and collidables (with entityradius(), entitytype(), collisions(), countcollisions(), collidedentity())
or
linepicks an pickables (with entitypickmode() tformvector() linepick(), pickedentity())

an example on how to throw an ellipsoid or a linepick and how to detect collisions with collidables/pickables :
with dim array lists : http://www.blitzbasic.com/codearcs/codearcs.php?code=3094
with customtype lists : http://www.blitzbasic.com/codearcs/codearcs.php?code=3095

good luck !


Rick Nasher(Posted February) [#7]
Apart from the method..

What is weird that this apparently, back in the days - as I recall, used to work fine. Now Asteroid/UFO to ship collision appears not to be working at all, only shots to asteroids/ship/UFO collisions seem to work.

So question is: What changed - Did things get messed up with a Blitz update and people never checked back?

I'm using Blitz3D V1.106 on Win 10 x64. I wonder if this has anything to do with it.


Pakz(Posted February) [#8]
I noticed the same behaviour. Though one time the bullets looked liked they worked and the astroid exploded.

I was thinking of taking apart the game to get the bug visible in a short code example. Not to sure when I can make time for that though.


RemiD(Posted February) [#9]
A way to debug a collision is to color the collided entity instead of destroying it. Also draw (with text()) the reference of each collidable above the associated entity, and when a collision between a bullet and a collidable is detected, use debuglog() to see the reference (in the debug log), and see if they correspond.


Ddawg747(Posted February) [#10]
Im sorry if there was any confusion but for me the bullets collide perfectly the problem i am having is when my player model collides with the asteroid model it should take damage but instead nothing happens Thank you all for your feedback. It is helping me more than you know.


Dan(Posted February) [#11]
yes Ddawg747, somehow the collision detection for the ship pivot vs asteroids and ship pivot vs Ufo does not trigger.

It can be a bug in newer blitzbasic versions, maybe some of the older ones work better ?


RemiD(Posted February) [#12]
@Ddawg747>>you can debug ellipsoid colliders (the shapes that provoke a collision) by having a partially transparent/opaque sphere positionned at the smae position than your turning moving entity.
See an example here : http://www.blitzbasic.com/codearcs/codearcs.php?code=3141

The collidables (the shapes that receive a collision) are usually the same meshes than the meshes used to display your entities. (but you can also use a low details version)