A Little Collision Help
BlitzMax Forums/MiniB3D Module/A Little Collision Help
| ||
I'm hoping someone can help me out here. I've started a very basic 3d game (my first one) and I'm having a bit of trouble with collisions. I have 1 mesh for my player, and it is given EntityType 1, while my buildings are EntityType2. Now, when I setup Collisions 1,2,3,1 or any other combination of 1,2,#,# nothing happens. Now, I control the movement of my player with WASD movement, so maybe I'm messing something up here, but how exactly do I check for collisions then? Also, I've noticed that Collisions 1,2,2,2 requires a sphere radius to be applied, but how does this work with tall, slim type meshes? The hit boxes would be very off. I can post my code if needed. Thanks |
| ||
* Use Collisions 1,2,2 * Use EntityRadius x,y for an ellipsoid * Make sure you are using UpdateWorld once per loop. Look at the sliding_collisions.bmx for an example. |
| ||
Thank you, that worked great! |
| ||
Alright, maybe I spoke too soon. I am no longer using CreateCube, but rather a mesh that I exported from Blender. I have the following for TShip: ' 3D Entity s.mesh = copymesh(efactory.shipMesh) s.texture = efactory.shipTex EntityTexture s.mesh, s.texture PositionEntity s.mesh, 0,0,0 EntityType s.mesh, SHIPID ScaleEntity s.mesh, s.sizex, s.sizey, s.sizez EntityRadius s.mesh, s.sizex, s.sizey, s.sizez TurnEntity s.mesh, s.xrotation, s.yrotation, s.zrotation and for TAsteroid: a.mesh = CopyMesh(efactory.asteroidMesh) a.texture = efactory.asteroidTex EntityTexture a.mesh, a.texture EntityRadius a.mesh, a.sizex, a.sizex, a.sizez PositionEntity a.mesh, a.x, a.y, 0 EntityType a.mesh, ASTEROIDID scaleEntity a.mesh, a.sizex, a.sizey, a.sizez Both are created with PositionEntity a.mesh, x, y, 0 as to keep the Z axis out of the picture. SHIPID = 1 ASTEROIDID = 2 by calling Collisions 1,2,2 I really only care about the Entities that collide, so I've tried EntityCollide and CountCollisions to see if my ship has collided with anything. Neither are correct. Any ideas? |
| ||
Collision mode 2 is only intended for use with dynamic ellipsoids -> static meshes. If your ship and asteroids are both moving, you will have to use method 1 (sphere-sphere). Use Collisions 1,2,1 for this. |
| ||
I'm sorry, I forgot to mention that I tried that method as well. Should countCollisions or EntityCollide be returning correctly in either of these situations? |
| ||
Great, I figured it out. I was altering my ship.x based on my own coordinates and not the EntityX/Y/Z ones. Learn something new everyday... |
| ||
Ok, well, this still isn't working and I'm very confused as to why. Perhaps I'm doing something to break something... My ship is positioned at screehwidth/2, screenheight/2, z=0 The ship actually never moves, but everything else is adjusted by is velocity. So, an asteroid is moved -x,-y of the ships velocity direction. When an asteroid is moved, I call PositionEntity, does that have an effect on anything? Also, I use CopyMesh for my asteroids, does that affect collisions at all? I've printed out the EntityX/Y/Z of all objects and I can place my ship directly over an asteroid and the coordinates are correct, but nothing happens. Does EntityCollided not work with collisison? I am calling EntityCollided(self.mesh, ASTEROIDID), is that not correct? Any ideas? |
| ||
If you send me the program I'll take a look. |
| ||
I sent you an email with the code. |