I want to achieve a fast hit detection for any hitbox, large / small
So the issue is, the detection isn’t that fast, or it wont detect at all…
I spent like 5 hours looking over things / testing, Ive tested “FastCast”, it doesnt work because its not a bullet, some abilities have larger hitbox, Region3, .Touched, Raycasting, Ive tried so many things, I also tried Server Creates the hitbox → Client gets the .Touched → Fires back to server, So the client would have a faster reaction for the hitbox, also didnt do much.
I would just love an idea on how to go with this, what would be best for detecting a hitbox for projectiles!
I don’t know if this is the most efficient but you could use :GetTouchingParts in a while loop while it exists or when it changes position, you could also create a invisible part to act as the :GetTouchingParts hitbox
Use raycasting with some math if you want travel time, using any form of .Touched will ultimately end up with bullets phasing through parts due to frame delta and how the physics engine works.
This object simulates a object moving along a trajectory. Every frame, call :update() and fire a ray from the old position to the new position. This trajectory has bullet drop built in, you can remove that and just keep the travel time though
function trajectory.new(initial, velocity)
local self = setmetatable({},{__index = trajectory})
self.position = initial
self.velocity = velocity
self.tracing = false
self.tracetype = "interface"
self.start = tick()
self.t = self.start
return self
end
function trajectory:update()
local dt = tick() - self.t
self.t = tick()
self.position = self.position + (self.velocity * dt)
self.velocity = (self.velocity + .5 * Vector3.new(0,-1,0) * dt)
end
Are you just trying to find the area which a projectile can affect? Like for example a grenade or shotgun spread or something? If so you could probably get away with just using .Magnitude from a central point.
What am trying to accomplish here is, the best way to make hitbox for ranged attacks for examples spells, that uses a Part as a HitBox, but i want something that can be a accurate