Judging the intersection point of moving objects

Blitz3D Forums/Blitz3D Programming/Judging the intersection point of moving objects

I dunno if this will help you at all, but that is the sort of problem I was working on at one point in my tank game:

			; Calculate if any bullets will hit this player.
	
				Px#  = EntityX#(ThisPlayer\Avatar, True)
				Py#  = EntityY#(ThisPlayer\Avatar, True)
				Pz#  = EntityZ#(ThisPlayer\Avatar, True)

				PVx# = ThisPlayer\Vx#
				PVz# = ThisPlayer\Vz#

				PSpeed# = Sqr#(PVx#*PVx# + PVz#*PVz#)

				Bullet_Will_Collide = False
		
				For ThisBullet.Bullet = Each Bullet			

	
					Bx#  	= EntityX#(ThisBullet\Avatar, True)
					Bz#  	= EntityZ#(ThisBullet\Avatar, True)
					BVx# 	= ThisBullet\Vx#
					BVz# 	= ThisBullet\Vz#
					BSpeed# = Sqr#(BVx#*BVx# + BVz#*BVz#)	


					; Check to see if the bullet's path intersects the computer's path, and calculate where.
					If Lines_Intersect(Px#, Pz#, Px#+PVx#, Pz#+PVz#, Bx#, Bz#, Bx#+BVx#, Bz#+BVz#)


						; Are both objects heading towards the point where their paths intersect?
						If (Intersection_AB# >= 0) And (Intersection_CD# >= 0)


							; Because the length of the line segments is equal to the distance that the entities will travel
							; over a period of 1 second, the realtive intersection points tell us the time which each entity
							; will reach the collision point.  Ie, if Intersection_AB# is 1.0, then the computer will reach
							; the intersection point in exactly one second.


							; Will the computer reach the intersection point in the near future?
							If (Intersection_AB# < 2.0)
			
				
								; Calculate the difference in the arrival time of the two entites at the intersection point.
								Arrival_Time_Diffrence# = Abs(Intersection_AB# - Intersection_CD#)
				
					
								; Will both entites arrive at almost the same time at the intersection point of their paths?
								If (Arrival_Time_Diffrence# < 2.0)
												
								
									; It's very likely that the computer is going to collide with the bullet if it keeps
									; moving in this direction.
						
									;EntityColor ThisPlayer\Avatar, 0, 255, 0
					
									Bullet_Will_Collide = True	
					
								EndIf
					
							EndIf		
				
						EndIf				
					
					EndIf			
											
				Next



Some thoughts:

For each point along the player's line of motion, there is a time it takes for the player to get there.

And each those points will also have a time for the bullet to get there.

You need to find the point where these two times are equal.

You need to find the point on the line which the player and bullet will be at at the same point in time.