You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I’m creating a melee system and recently have thought of parrying, I don’t know how to execute this or if there is any other better methods to make it.
What is the issue? Include enough details if possible!
How can I make this direction based? Is there a better way to make something like this? No tutorials have helped so far.
What solutions have you thought of so far?
I’ve thought of making it so an attribute is enabled when inside the parry window and if an enemy player hits the player inside the parry state, then it causes the other user to be stunned.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
you’d use dot product checks. here is an example usage
local Parryer = charactergoeshere
local Attacker = charactergoeshere
local AttackerPosition = Attacker.PrimaryPart.Position
local ParryerPosition = Parryer.PrimaryPart.Position
local Difference = AttackerPosition - ParryerPosition
if Diff.Magnitude == 0 then
return
end
local myLookVector : Vector3 = Parryer.PrimaryPart.CFrame.LookVector
local diffUnit = Diff.Unit
if myLookVector.Magnitude == 0 or diffUnit.Magnitude == 0 then
return
end
local dotProduct = myLookVector:Dot(diffUnit)
dotProduct = math.clamp(dotProduct, -1, 1) -- clamp to ensure no errors
local Angle = math.acos(dotProduct) -- returns radians, so be careful
local Parried = Angle <= math.rad(PARRY_ANGLE_IN_DEGREES)
-- Now do something with parried! Yaaay
if Parried then
print("parried")
else
print("not parried u suck!!")
end