Issue with linear velocity

Basicly im trying to make a move like tsb where we run but I have a problem where the part always tilts a little which make the character go in the floor (slightly).

This is how its supposed to look like:
Image1

how it looks like when the velocity is enabled:
Image2
We can see that the legs are in the floor.

Here’s the script (its a local one) and its not the full code, i just put the collision and velocity thing.

local Part = Instance.new("Part")
		Part.CanCollide = false
		Part.Size = Vector3.new(4,3,6)
		Part.Parent = workspace.Fx
		Part.CanQuery = false
		Part.Transparency = .5
		Part.Color = Color3.fromRGB(105, 153, 255)
		Part.Massless =true
		Part.Position = char.PrimaryPart.Position -- Vector3.new(0,2,0)
		Part.Orientation = Vector3.new(0,char.PrimaryPart.Orientation.Y,0)
		
		local Collision = Instance.new("Part")
		Collision.Shape = "Ball"
		Collision.Size = Vector3.new(2,2,2)
		Collision.Parent = char
		Collision.Name = "Collision"
		Collision.CanQuery = false
		Collision.Transparency = .5
		Collision.Color = Color3.fromRGB(0, 0, 0)
		Collision.Massless =true
		
		local Animation = Instance.new("Animation")
		Animation.AnimationId = "rbxassetid://79340075631032"
		Track = plr.Character.Humanoid.Animator:LoadAnimation(Animation)
		Track:Play(nil,nil,1.75)
		
		Weld(Part, char.PrimaryPart)
		Weld(Collision, char.PrimaryPart)
		
		local attachment = Instance.new("Attachment")
		attachment.Name = "DashAttachment0"
		attachment.Parent = Part

		local linearVelocity = Instance.new("LinearVelocity")
		linearVelocity.Attachment0 = attachment
		linearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
		linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
		
		linearVelocity.Enabled = false
		linearVelocity.Parent = attachment	
		
		local att1Right = game.ReplicatedStorage.TrailEffect.Attachment1:Clone()
		local att2Right = game.ReplicatedStorage.TrailEffect.Attachment2:Clone()
		att1Right.Parent = Part
		att2Right.Parent = Part
		att1Right.Trail.Attachment0 = att1Right
		att1Right.Trail.Attachment1 = att2Right
		
		task.wait(3)		
		
		local params = RaycastParams.new()
		params.FilterDescendantsInstances = {workspace.Baseplate, workspace.Fx, workspace.Characters}
		params.FilterType = Enum.RaycastFilterType.Exclude
		
		local X = Instance.new("NumberValue")
		X.Value = 240
		local Y = 0
		local Tween = ts:Create(X,TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,true),{Value = 250})
		Tween:Play()
		linearVelocity.Enabled = true
		Loop = rs.RenderStepped:Connect(function()
			hum:SetStateEnabled(Enum.HumanoidStateType.Freefall, true)
			local ray = workspace:Raycast(Part.Position,Vector3.new(0,-5,0),params)
			if ray then
				linearVelocity.Enabled = true
				linearVelocity.VectorVelocity = Part.CFrame.LookVector * X.Value - Vector3.new(0,20,0)
				linearVelocity.MaxForce = 35000
			else
				linearVelocity.Enabled = false
			end
		end)
		
		Tween.Completed:Connect(function()
			task.wait(20)
			Collision:Destroy()
			Track:Stop()
			Part:Destroy()
			Loop:Disconnect()
			att2Right:Destroy()
			att1Right:Destroy()
			linearVelocity:Destroy()
		end)

I think it has something to do with the orientation of the velocity part but I cant do anything since there’s a weld which makes it slightly orientated towards the floor. What i mean:
Orientation needed: (0,something,0)
Orientation obtained: (.011,something,0)

Please help me if you can.

1 Like

Hey! You can use the VelocityConstraintMode property of the linear velocity to Plane so it will only work in 2 directions that are the x and y axis (not to be confused by the actual y axis in Roblox, this is the y axis for a Vector2 which may also be the z axis in terms of Roblox). This way, the velocity will not push the character inside the ground! Do note that you would need to property adjust the velocity direction by changing the PrimaryTangentAxis and SecondaryTangentAxis properties.

Learn more here.

1 Like

Imma try that, thanks for the help!

1 Like

No worries! Just be sure to set the PrimaryTangentAxis and SecondaryTangentAxis properties properly or else it may get a bit out of hand. Another thing to note is that it uses the PlaneVelocity property which uses a Vector2 and not a Vector3 so you need to convert your Vector3 to Vector2 before applying the velocity.

Unfortunatly it doesnt work but I found the issue, its because of the part orientation, it is (-.011,0,0)
instead of (0,0,0)

Can you explain a bit more on how it doesn’t work? Like does it not work at all or what?

Also, if the parts orientation is the case then I’ll give you a heads-up that your system won’t respect gravity and if the player was to encounter a ledge then it will just float.

What I mean is that it work in terms of the velocity, the issue is I cant keep the part at the same orientation. What I need is that the velocity part has an orientation of like (0,something,0) but since its welded to the character it always tilts on the X level which makes the part point to the ground which explains why the character goes in the ground.

Are you welding the part to the RootPart or some other part?

As far as I know the PrimaryPart of the character is usually set to the Head for R6 rigs. So, I recommend setting it to the root part instead.

Yeah I made it so the primary part for r6 to be the hrp instead, and it is infact welded to the rootpart

Oh, I see. Well then this is probably just a Roblox problem. The only thing I could really recommend is using the method I listed.

I said the above line again because I don’t understand what you mean by this.

Oh sorry abt that, I meant that the velocity works as intended but its just the rootpart’s orientation that kinda breaks the thing

Apologies if I am being a bit out of touch here but you are saying that the Plane Velocity idea that I mentioned works? Or do you mean your system works.

Sorry im kinda sick rn I may have difficulties forming correct sentences :sob:.
Anyways the plane velocity has the same issue where we go in the ground.

Oh, get well soon I suppose.

Perhaps try properly adjusting the plane for the plane velocity. For this, you need to visualize it by selecting the plane velocity, next, editing the Tangent Axis properties till it’s parallel with the ground.

I found a fix to it! I just had to take the lookvector but adjust manualy that i didnt take the Y value.

1 Like