Dash System: Direction

Interesting, I’ll check it out later and see what happens.

I have some questions if you could answer them many thanks

  1. Wasn’t BodyVelocity deprecated and replaced by Linear Velocity?
  2. Is the mass of a character based on the body parts like Rthro?
  3. Is the :ApplyInpulse function for applying a force in a Vector3 format?
  1. Yes, but both serve the same purpose.
  2. No, the mass of a Model is calculated by the mass of each individual part, of which is calculated by the Size * CustomPhysicalProperties.Density property (CustomPhysicalProperties is superseded by its material physical properties if CustomPhysicalProperties is disabled)
  3. Yes
1 Like

Here ill give you some source code it uses cardinal converter

Only click this if it's the last resort... (you're also going to have to change some stuff
--// Player
local player = game:GetService("Players").LocalPlayer
local character = script.Parent.Parent
local rootPart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")

local animator = humanoid:WaitForChild("Animator")
local slideAni = script:WaitForChild("Slide R6")
local track

--// Service
local UserInputService = game:GetService("UserInputService")

--// Modules
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Camera = require(ReplicatedStorage.Client_Modules.Camera)

--// Effects
local Smoke = script:WaitForChild("Smoke")
local emitter = Smoke:WaitForChild("Attachment"):FindFirstChild("ParticleEmitter")

--// Settings
local keycode = Enum.KeyCode.Q
local debounce = false
local cooldown = 1

local force = 150

--// Play Animation Function
function playAnimation()
	track = animator:LoadAnimation(slideAni)
	track:Play()
end

--// Emit Smoke Function
function emitSmoke()
	coroutine.wrap(function()
		Smoke.CFrame = rootPart.CFrame
		Smoke.Parent = workspace.Effects
		emitter.Enabled = true
		task.wait(0.25)
		
		coroutine.wrap(function()
			task.wait(0.25)
			emitter.Enabled = false
		end)()
		
		Smoke.Parent = script
	end)()
end

--// Disable Jump Function
function disableJump()
	coroutine.wrap(function()
		humanoid.JumpPower = 0
		task.wait(0.75)
		humanoid.JumpPower = 40
	end)()
end

--// Disable Collision Function
function disableCollision()
	for _, part in pairs(character:GetDescendants()) do
		if part:IsA("BasePart") then
			if part.CanCollide == true then
				coroutine.wrap(function()
					part.CanCollide = false
					task.wait(5)
					part.CanCollide = true
				end)()
			end
		end
	end
end

--// Cardinal Convert Function
function cardinalConvert(dir)
	local angle = math.atan2(dir.X, -dir.Z)
	local quarterTurn = math.pi / 2
	angle = -math.round(angle / quarterTurn) * quarterTurn

	local newX = -math.sin(angle)
	local newZ = -math.cos(angle)
	if math.abs(newX) <= 1e-10 then newX = 0 end
	if math.abs(newZ) <= 1e-10 then newZ = 0 end
	return Vector3.new(newX, 0, newZ)
end

--// Apply Velocity
function applyVelocity()
	local Attachment = Instance.new("Attachment")
	Attachment.Name = "Slide"	
	Attachment.Parent = rootPart
	
	local LinearVelocity = Instance.new("LinearVelocity")
	LinearVelocity.Attachment0 = Attachment
	LinearVelocity.MaxForce = 50000
	
	if humanoid.MoveDirection == Vector3.new(0, 0, 0) then
		LinearVelocity.VectorVelocity = rootPart.Position + rootPart.CFrame.LookVector * force + Vector3.new(0, -100, 0)
	else
		local direction = cardinalConvert(humanoid.MoveDirection)
		LinearVelocity.VectorVelocity = direction * force + Vector3.new(0, -100, 0)
	end
		
	LinearVelocity.Parent = Attachment
	
	for i = 1, 5 do
		task.wait(0.05)
		LinearVelocity.VectorVelocity *= 0.7
	end
	
	LinearVelocity:Destroy()	
end

--// Input Began Function
function inputBegan(input, gameProceed)
	if gameProceed then return end
	
	if input.KeyCode == keycode then
		
		if not debounce then					
			if humanoid:GetState() == Enum.HumanoidStateType.Jumping or humanoid:GetState() == Enum.HumanoidStateType.Freefall then
				return
			end

			debounce = true
				
			disableJump()				
			playAnimation()
			emitSmoke()
		--	disableCollision()
			Camera.shake(player, 0.1, 1000, 0.1)
			applyVelocity()
				
			task.wait(cooldown)
			debounce = false
		end		
	end
end

--// Connect Function
UserInputService.InputBegan:Connect(inputBegan)

So anyways you can use context actions service like this:

local function handleAction(actionName, inputState, inputObject) -- Function for handle inputs
	if actionName == "Right" then

   elseif actionName == "Left" then

   elseif actionName == "Forward" then

   elseif actionName == "Backward" then

	end
end

ContextActionService:BindAction("Forward", handleAction, false, Enum.PlayerActions.CharacterForward)
ContextActionService:BindAction("Backward", handleAction, false, Enum.PlayerActions.CharacterBackward)
ContextActionService:BindAction("Left", handleAction, false, Enum.PlayerActions.CharacterLeft)
ContextActionService:BindAction("Right", handleAction, false, Enum.PlayerActions.CharacterRight)

Then you will just change the vector accordingly. But, anyways you should provide a script.

Your problem can easily be searched up on the internet and it has to do with your lookVector. If you gave us your script we can help you more easily.

GOOD LUCK

2 Likes

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