What is the issue? Include screenshots / videos if possible!
Putting the position of a bodyposition mover to Vector3.new(0,0,-30) will simply make the humanoid rootpart move -30 degrees on the z axis and not propel the character forward at times.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried to use bodyposition but simply placing the position’s vector3 value to -30 does not propel it forward. I tried to use the LookVector of the HumanoidRootPart’s CFrame, but it makes me go sideways sometimes and forwards other times. Any help is appreciated.
local TweenService = game:GetService("TweenService")
local humanoidrootpart = 0 --path.to.root.part
local speed = 40
local _time = 0.4
local walkspeed = 16 -- assumed 16
local function dash()
local velocity = Instance.new("LinearVelocity")
local attachment = Instance.new("Attachment")
local movement = nil
attachment.Parent = humanoidrootpart
velocity.Attachment0 = attachment
-- if you want them to be able to turn
velocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
movement = -Vector3.zAxis * speed -- fancier way
--[[ if you don't...
velocity.RelativeTo = Enum.ActuatorRelativeTo.World
movement = humanoidrootpart.CFrame.LookVector * speed ]]
-- if you don't want them to jump
velocity.MaxForce = 10000
--[[ if you do...
velocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
velocity.MaxAxesForce = Vector3.new(10000, 0, 10000) - doesn't apply force on the y ]]
velocity.VectorVelocity = movement
local tween = TweenService:Create(velocity, TweenInfo.new(_time), { VectorVelocity =
movement.Unit * walkspeed -- end the tween at normal speed
}):Play()
task.delay(_time, function()
attachment:Destroy()
velocity:Destroy()
end)
end
Make sure to set the humanoid’s walkspeed to 0 for more accurate results.
This won’t be a high quality dash, it will most likely look like a laggy push, and it will deaccelerate too fast to be able to react to. It will also be inconsistent based on what you’re standing on or what direction you’re moving.
The advantage of using ApplyImpulse is how easy to use it is and the reaction time, it instantly apply a force to the object while it is not the case with the linear velocity (0.05 - 0.2s delay).
There is nothing “laggy” but i aggree with the fact that it deaccelerate too fast, that’s why you should edit the physical properties of all character body part so it look better and the movement is smoother.
This is actually untrue. LinearVelocity attempts to maintain the exact velocity that’s described by it’s property. It instantly obtains that velocity if the max force is set high enough (I’d recommend 100000-1000000).
I’m not talking about the time it take to reach the velocity, but mostly the time it take to setup the instances each time you’re doing a dash, and when people do it server side (which i see often), the velocity have a delay to start and stop depending of the server performance and player network.
The delay is also noticed when you rotate your character at the last moment.
Changing direction around 0.1s before the dash isn’t taken into account so the velocity still is at the last direction and it result to you dashing in the wrong direction, even if it is made on client side.
This is good. I have used it and it works. Will try to use bodyalign or whatever it is though if ApplyImpulse does have problems like Den_vers says. This thread is considered solved.