Side Dash Direction Problem?
I'm trying to make a character dash on double-press (W, A, S, D). I'm using BodyVelocity
inside HumanoidRootPart
to dash.
W Dash is pretty straight-forward, just take the lookVector
, multiply by some speed and set bodyVelocity.Velocity
to that. S Dash is almost the same, just multiply the lookVector
by -1.
Side dash is the problem though. I tried multiplying by CFrame.Angles
, adding some vectors but couldn't make it work, here's the simplified version of my code:
01 | local dashRemote = game:GetService( "ReplicatedStorage" ):WaitForChild( "Remotes" ).Dash |
03 | local timeNeeded = 0.25 |
05 | [ 'a' ] = CFrame.Angles(- 90 , 0 , 0 ), |
06 | [ 'd' ] = CFrame.Angles( 90 , 0 , 0 ), |
12 | dashRemote.OnServerEvent:Connect( function (plr, key) |
13 | local root = plr.Character.HumanoidRootPart |
14 | local direction = dirs [ string.char(key):lower() ] |
15 | local velocity = Instance.new( "BodyVelocity" , root) |
16 | velocity.MaxForce = Vector 3. new( 1 , 1 , 1 ) * math.huge |
17 | velocity.Velocity = root.CFrame.lookVector * direction * speed |
19 | delay(timeNeeded, function () velocity:Destroy() end ) |
Any kind of help is appreciated, Thanks.