Bullet collisions

I need help/tips on creating a semi-accurate bullet collisions

Currently I only have this piece of code that checks for collisions or not

local collision = workspace:Raycast(bullet.Position,bullet.CFrame.LookVector,rParams)

if not collision then print("NONE") task.wait() continue end

print(collision.Instance)

I have tried using workspace:GetPartsInPart(bullet) and its not accurate as well so I really don’t know how to do this
Screenshot 2023-10-15 111009

2 Likes

I’m not sure if this will fix your problem, but have you tried typing this instead?

local collision = workspace:Raycast(bullet.Position, bullet.CFrame.LookVector.Unit * [bulletMaximumRange], rParams)

Also why didn’t workspace:GetPartsInPart(bullet) work for you? Why is it not accurate?

workspace:GetPartsInPart() only works sometimes, let me get a footage of it

Heres a video of the thing not working, seems to work in some occasions but sometimes it isnt
https://streamable.com/plb76b

1 Like

You’d have to show the code behind that to really demonstrate why that was happening. I’ve used workspace:GetPartsInPart() for my projectile hitboxes and it worked fine.

my bad, here’s the code

1 Like

further observation, its only detecting the humanoid root part :thinking:

1 Like

Did the same happens when the NPCs were close to you?

And also, have you tried using the .Touched event with a loop that keeps fixing its position? As I’ve explained in the solution of my first post, the loop is able to make the .Touched event become accurate for some reason, but I’m not sure how it would be for high speed projectiles.

Does the other parts of the NPCs have CanTouch on?

Nevermind, I just remembered that that method detects parts independently if they have CanCollide or CanTouch on.

seems to
Screenshot 2023-10-15 120242

does CanQuery have something to do with this? Only the HRP has that property turned on

I don’t really know, you should try turning their CanQuery on and testing. Before saying anything about that test, you should also try the other solution I’ve suggested using the .Touched event.

I think the workspace:GetPartsInPart() was the right choice, .Touched seems to not output anything

Only real problem I’m encountering with the collision checking is for far away distances, could be my trash aim since it works 100% of the time on close ranges so idk, I’ll mark it as the solution though thx!

If it works on close distances, it probably is related to the direction the projectile is going to, so you should also check if your projectile is not going down or something too. But yeah, I’m glad I helped, good luck!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.