Top down shooting rendering[SOLVED]

So, I was going to make the shooting for my game. Then, I recalled that moving a bullet is unreliable, as it could be moving so fast, that it passes the target in 1 update frame, never touching it. So I need a new shooting system, that looks just like this:

xlM2XDPsF_0

How would I do the streak of light and hit the target? I know I am being vague, but If you understand what I’m asking, please help!

2D Raycasting.

^^^^

Which you can do with a regular bullet, as well. Basically just draw an invisible line from the origin to the end point, and check if anything touches that line. Then move the bullet to the closest collision.

Googling always helps.

Well if are going to use a projectile instead of a ray, I’d recomend you to use jbox2d and if you are using LibGDX then it’s perfect because jbox2d is already built-in the library

Not jbox2d, the original box2d :slight_smile:
Box2d supplies collision detection specifically for bullets, with the bullet boolean in BodyDef.

well you can raycast it then tell everything on the x/y it intersects to perform a function such as losehealth(int/float/double etx)