Collision of two moving entities
Blitz3D Forums/Blitz3D Programming/Collision of two moving entities
| ||
Check: http://www.stickystudios.com/ftpJeroen/multipongtest3.exe (467kb) I want to make a LAN pong game with some Arkanoid influences. Just a simple little game :-) 1) If you move the bat quickly it will not collide with the balls. Does anyone know how I can check like "Entitydistance", but then for rectangular objects? The odd thing is; the balls collide properly, with Blitz collisions! 2) When you press the left mouse button, the camera turns, and the controls will be bad, since the Y-axis do not correspondent with the camera rotation. How can I possibly avoid this problem? Thanks! Jeroen |
| ||
well simply check if the balls Z is higher than the one of the bat. If it is, check if its X and Y is within the size and location of the bat. additionally you culd add some drift, depending on the motion speed of the bat. This would work completely without collisions. 2: that's a tricky problem. If your camera switches to the other side, you can invert the x motion of the pad, but when the cam flys around like in a matrix scene, that's no good for the controls. |
| ||
thanks! The problem is that the bat rotates based on user input. So, that makes it more complex. |
| ||
Blitz has only sphere to something collisions, so perhaps you could check for other libraries or dll's like coldet... |
| ||
Blitz has only sphere to something collisions It's a Pong game... he only needs sphere-to-something! |
| ||
It's a Pong game... he only needs sphere-to-something! Except when the bat moves into the ball. ;) |
| ||
There is some code in the archives which uses blitz collisions and will always produce the correct response .. In fact this would be perfect for you .. http://www.blitzbasic.com/codearcs/codearcs.php?code=898 |
| ||
http://www.blitzbasic.com/toolbox/toolbox.php?tool=11 http://www.blitzbasic.com/toolbox/toolbox.php?tool=49 |
| ||
Except when the bat moves into the ball. ;) Bizarrely I did a Pong clone ages ago and it uses only one Collisions command (sphere to poly) for ball to bat collision and it works perfectly... I mean I've tested and tested it and can't make it fail. Yet when migrate the code to any other context, I start to see the normal OMG!-Two-Moving-Things!-Help-Me! Blitz problems with collisions not being caught - which is a shame as I was going to post it but there's no point now. |
| ||
Sledge, I'm guessing that probably worked in your Pong game because the ball is constantly in motion so blitz can always see collisions as ball-to-bat. Just a guess, though. |
| ||
Well I tried isolating it from the game to post and it just doesn't work reliably - I think I must've got lucky with the relative dimentions of the objects and the speeds/angles at which it is possible for them to collide. It's not applicable in general, though, so your earlier statement stands. |