Whats wrong with my dash script?

Hey there and merry christmas! Currently working on my 2.5D platformer Overdrive! and my dash seems to be interferring with the ground and is effecting the velocity, I’d like the dash to always do the same amount as power, wether you are in the air or on the ground, but it seems as the ground interferes with that.

I’m more of looking for something like in Verdant Moon

If you could help me with finding a solution it would be appreciated. Cheers!

Heres my current dash script.

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

--player vars
local client = Players.LocalPlayer
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local animation = script:WaitForChild("Animation")
local animator:Animator = hum:WaitForChild("Animator")
local animTrack = animator:LoadAnimation(animation)
animTrack.Priority = Enum.AnimationPriority.Action
animTrack.Looped = false
local hasLanded = true
local boosted = false

local upwardsForce = 0 --as percent of sidewards force
local boostMagnitude = 1850
local debounce = tick()
local debounceTime = .5
local boostKey = Enum.KeyCode.Q
local hotkeys = {
	["W"] = Vector3.new(0,.50,0),
	["A"] = Vector3.new(-1,0,0),
	["S"] = Vector3.new(0,-1,0),
	["D"] = Vector3.new(1,0,0),

--the function to get a normalized vector3 of the boost direction
local function getUnitDirection(): Vector3
	--set up the return var
	local resultVec3 = Vector3.zero
	local isSideways = false
	local isUp = false
	local issidewaysup = false
	for _, input: InputObject in pairs(UserInputService:GetKeysPressed()) do
		if hotkeys[input.KeyCode.Name] then
			--add up the vector forces based on the pressed hotkeys (W/A/S/D)
			resultVec3 += hotkeys[input.KeyCode.Name]
		if (input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D and (not isSideways) and input.KeyCode ~= Enum.KeyCode.W) then
			isSideways = true
		if input.KeyCode.Name == "W" then
			isUp = true

	if resultVec3.Magnitude > 0 then
		--return the normalized vector
		return resultVec3.Unit, isUp, isSideways, issidewaysup
		--return (0,0,0) if no direction vector can be normalized
		return Vector3.zero, isUp, isSideways, issidewaysup

local function boost()
	--apply the boost force
	local direction, isUp, isSideways, issidewaysup = getUnitDirection()
	local boostVector = Vector3.zero
	if isUp then 
		boostVector = getUnitDirection() * boostMagnitude * .5 
	elseif isSideways then
		boostVector += Vector3.FromAxis(Enum.Axis.Top) * upwardsForce * boostMagnitude + getUnitDirection() * boostMagnitude * 0.6
	--update the vars
	boosted = true
	hasLanded = false
	--play the animation

UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
	--ignore input on UIs, chat, etc.
	if gameProcessedEvent then return end
	--only boost if the designated hotkey was used
	if input.KeyCode == boostKey and tick() - debounce > debounceTime and not boosted  then

while wait() do
	if not hasLanded then	
		local rayOrigin = char.HumanoidRootPart.Position
		local rayDirection = Vector3.new(0, -3, 0)

		local raycastParams = RaycastParams.new()
		raycastParams.FilterDescendantsInstances = {script.Parent}
		raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
		raycastParams.IgnoreWater = true
		local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
	if raycastResult then
	hasLanded = true
	boosted = false
			debounce = tick()

You’ll need to sustain more of the force rather than doing a quick burst.

What you’re currently doing is just applying an impulse for a split second making the dash be more of a quick move rather than sustained in the video shown.

There are many ways to go about this but you can try using a vector force if you want something of that nature without having to use a loop.

Of course, while dashing, check the distance, and if it reaches the distance of dashing you want, stop it. That’ll help keep it more consistent.

1 Like

They should use a timer and not distance, lest the dasher dash into a wall and have it never end.

1 Like