So I am using LinearVelocity to make a dashing system, but it causes the character to stay floating in the air because it applies a velocity of 0 on the Y Axis. Anyone know how to stop this?
You might be looking for a VectorForce? I had a similar issue where I wanted players to be boosted up but they shouldn’t be slowed down on the X or Z axis but since I was using a BodyVelocity (BM equivalent to LinearVelocity), it caused them to slow down on those axes. I tried a BodyForce (BM equivalent of a VectorForce) and that was what I wanted.
I’m trying to replicate BodyVelocity with a Max Force of Vector3.new(x, 0, x)
, but it seems that it is only to possible to set the Max Force of a Linear Velocity to a float value. So, I am wondering if there is another way.
I was looking into Vector Force, but it seems to be affected by mass and friction unless I’m mistaken.
I think it’s affected by mass, you’re right, but you might be able to use BasePart:GetMass() to set it dynamically?
The problem is that Vector Force still is affected by friction if it is applied to a Player’s Character unless I’m doing something wrong.
Here is the code that I am doing to create the Vector Force
local vectorForce = Instance.new("VectorForce")
vectorForce.ApplyAtCenterOfMass = true
vectorForce.Force = character.HumanoidRootPart.CFrame.LookVector * 5000
vectorForce.Attachment0 = character.HumanoidRootPart.RootAttachment
vectorForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
vectorForce.Parent = character.HumanoidRootPart
Oh I see, you’d probably want to use mass * LookVector * multiplier but that’s only if it’s RelativeTo world, you don’t really need to use the LookVector if it’s RelativeTo Attachment0 because Attachment0’s CFrame will be aligned with the HRP’s CFrame with an offset.
character.HumanoidRootPart:GetMass() * character.HumanoidRootPart.CFrame.LookVector * 5000 -- 5000 might be a bit high
When I tested, this seemed to work best:
character.HumanoidRootPart:GetMass() * Vector3.new(0,0,-1000) -- -1000 is forward which I assume is what you want?
You do mention friction though, I don’t have a reliable way to test it since I’m not great with physics but I’m thinking maybe you could try using CustomPhysicalProperties on the character’s BasePart descendants while dashing, and when they aren’t dashing, set it back to normal?
Here’s a video of what is what when I’m talking about friction. When the player is on the floor, the VectorForce barely moves the player, but when the player jumps, it sends them way farther.
Ohhh I see, my apologies. Are you just trying to sort of lunge the player forward like not for an extended amount of time?
I was thinking maybe :ApplyImpulse with setting the friction and density to very low values but after trying I can only get the player to treat the baseplate like ice. I’m stumped, sorry.
Here’s what I had if you want to mess around:
local userInputService = game:GetService('UserInputService')
local humanoidRootPart = script.Parent:WaitForChild('HumanoidRootPart') :: BasePart
userInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then
return
end
if input.KeyCode == Enum.KeyCode.E then
for i,v: BasePart in ipairs(script.Parent:GetDescendants()) do
if v:IsA('BasePart') then
v.CustomPhysicalProperties = PhysicalProperties.new(0, 0, 0.3) -- defaults 0.7, 0.3, 0.5
end
end
local pos = humanoidRootPart.Position
humanoidRootPart:ApplyImpulse(humanoidRootPart.CFrame.LookVector * humanoidRootPart:GetMass() * 200)
task.wait(1)
print(((pos - humanoidRootPart.Position) * Vector3.new(1,0,1)).Magnitude) -- should print the distance (multiplied by V3(1,0,1 to not account for height))
end
end)
i may be late, but just change the velocity constraint mode to line
You do it like this
LinearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Plane
LinearVelocity.PrimaryTangentAxis = Vector3.new(1, 0, 0)
LinearVelocity.SecondaryTangentAxis = Vector3.new(0, 0, 1)
LinearVelocity.PlaneVelocity = Vector2.new(0, 0) --> Or whatever velocity you want to put here
A simpler way to do it would be:
local LinearVelocity = Instance.new("LinearVelocity")
LinearVelocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
LinearVelocity.MaxAxesForce = Vector3.new(1000, 0, 1000)
that does not do it for me unless i set it to a very high force
Might be something else, doing it that way does not apply any force to the Y axis
You need to set it to a high force. What the code above does is make 0 force be applied on the y axis, and a variable amount on the others.
So to make it rigid, the force should be set to math.huge
, or just some very large number.