I want to make a dash but there’s a lot of things that I can use to do so. I can use AssemblyLinearVelocity or ApplyImpulse, but I can also use the Mover Constraints. What should I use for it? What’s the differences? Why are there so many options?
Depends on the needs of the dash. If it’s a precision platformer you need whichever is the most consistent. If it’s for a more open-field combat system, you could probably use any of these equally well.
Try the Search button up top.
Use the term "dash " (with the quotes and space, otherwise you get a bunch of posts with the word dashboard).
A lot of people over the years have posted different dash systems and the help they’ve received should point you in the right direction.
Use ApplyImpulse
trust its the best for that.
Won’t apply impulse not allow for changing direction? I don’t want to spam it to do that, so if I used a linear velocity and based the velocity off of the movement direction of the humanoid, would they be able to dash and turn their screen to rotate?
do you mean a controllable dash? like as in you can steer while you are in the dash? You could make a simple script that uses a linear velocity and some scaling on the magnitude over time to make it feel more natural.
What magnitude? For linear velocity, aren’t you just adjusting the velocity in a given direction to propel the player? And yes, I mean a dash that you can steer.
Im not very familiar with physics components in roblox because i usually just code them myself, but I believe a linear velocity has a direction and a magnitude, similar to a vector.
To scale the magnitude like i said, you could use a script like this:
local function f(x)
return math.log(100x+1)
end
local function g(x)
return math.log(100x+1000)
end
local function GetMagnitude(x)
return math.min(g(x), h(x))
end
local function OnDash()
local duration = .5 --DEFINE DURATION HERE
local domain = 10 --DEFINE DOMAIN OF MAGNITUDE(x) HERE
--the domain of the function i gave you is [0, 10)
local scale = domain/duration
local start = tick()
local connection = game:GetService("RunService").RenderStepped:Connect(function()
elapsed = tick() - start
local magnitude = GetMagnitude(elapsed*scale)
local direction = --GET MOVEMENT DIRECTION
local finalVector = direction*magnitude
--SET LINEARVELOCITY VECTOR HERE
if elapsed >= duration then
--SET LINEARVELOCITY VECTOR TO ZERO
connection:Disconnect()
end
end)
end
There are also other ways to write this, but this is the most straightforward
Also, if you want to use different formulas, then you can use desmos to visualize them. Heres mine:
nope, you can do:
humanoid.MoveDirection.Unit * your impulse value
He wants to be able to change direction mid-dash. Unless you constantly apply impulses, this wont work.
I don’t understand any of this… But I ended up making my own system that I’m happy with. Although, I’ve already seen some setbacks with it related to my game that I’ll have to deal with.
local char = script.Parent
local rootPart = char.PrimaryPart
local humanoid = char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local dashMult = 72 + (humanoid.WalkSpeed * 0.5)
function applyDashChange(linearVelocity, i)
local dashVelocity = Vector3.new(rootPart.CFrame.LookVector.X * (dashMult - (i * 10)), 0, rootPart.CFrame.LookVector.Z * (dashMult - (i * 10)))
linearVelocity.VectorVelocity = dashVelocity
end
local avaliableDashes = 3
local debounce = false
UIS.InputBegan:Connect(function(input)
if not debounce then
if input.KeyCode == Enum.KeyCode.LeftShift and avaliableDashes > 0 then
avaliableDashes -= 1
local linearVelocity = Instance.new("LinearVelocity")
linearVelocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
linearVelocity.MaxAxesForce = Vector3.new(math.huge, 0, math.huge)
linearVelocity.VectorVelocity = rootPart.CFrame.LookVector * dashMult
linearVelocity.Attachment0 = Instance.new("Attachment")
linearVelocity.Attachment0.Parent = rootPart
linearVelocity.Enabled = true
linearVelocity.Parent = rootPart
for i = 1, 7 do
applyDashChange(linearVelocity, i)
task.wait(0.05)
if i == 7 then
linearVelocity.Attachment0:Destroy()
linearVelocity:Destroy()
end
end
elseif avaliableDashes == 0 then
debounce = true
rootPart.Parent.Torso.BrickColor = BrickColor.new("Persimmon")
task.wait(4)
avaliableDashes = 3
debounce = false
rootPart.Parent.Torso.BrickColor = BrickColor.new("Electric blue")
end
end
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.