I’m attempting to make a dashing system where when the player presses their dashing key, they dash in the direction they were moving in.
Right now, I have the input system down, the problem is with the dashing itself. Everywhere I’ve looked, it seems that the dashing only goes one direction. What I mean is that I’m trying to make dashes where the end point changes as the player rotates. It’s hard to describe, but here are some clips to make it easier to understand:
Every other dash system I come across has very linear dashing, where once it starts, the end point doesn’t change, regardless of the character rotating in the middle of it. I want to make a system like those three, but I don’t even know where to begin. I’ve been using BodyVelocity, but I’m willing to replace them.
(Extra Context: The dashing is triggered in a server-sided module script.)
All you have to do is repeatedly apply the velocity to the player’s HumanoidRootPart for the duration of the dash, instead of using a BodyMover or VectorForce.
I have a way to detect which direction the dash should go in and a way to update the end point, but when I try something like:
HumanoidRootPart.Velocity = VariableVelocity
Nothing happens. Not even an error message in the output. Am I doing something wrong? (VariableVelocity takes the form of the LookVector * 30 moving forward, -LookVector * 30 moving backward, -HumanoidRootPart.CFrame.RightVector * 30 moving left and HumanoidRootPart.CFrame.RightVector * 30 moving right)
you need to loop updating the velocity based on the LookVector/RightVector, setting it once does not work, you can use os.time or tick if you want to create a timed loop.
Here is an example of how to achieve your desired effect:
local DesiredTime = 1
local RenderStepped = game:GetService'RunService'.RenderStepped
local HumanoidRootPart = game:GetService'Players'.LocalPlayer.Character.PrimaryPart
local t = tick() + DesiredTime
while tick() < t do
HumanoidRootPart.Velocity = HumanoidRootPart.CFrame.RightVector * 30
RenderStepped:Wait()
end