Boost going further in air (VectorForce)

local Knockback = {}

function Knockback:ApplySelf(plr)
	local humrp = plr.Character.HumanoidRootPart

	local Attachment = Instance.new("Attachment", humrp) 

	local VectorForce = Instance.new("VectorForce") 
	VectorForce.Force = Vector3.new(0,0,-10000)
	VectorForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
	VectorForce.ApplyAtCenterOfMass = true
	VectorForce.Attachment0 = Attachment
	VectorForce.Parent = Attachment
	
	game.Debris:AddItem(Attachment, 0.4) 
end

return Knockback

I know it has something to do with friction or whatever, but is there a workaround? Or some other boost I can use. I tried linearvelocity but I want the boost to constantly go towards where I’m looking while it’s active.

2 Likes

You could try reducing the time when the humanoid is on air

-- get humanoid
if humanoid.FloorMaterial == Enum.Material.Air then
game.Debris:AddItem(Attachment, .2)
else
game.Debris:AddItem(Attachment, .4)
end
1 Like

That worked for when the player uses the attack mid-air, but it still boosts further when they jump mid attack.

How about you try using BodyVelocity? Maybe they can help you a bit more

    local bv = Instance.new("BodyVelocity")
	bv.MaxForce = Vector3.new(1,1,1) * math.huge
	bv.Velocity = Vector3.new(0,0,-100) 
	bv.Parent = humrp
	
	game.Debris:AddItem(bv, life)

I tried this code but it’s going straight forward and not turning with the direction i’m looking at

Using a velocity controller instead of something that applies force is correct because you need to overcome the forces the character controller applies.

BodyVelocity is depreciated, but if you wanted it to go in the correct direction you would continuously set bv.Velocity to be HumanoidRootPart.CFrame.LookVector * 100 (probably using a connection to RunService.Heartbeat).

It’s easier (though not necessarily simpler) if you use a LinearVelocity. Here are some directions:

  • Create an attachment parented to the humanoid root part
  • Create a LinearVelocity
  • Set LinearVelocity.Attachment0 to the attachment
  • Run LinearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
  • Set LinearVelocity.VectorVelocity to Vector3.new(0,0,100)
  • Destroy (or disable) the LinearVelocity when you want the dash to stop
1 Like

It actually worked this time around

function Knockback:ApplySelf(plr, life)
	local humrp = plr.Character.HumanoidRootPart
	
	local Attachment0 = Instance.new("Attachment", humrp)
	
	local LinearVelocity = Instance.new("LinearVelocity")
	LinearVelocity.MaxForce = math.huge
	LinearVelocity.VectorVelocity = Vector3.new(0,0,-100)
	LinearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
	LinearVelocity.Attachment0 = Attachment0
	LinearVelocity.Parent = Attachment0
	
	print("Bout to delte")
	game.Debris:AddItem(Attachment0, life)
end
1 Like

why not use RootAttachment as Attachment0?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.