Right now, I’m trying to make a Dash system, you press a specific key and the player lunge forward.
It works but then here comes the problem, it is inconsistent.
And here are few things I tried and failed
1. Velocity based dash
While this works smoothly when activated in the air, the character goes so much further than when on the ground.
I can make the velocity weaker when activated in the air, but when at the edge of a cliff the same thing happens.
All this can be fixed if I make the character completly massless, but this cause some major issues that I have no controll over.
2. Tween based dash
This seems like the solution at first, but when activated near a wall the character just goes right through the wall which, I oviously do not want.
3. Align position
This one is a mess, you have no idea if the player has reached the goal since there is no events to tell you that, the character clip into the ground when activated on a slope.
4. Moving the character manualy
While this is very secure because you can use this move the character from the server, that is precisly the reason why this doesn’t work, the lag between the server and the client make the dash direction deleyed. Plus it looks very choppy.
I want make one thing clear and that is that I DO NOT want to use Body movers like Body velocity and Body position, I want to use contraints.
I have been pretty stumped by this for a long long time so please if you have any infomation at all, let me know, Thank you.
The velocity based dash becomes slower when you touch the ground because of friction ig, and
you can make custom physics for your character’s body parts with no friction.
local plrs = game:GetService("Players")
plrs.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
for i,v in ipairs(char:GetChildren()) do
if v:IsA("BasePart") then
local props = PhysicalProperties.new(0.7,0,0.5,0,1)
v.CustomPhysicalProperties = props
end
end
end)
end)
Touching on attempt #4, you shouldn’t be using the server for Character movement anyways.
There’s security issues with using the client, but an exploiter could also just write their own dash and completely bypass your security measure of doing such on the server.
So, let me propose a possible solution.
Note: The last time I wrote a dash mechanic was over 3 years ago.
Possible Solution:
Move the character manually on the client, this may be consecutive impulses of velocity, a single impulse of velocity, or otherwise.
A few other notes:
Try adding a bit of upward velocity to circumvent gravity and friction when using velocity-based dashes. It doesn’t need to be too much, just a bit. (Recomend trying this)
When using AlignPosition, you can adjust the MaxForce to prevent clipping. Not entirely sure, but about twice your characters mass should be enough. Don’t quote me on that, though.
TweenService really isn’t useful here, to my knowledge. May as well skim over the possibility.
so this caused a bit of a ploblem of it’s own so I tried your idea to move the character manualy on the client and it worked really well! but still have some problems with clipping, what do you think I should do? maybe overlap?
Currently I can only think of one way to prevent clipping off the top of my head.
Raycast from the players position a little ways in front of them, see if it hits anything, and don’t dash if they’re too close to the point where it hits.
I used CFrame and I used workspace:GetPartsInPart() function to detect if it touched anything and if it did then move the character upwards(for rising slopes) and if the character is still touching a part then cancelled the dash, it works like a dream thank you so much!
ive have this dash localscript that ive used in my game
maybe is this what you looking for?
local plr = game:GetService("Players").LocalPlayer
local Char = plr.Character or plr.CharacterAddeed:Wait()
local UIS = game:GetService("UserInputService")
local humanoid = plr.Character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local debounce = false
local cooldown = 0.4
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://10653187518"
function System()
local playAnim = humanoid:LoadAnimation(anim)
Char.HumanoidRootPart.Velocity = Char.HumanoidRootPart.CFrame.lookVector + Vector3.new(0,50,0)
wait(0.05)
playAnim:Play()
script:WaitForChild("Dash"):Play()
Char.HumanoidRootPart.Velocity = Char.HumanoidRootPart.CFrame.lookVector * 100
camera.FieldOfView = camera.FieldOfView - 10
end
--PC
UIS.InputBegan:Connect(function(input,IsTyping)
if IsTyping then
return
elseif input.KeyCode == Enum.KeyCode.LeftShift then
if debounce == false then
debounce = true
System()
debounce = false
end
end
end)