How do I go about making a parry with a sword

I’ve been having ideas of making a LOTR style game and making it open world where players go on their own adventures. I would like to make a good pvp system and for that I’m looking at raycasting for the solution. However, can raycasting help with detecting parries? Or should I just use the click mouse2 button and you’re basically invincible?

1 Like

Just use region3s for the hitboxes, and make a function within a module with parameters for the size of the hitbox, how long it should last, and if it should update to keep staying in front of the player, etc… as well as a table to store the players in + a delay time of when they should be removed. i know raycasting is a good solution for combat, i think? i’ve seen some stuff on it, so it looks cool… for the parrying part, when the player is blocking, always have something run alongside the code when it blocks for like a delay as shown below…

--keep in mind this is just an example for the most part, this is how i would go about it, maybe..? this is also just a draft so excuse any errors i make / malpractice.
local basic_attacks_module = {
    ["Block"] = function(player, ParryTime)
        local Settings = player.Settings;
        local isParrying = Settings.Parrying;

        isParrying.Value = true;

        delay(ParryTime, function()
            isParrying.Value = false
        end)

        --other code here ...
    end
}

return basic_attacks_module;

as for the parrying part, inside the hitbox, make a function for if the parrying value is true within the player being attacked, then run something instead of doing damage?

2 Likes

Speaking of raycasting, it exists:

Parrying effects would probably be when one hitbox hits another, as in the solution above.

Yeah, that’s the one I’m using. Thanks for reminding me