PDA

Click to See Complete Forum and Search --> : Collision Detection.


Terrell
Sep 8th, 2000, 01:38 AM
I need to know the fastest and most optimized way to detect 3D objects in DirectX IM. Are there any good tutorials around to explicitly learn about collision detection? If so please tell me. If not and you do know how to detect collisions please tell me also. Thank you.

Sep 8th, 2000, 06:47 PM
ok,

well, i don't know about the first one, and i don't know if this is the answer youre looking for on the second one, but i detect collisions using this code:

(i don't know how to make that code thing, please tell me!)

Public Sub LaserHit()

If z = 1 Then GoTo 12

If Laser.Left >= guy.Left And Laser.Left <= guy.Left + guy.Width And Laser.Top <= guy.Top + guy.Height And Laser.Top > guy.Top Then
MsgBox "you hit him"

z = z + 1
12

End If
End Sub

thats the basic code i use, hope thats what youre looking for, but if anyone else out there knows, and i know you do!, how to change the picture each time the laser hits. up to four times? thanks:)

KENNNY
Sep 9th, 2000, 06:53 PM
but he needs 3d collision detection, which is harder..

btw, your collision detection thing could be better by saying

if Laser.Left < guy.left Or laser.left > guy.left + guy.width ..etc Then

'NOT HIT

else

'HIT

endif

using Or means that if an early check fails (say if laser.left is bigger than guy.left) then the other parts of the If arent checked, making it faster. not much, but a little :)

HarryW
Sep 9th, 2000, 07:58 PM
Actually I'm pretty sure that both logical statements are checked every time in VB. In C and some other languages it's like you say Kennny, but VB does it the long and crap way.

KENNNY
Sep 10th, 2000, 04:04 AM
im pretty sure i read that VB can do shortcuts..i know its language specific, but I thought VB supported it. anyone know 4 sure?