Hi all, was working on a move for my game when a strange bug appeared when playtesting it on the actual Roblox app and not in studio.
After using a specific move that slightly pushes me forward (Super God Fist) and then trying to jump afterwards, it tries to move me slightly in the direction of the LinearVelocitys original trajectory.
This is strange to me because there are other parts of the game that use the exact same code to make a LinearVelocity instance and it does not cause this same exact issue. (It in fact fixes it! Using a dash somehow stops the drifting I experience when jumping)
Video of the bug in action:
This is the code for the move that causes the weird drifting issue when jumping:
-- Does server side stuff like stun and replicating VFX by sending remote events
Network:FireServer("Start")
SGFTrack:Play()
-- Writing down variables for connections to define them later and be able to cancel them later
local RushStartEvent
local HitboxEvent
local EndConnect
local RushVelocity
local Hitbox
local RootPart : BasePart = Character:WaitForChild("HumanoidRootPart")
-- Code that makes the LinearVelocity
RushStartEvent = SGFTrack:GetMarkerReachedSignal("StartRush"):Once(function()
RushVelocity = Instance.new("LinearVelocity")
RushVelocity.Attachment0 = RootPart:WaitForChild("RootAttachment")
RushVelocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
RushVelocity.MaxAxesForce = (Vector3.one * 25000) * Vector3.new(1,0,1)
RushVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
RushVelocity.VectorVelocity = (RootPart.CFrame.LookVector * 25)
RushVelocity.Parent = RootPart
--game:GetService("Debris"):AddItem(RushVelocity,1.5) -- Thought this would fix it, it didnt.
end)
HitboxEvent = SGFTrack:GetMarkerReachedSignal("Hitbox"):Once(function()
if RushVelocity then
RushVelocity.Enabled = false
RootPart.AssemblyLinearVelocity = Vector3.new(0,0,0)
end
Hitbox = HitboxManager:MakeHitbox(RootPart.CFrame*CFrame.new(0,-1,-3),Vector3.new(5,5,8),Player.Name.."-supergodfist-hitbox")
local GetHit = HitboxManager:GetHitCharacters(Hitbox,Character)
Network:FireServer("Hit",GetHit)
end)
EndConnect = SGFTrack.Ended:Once(function()
if RushStartEvent then
RushStartEvent:Disconnect()
end
if HitboxEvent then
HitboxEvent:Disconnect()
end
if RushVelocity then
RushVelocity:Destroy()
RootPart.AssemblyLinearVelocity = Vector3.new(0,0,0)
end
if Hitbox then
Hitbox:Destroy()
end
Network:FireServer("End")
end)
If anyone has encountered this bug before or knows how to fix it, a reply would be extremely helpful!
Edit1: Added a video of the bug and fixed some typos.