Can this be used for static hitboxes? (where the hitbox is more of an AoE)
You would probably be better off handling AoE on the server, as there is not much benefit in doing this on the client.
So the module is capable of detecting the hit without the hitbox moving?
No. This module functions by raycasting from the hitbox’s current position to the hitbox’s last position - if the hitbox didn’t move, it would not work because raycasts cannot have 0 magnitude.
Oh, alright. What would be a reliable alternative to doing an AoE attack then? I heard part.Touched was pretty bad so I’d rather not use that.
You could use the new spatial query API:
Additionally, you can just loop over all players in-game and find which ones are close enough.
Didn’t even know this existed. Thanks for the ideas!
Sorry to bug you once more, but how would I go by using this module without a weapon? Could this be implemented into a roblox character’s arms for fist combat?
Yes, you can use Caster:SetRecursive(true)
to have ClientCast check the whole character model for any hitbox attachments. From there, just put DmgPoint
attachments inside each arm.
local Caster = ClientCast.new(PlayerCharacter, RayParams)
Caster:SetOwner(Player)
Caster:SetRecursive(true)
See Caster:SetRecursive for more info.
Your UpdateAttachment calculation is a ray from the current position to the last position, but if the projectile is moving too fast and there are 2 parts between the current position and the last position, it will count as it hit the part near the current position , which made it look like the projectile would throw the first part in the player’s field of view and hit the second part. So I changed the UpdatedAttachment() function slightly, which makes it more suitable for quick projectile:
local function UpdateAttachment(Attachment, Caster, LastPositions)
local CurrentPosition = Attachment.WorldPosition
local LastPosition = LastPositions[Attachment] or CurrentPosition
if CurrentPosition ~= LastPosition then
--local RaycastResult = workspace:Raycast(CurrentPosition, LastPosition - CurrentPosition, Caster.RaycastParams)
local RaycastResult = workspace:Raycast(LastPosition, CurrentPosition - LastPosition, Caster.RaycastParams)
UpdateCasterEvents(Caster, RaycastResult)
end
LastPositions[Attachment] = CurrentPosition
end
I hope this helps you and thanks for the ClientCast system, it helped me a lot : )
Hey, yeah this behavior makes more sense - ClientCast seems to currently raycast from the current position to the old position, when it’d make more sense to raycast from the old position towards the current position (same vector, but opposite directions).
Update 1.0.8.2
- Raycasts now start from the old position and go towards the current position, rather than starting from the current position and going towards the old position. cc @ProHandsomeGod
Every time I unequip my weapon I get this error.
I have no code written that does anything to the caster when unequipping. I’m completely clueless on how this happens.
Hey! thanks for showing this. I have updated the script, could you update your ClientCast module to the latest version and see if this error has been fixed? Thanks!
Updated to the latest version. It works now. Thanks!
How to use module, please help
This text will be blurred
Is there anything specific you are stuck on? I can’t help much if you don’t explain your issue.
I am making a fists tool with this that has a left and a right punch. I want to make this so there are two different hitboxes depending on which punch animation is being used, so I’ve created two casters and I start and stop an individual one when they’re needed. However, both casters seem to start when I intend to start only one. Is the module not supposed to be used like this, or is there a workaround?
This seems like an issue with your code. I’m not able to help you further without seeing a decently large snippet of code, but from the information at hand, it shouldn’t be an issue with the module.
What are the benefit’s for me switching to this module? Is it better for the user experience if its client side instead of server? For example, this is my current server side code for hitboxes. It might be bad but it does the job alright.
local ServerSideHandler = coroutine.wrap(function()
while task.wait(0.009) do
for i,v in pairs(AllRunningHitBoxes) do
local player = v.player
local playercharacter = v.player.Character
for i,v in pairs(workspace:GetPartsInPart(v.hitboxpart)) do
if not v:IsDescendantOf(playercharacter) then
if (tick() - PlayerStates[player.Name].M1Frame) > 0.4 then
print("hit")
PlayerStates[player.Name].M1Frame = tick()
end
end
end
end
end
end)
ServerSideHandler()