Performing dashes in the same direction regardless of shift lock

In the first link below, you will see how when the player is shift-locked and dashes to the left it plays to animation and dashes them in that direction, but when they aren’t shiftlocked and dash in that same direction, it forces them to look forward for a bit, dashes them in that direction, then returns them to their normal direction when the dash ends. How would I do this? (because currently, my dash system (second link) will send the character left based on the HRP regardless of shiftlock or not)

Here is my current code:

local HumanoidRootPart = player.Character.HumanoidRootPart
	
local attachment = Instance.new("Attachment")
	
if math.round(MoveDirection.X) == -1 then
	attachment.CFrame = CFrame.Angles(0, math.rad(180), 0)
elseif math.round(MoveDirection.X) == 1 then
	attachment.CFrame = CFrame.Angles(0, math.rad(0), 0)
elseif math.round(MoveDirection.Z) == -1 then
	attachment.CFrame = CFrame.Angles(0, math.rad(90), 0)
elseif math.round(MoveDirection.Z) == 1 then
	attachment.CFrame = CFrame.Angles(0, math.rad(-90), 0)
end
	
attachment.Parent = HumanoidRootPart
	
local LV = Instance.new("LinearVelocity")
LV.Attachment0 = attachment
LV.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
LV.VelocityConstraintMode = Enum.VelocityConstraintMode.Line
LV.MaxForce	= 100000
LV.LineVelocity = 50
LV.Parent = HumanoidRootPart
	
Debris:AddItem(LV, .2)
Debris:AddItem(attachment, .2)
1 Like

This looks very hard for you, I think you should learn about lookvectors so that you can perform a dash according to the direction the player is looking in.

2 Likes

I’m aware of how look vectors work and this doesn’t answer my question. I’m mainly asking how they are smoothly forcing the player to look toward the direction the camera is facing. When I attempted to do this it was not smooth at all. I did it by putting this in a loop:
local lookVector = camera.CFrame.LookVector
character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.Position, character.HumanoidRootPart.Position + Vector3.new(lookVector.X, 0, lookVector.Z))

1 Like

Based on what I’m seeing, I’d guess the dash is influenced by the actual camera’s direction. If you want to dash left regardless of where the player is facing you should use the CurrentCamera’s CFrame.RightVector and LookVector. (To dash left just multiply the RightVector by negative 1)
Edit: They could also be using the MoveDirection so compare both results and choose which best suits you.

Hey, thanks for the possible solution. This definitely could be the correct way to do this but I think I may be implementing it incorrectly because I’m still not getting the result I want. If you could provide a little more guidance it would be extremely appreciated. Right now I’m trying to figure out how they’re making the character face where the camera is facing smoothly because when I attempt it it’s extremely rough. (my attempt was making the character hrp cframe face the camera look vector then putting it in a rs heartbeat so it looped) Thanks for the reply.

Well I said that sort of because I don’t see any lookvectors in your code. However, to make it smooth I guess you could switch to bodyvelocity/applyimpulse? Linearvelocity is not deprecated but it’s worse for these things I believe.

I was able to solve this, the fix was very simple I don’t know how I didn’t find this earlier:
UserSettings().GameSettings.RotationType = Enum.RotationType.MovementRelative

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.