Best Option for Bullet Hit Register

Hello I’m current working on my fps framework, but I don’t know the best way to make hit detection for bullets.

Currently I’m using raycasting for bullet hit detection:

local hit = game:GetService("Workspace"):Raycast(bullet.Position, bullet.CFrame.LookVector * self.velocity, self.raycast)

It makes a ray and the length is the bullet velocity.

With this there are some hit register issues, so I’m wondering if there is a better way of making bullet hit register or maybe I already got the correct idea but I executed it incorrectly.

Any help or feedback would be greatly appreciated!

please do not suggest FastCast, I already tried it, it’s good but I’m trying to make my own system

1 Like

I remember a post about deciding what tools are great for hitboxes. In short answer, use Touched event. For long answer, it’s here:

1 Like

It’s… in the title… That’s for melee. For long-range weapons such as bullets, use FastCast.

2 Likes

Touched with bullet isn’t really a good idea, I just tested and basically none of them registered as a hit.

1 Like

If it’s your first time making guns, just use hitscan (raycast) bullets. They already get challenging enough and projectile bullets would cause even more issues.

No, this is not my first time, I’m updating the bullet position every frame. I already got everything sorted out but I’m trying to find what is the most efficient way to do bullet hit register.

If I were to make that, I would probably start by making bullets without any drop and just raycasting from the bullet every frame with the ray’s length being deltaTime * speed.

Your missing the point here, I’m trying to know what is the most efficient way to make bullet hit register, not how to make bullets.

1 Like

As I just said, use raycasts for the hit register. Every frame, do a raycast from the bullet with the ray length equal to deltaTime * speed. This should work.

speed * dt breaks the hit register, and also that is close to my current way of doing hitreg.

I would HIGHLY recommend, cannot emphasize enough, FastCast:

as @PysephDEV has already suggested. FastCast already has integrated piercing and allows for easy ricochet. If you are interested in making your own module, I would suggest looking at FastCast anyways as it uses a combination of raycasting as well.

Side note: If you do a single raycast for your fps framework, you will have no bullet arc or drop as it is a single, straight ray.

For further hit detection info, please see:

I have found it very useful when making my own FPS framework.

Bumping the post a bit here since I just got back to reading this

If you want a really simple solution without having to use some sort of external module like FastCast, you can just raycast between the bullet’s current position and it’s next position when you update the new position - I do this for my game’s spells, since I feel like using FastCast is an overengineered solution to something I don’t want to overcomplicate.

Isn’t that basically what fastcast does? just in multiple steps before each teleport?
FastCast’s api is a little strange. I was looking for something similar to FastCast for my own game, but I ended up just writing my own thing.

Yes and no. FastCast divides the whole trajectory / path the projectile should be going in and calculates the hitbox based off that, meaning you never input any object - this makes it annoying because it pretty much forces you to have bullets on client, causing a lot of other unecessary issues.
I’ve never used FastCast due to how overengineered it’s API is - it just seems like a niche developer tool for me.

1 Like