I’m trying to make a dash or more specifically an evade which is essentially a dash but will make you immune temporarily anyways an issue I’ve encountered with most of my approaches is the air dash brings the player further than a ground dash and I haven’t bee able to find a fix.
I’ve tried applying a force in an opposite direction, lowering values if the player is in the air, and using rays. The ray approach is the closest, however, still brings the player just a tiny bit further than a ground dash.
-- TODO: Make all of this more generic and probably combine it with another system
local function EvadeSystem(world)
for _, inputObject, gameProcessed in Matter.useEvent(UIS, "InputBegan") do
if inputObject.KeyCode == Enum.KeyCode.LeftShift then
for id, evade, model in world:query(Components.Evade, Components.Model) do
-- This stuff can probably go into components
local distance = 130 -- speed(?)
local duration = 0.2
local root = model.model.PrimaryPart
local ray = Ray.new(model.model.PrimaryPart.Position, Vector3.new(root.CFrame.LookVector.X * distance, 0, root.CFrame.LookVector.Z * distance))
local Raypos, Hitpos = workspace:FindPartOnRayWithIgnoreList(ray,{},false,true)
local attach0 = Instance.new("Attachment")
attach0.Parent = root
local ap = Instance.new("AlignPosition")
ap.Mode = Enum.PositionAlignmentMode.OneAttachment
ap.Attachment0 = attach0
ap.RigidityEnabled = true
ap.Position = Hitpos
ap.Parent = root
game.Debris:AddItem(ap,duration)
end
end
end
end