What I’m hoping to achieve is to give the player the ability to perform air juggling combos whilst on the ground. A similar effect would be the Yakuza games, this video would be an example of what I’m talking about: https://www.youtube.com/watch?v=rsy4Ke4je4Y
The issue is that I don’t know how to really approach this. The only rough idea I have so far is this:
If the player’s opponent is on the ground, all that happens is a simple knockback with the BodyVelocity.
If the opponent is caught in mid-air however, maybe I can set the Velocity to something like Vector3.new(0,15,0)
To detect when the player is in the air, I’m thinking of using attributes.
Yeah, I would say this is about accurate. One thing to note, however, is that BodyVelocity is deprecated. Use LinearVelocity instead.
I don’t see how attributes would help with this. Shouldn’t your air detection be within the same script you’re using for combat? Also, an easy way to detect if the player is in the air is to check if Humanoid.FloorMaterial == Enum.Material.Air. You could also check if Humanoid:GetState()== Enum.HumanoidStateType.Freefall or Enum.HumanoidStateType.Jumping. Lastly, you could perform a custom raycast to below the character to check if there’s anything directly beneath them.
You could use LinearVelocities as we discussed above, or you can try :ApplyImpulse or directly modifying the AssemblyLinearVelocity. I’m not sure how much the physics engine would like the latter method, though.
I have made the switch from BodyVelocity to LinearVelocity.
It appears that increasing the size of the Hitbox on the Y axis seems to push the opponent upwards, regardless whether or not they’re on the ground or not.
Keep in mind I am using modules.
--///Script calling the Hitbox module\\--
local HitboxSize = Vector3.new(4,8,4)
local HitboxCFrame = HRP.CFrame + (HRP.CFrame.LookVector * 1.5)
local EM_Humanoid = HitboxUtil.GetPartsInBoundBox({Character}, HitboxCFrame, HitboxSize, "Humanoid", false)
--These are the paramets on HitboxUtil.GetPartsInBoundBox
function HitboxUtil.GetPartsBoundInBox(FilterDescendantsInstances, HitboxCFrame, Size, ReturnInstance, ReturnMultipleInstances)
--//States Module\\--
--Knockback
local RaycastParameters = RaycastParams.new()
RaycastParameters.FilterDescendantsInstances = {Character, Attacker}
RaycastParameters.FilterType = Enum.RaycastFilterType.Exclude
RaycastParameters.IgnoreWater = true
local Floor_Raycast = workspace:Raycast(HRP.Position, -HRP.CFrame.UpVector * 3, RaycastParameters)
if Floor_Raycast then
if Attribute_AttackerM1 < 4 and Combo then
BodyMoversUtil.create_LinearVelocity("Knockback", HRP, 10000, -HRP.CFrame.LookVector * 1.25, 0.1)
else
BodyMoversUtil.create_LinearVelocity("Knockback", HRP, 10000, -HRP.CFrame.LookVector * 37.5, 0.1)
end
else
BodyMoversUtil.create_LinearVelocity("Knockback", HRP, 10000, Vector3.new(0,50,0), 0.025) ---For air juggling
end