(sorry for bad english)

I'm making 2D arcade game. I write all of physics stuff myself. The problem involves bullet behaviour. Imagine bullet flying towards some entity. If the bullet's velocity is relatively high and the entity is small, the bullet passes right through the entity which is obviously not what it's meant to do. Here's the gif that shows why that happens (values are exaggerated to better show the process): gif created with paint & gifcam
As you can see bullet's velocity is simply bigger than the size of the entity. Then I came up with this: dem paint skills tho
Getting point of impact coordinates means I can check if the distance between the point of impact is smaller than the bullet's velocity. If the distance is smaller then bullet should collide with the entity at the point of impact. But I don't know how to calculate the coordinates of the point of impact. Pls help.


First calculate the line equation (the laser direction)

<x,y,z> = <x0,y0,z0> + t*V  (1)

where V is the direction Vector, and is the a known position of your bullet.

Second calculate the equations of each side of your entity,

the intersection would be the point that satisfies (1) and one of the rectangle sides equations


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.