#Method for hitbox detection
1 messages · Page 1 of 1 (latest)
** You are now Level 3! **
Hitbox:destroy()
People tend to use raycasts as they're the most reliable
This library (which is the successor to Raycast hitboxes) may help: https://devforum.roblox.com/t/shapecasthitbox-for-all-your-melee-needs-v025/3624241
This module is the successor to my previous team’s RaycastHitbox: For All Your Melee Needs. Each library has unique features, so I recommend reading both to determine which one best suits your needs. In summary, ShapecastHitbox offers the following advantages over RaycastHitbox: Shapecasting (Blockcast, Spherecast, Raycast) Performance impro...
a problem ive run into with using raycast is that it only will be able to detect one player, not sure if there are ways around this so please lmk if there are
use spatial queries like workspace:getpartsinbox/sphere/etc
i'd suggest avoid using getpartsinpart to save creating an instance, unless the hitbox should last for several frames in which case you can also use .touch
or just use a spatial query every frame
up to you 🤷
what im currently doing is filtering through a list of parts tagged damagable, and checking if relevant parts are inside the box, im not sure if this is more or less efficient, i kinda feel like its less
function Punchingv1:Create_boundB(HumanoidRootPart: BasePart)
local boundBoxSize = Vector3.new(6,6,5)
local localboundBoxOffset = HumanoidRootPart.CFrame * CFrame.new(0,0,((boundBoxSize.Z/2)+0.7)*-1)
-- Visualization (for debugging)
local visual = Instance.new("Part")
visual.Name = "PunchDebugBox"
visual.Size = boundBoxSize
visual.CFrame = localboundBoxOffset
visual.Anchored = true
visual.CanCollide = false
visual.Transparency = 0.5
visual.Color = Color3.fromRGB(255, 0, 0)
visual.Material = Enum.Material.ForceField
visual.Parent = workspace
game.Debris:AddItem(visual, 0.2)
return localboundBoxOffset, boundBoxSize
end
local boundB,BoundBSize = self:Create_boundB(hrp)
local charHit = {}
local damageables = collectionService:GetTagged("Damageable")
for _, model: Model in pairs(damageables) do if model == char then continue end
for _, part:BasePart in pairs(model:GetChildren()) do
if part:IsA("BasePart") and damagablesParts[part.Name] then
local partRelative = boundB:ToObjectSpace(part.CFrame)
if math.abs(partRelative.X) <= BoundBSize.X and math.abs(partRelative.Y) <= BoundBSize.Y and math.abs(partRelative.Z) <= BoundBSize.Z then
table.insert(charHit,model)
break
else
continue
end
end
end
end
that's absolutely, utterly insane.
😭
very bad and you should feel bad
...
ok so it was insane and i do feel bad
I started an M1 system today and I use a spatial query every frame like pyro said
Works well I suggest that
Wym every frame
im making an M1 system, every frame of the punch animation i need it to deal damage if a player is inside the hurtbox
so i use a spatial query to add players into a list to do damage to them
why not use a single frame for ur hit detection?
when moving around if you only use a single frame it might be a bit hard to hit
i use a heart beat connection and a spatial query so say i move around alot it spawns hurtbox parts and stores any players it touches in the list once
then deals the damage
its more dynamic and handles movement better
some attacks last for multiple frames like a wide sword swing will likely have multiple frames where it should be slashing for aoe radius, and it takes a few frames for the full swing to complete, so you'll need to do a query for every frame it should be damaging
or .touched
yeah but that can take a lot of server performance
wouldnt it be better to do a stud buffer instead?
Thats true but u can also compensate with a stud buffer
i also want to know the best method so im very open to your ideas
i don't think you know enough about programming to be making any statements about performance
most people don't
what is stud buffer
Increasing hitbox range by a few studs than the weapon visually shows
that's not much of a compensation, it's just making the hitbox bigger
Rank in this server doesn't mean everything. It's common sense though that an active frame check will be more expensive than a single frame check.
you can do some compensation with 2 hitboxes like that but it's complicated as to how you would actually use it
Yes making it bigger will allow more leniency with its hits
Deepwoken does this
i doubt deepwoken does this
it might do the compensator but it probably doesn't just broadly make the hitbox bigger
it's complicated why you might want to use 2 i'm not going to go into it right now
but it's not as simple as just a bigger hitbox
haven't played deepwoken so i can't say for certain but if they've done their homework they probably have a prediction system with rollback
compensator helps make this more accurate, less prediction errors. but again can't say for certain, just as much as you cannot
we don't have access to deepwoken source code.
They actually do if u go into the game u can see the hitbox is extended
i refuse to pay for it
No we don't but I had a friend who somehow got a copy of the game
they didn't "somehow" get a copy, they probably stole it with a decompiler
I can assure u it's extended
That doesn't steal server code unless I'm wrong
correct, only client and shared code no server code
pretty obvious tell how they got it if theres no server code
if they do have server code then 🤷 they might've attempted to reverse engineer it based on client code
still huge job
why bother when you can just make your own
They got the server code as fir how I don't know but they told me it's a server side hitbox
Your guess is good as mine
so they do it the tsb way then 
just completely ignore prediction and do everything on the server, input lag be damned
It works out for them it seems
clearly
I would like some advice on prediction
Since I use server side hitboxes is there any benefit to me using cached positions in my checks
the full prediction pattern is very difficult to do
i'd suggest waiting for roblox to release their auroraservice instead of trying to make one yourself
I guess I should follow deepwokens footsteps then huh? 😭
for now
i'll be adding the full prediction pattern to my framework
coz i don't have the luxury of 50 ping on 99% of roblox games
lag compensation and prediction go hand in hand but they are different concepts
lag compensation is usually called rollback netcode, prediction is where clients predict what the server is going to do before the server responds, sometimes this prediction is incorrect aka misprediction so you get jitter and other visual errors like that
like your character can teleport if big misprediction
I see ty for clarifying it
if you've played any source engine games like csgo, gmod or tf2 you'll have experienced the full prediction pattern
Yes, where they teleport you back due to a ping spike
Yes
or if your code is wrong it will mispredict as well
I assume that's where the usefulness of caching positions comes in for movement predictions
but under normal circumstances with minimal packet loss no one will notice
it's not just a cache ;o
much more involved than that
Yes ik what u mean
I considered doing predictions for my dashes but I realized it would take a lot more math than I thought
anyway i got things to do
Yeah man thank you for your time
alot of games inflate hitboxes to make it feel more responsive, take overwatch for example
personally though say im punching i would want hurtboxes to spawn that catch the player inside
you may see a game like brawlhalla do this and i think its alot better for games with alot of movement
So my current takeaway is to use spacial queries and look into rollback for hitboxes or prediction systems to compensate for ping, that sound about right?
roll back requires from my knowledge you to store every players position look vector rotation then states like blocked dodged stunned attack
then to calculate on the server depending on their ms if they should have hit or not
basically dont bother with rollback until your S3-4 or roblox adds something to make it easier
theres probably an easier checklist to make sure your combat feels good
ive made a fsm system for every player int eh game already, so im able to easily fetch and store things like states, im guessing the only thing i would need is to store positions and vectors to sanity check whether the other player should have been hit right?
im not sure on optimization and preformance, i just want to see if im understanding how they work
im honestly not the most educated on the topic but i think alot of the complexity will come from juggeling things like players ping
how do you determine how far back to go
would depend on how high their latency is i imagine but easier said then done
if you want to give it a shot ofc
then the actual rollback
i think making it look and feel nice is also quite the challange
Are there any popular games that use rollback?
Is that a method that only client side hitboxes benefit from or also server side?
pyro listed a few but ill add Rainbow six siege as i use to play it alot
if youve ever played high ping and had a hit rejection thats why
oh apparently also OW call of duty and valorant
seems like the industry standard tbh
i see, is imore for a system for shooter games, or does melee combat also benefit from this? Also what are your thoughts about the benefits for server vs client?
Street Fighter 6, Guilty Gear Strive, Skullgirls, Mortal Kombat 1 also use netcode rollback
i would always recommend the server as the one with authority
idk if there is any benefits for doing it client side
potentially responsiveness but it doesnt weight well against the cons
Sorry i didnt clarify, i mean for using a rollback system
the only type of rollback i know uses both
client predicts
it plays say the punch
then on the server it calculates if that punch should have landed
idk of any client specific rollback systems
if the server were to initiate the animation through server side validation, would it still benefit from a rollback?
in other words, if the client didnt use any prediction
if it didnt use any prediction imagine it like this
you have high ping and you shoot or hit someone
it wouldnt play any animation to begin with as it wont predict if you did or didnt hit them
then the server would calculate what should have happend rollback if need be and apply the hit
so it would look a bit off especially at higher pings
imagine shooting someone then say 0.3 seconds later you see the shot hear the shot and get the kill
i guess vise versa would be if it predicts against what you experienced you may feel cheated out
you saw your shot landed but the server said it didnt
I get that but in a timing sensitive system, its difficult to replicate this either way
i can see how this benefits input _> instant attack
ah like stringing a combo
yeah that would be very difficult to implement in a tight frame combo
yeah i get what your saying
if street fighter and mortal kombat can use client side prediction and rollback then im sure its somehow possible
street fighter attacks are usually instant/ almost instant
also we have to look at the perspective of all players not just the attacker
if the attacker uses client side prediction, the server will recieve the attack while the client's animation is already somewhat progressed
it uses charged moves and i think if anything would be a real challange it would be combos
especially mortal kombat where you can frame skip i think its caleld
yes which means the worst outcome is it plays but the player doesnt actually get the hit they saw
but thats more fair than the alternative
no, the player that got hit will be facing a delayed hitbox, making it difficult to time/parry according to the animation
** You are now Level 10! **
thats why client prediction for these systems is so rare
i mean if one of the biggest fighting games of all time is using prediction in their rollback they must have been able to implement it pretty well
im not saying prediction is useless for rollback, but it's pretty difficult to implement in this kind of scenario
especially with roblox's engine
perhaps if there methods to prevent replication from some client animations it would be infinitly more possible
well if pyro fire thinks roblox will add some service to make it easier maybe in due time itll be possible for your average developer
Hey, i was wondering if i could get some advice on this: My combat framework sends requests to the server to attack where the server validates it with a hitbox. It doesnt use prediction and is a melee system. Should i use a rollback system for it?
honestly
if your new to it and just want a working game i think theres more pressing matters that can make your combat feel better easier
lower hanging fruit
if you want to specifically for the fun or experience or have made combat games before and want a step above go for it
I currently have one implemented, so I was wonderign if its worth keeping. Do you have any advice for making it feel better in general?
I make the hitbox slightly bigger than visuals so its more consistent too
Im also considered about the scalibility for my polling:
RunService.Heartbeat:Connect(function()
for character, rollCharacter in pairs(self.HRPCache) do
rollCharacter:Record()
end
end)
this polls the positions of the roots
not really honestly
a generous hitbox can help
well sycned with the animation
you want at a certain stage for it to remove old history
so 500 ms ago is quite unrealistically needed as idk anyone who constantly has to play on 500ms
i think the heavy top end that should be accounted for is 300
so you need say 350ms worth of history saved then after that remove it
or your table will grow and grow
you could try storing only the root
- cframe
- velocity
- maybe rotation or a look vector
instead of the entire character
also you dont need to store every frame
i would try find a nice balance where its accurate but your not oversaving data whatyou dont need to
I do around 250 ms of history
Do you mean not really to keeping the rollback system or advice for improving a hitbox?