I am currently trying to get the player to go to a point based by his mouse and a Ray using BasePart.Velocity.
The thing is that it only works on normal parts that I use to have a visual of what is happening. When I set the velocity of the HumanoidRootPart, the player has difficulty in having the velocity in question and even when I jump, the player does not go completely on the target in question.
https://gyazo.com/0ffbd2d28e8f5f3a30ca610680773e84
It’s crazy I do not understand. At first I tried to weld the HumanoidRootPart to the part that was working in question. All this on the client of course, and it did not work and the part began to travel like the player, very difficultly.
https://gyazo.com/c612cccecd29220d503d86c6a28d9389
I first thought it was because I was on the client, so I tried on the server and it’s the same result.
The physics on Roblox are starting to get a little upset. When I use a BodyVelocity, it’s hard because the physics of the parts are sleeping, there is not really any proper constraint to have a constant velocity and even when I use BasePart.Velocity I have problems? Any ideas on what could be the problem in this case and how to fix it?
Here’s a reproduction of the place in question : Repro.rbxl (18,7 Ko)
local function jumpToWall()
character.Humanoid.Jump = true
local cachedPosition = mouse.Hit.p
local rayToMouse = Ray.new(game.Workspace.CurrentCamera.CFrame.Position,cachedPosition)
local part,pos,norm = game.Workspace:FindPartOnRay(rayToMouse,character)
local magnitude = pos and (character.PrimaryPart.Position-pos).magnitude
local endEffector = pos and (pos-character.PrimaryPart.Position)
if part and magnitude <= maxMagnitude then
local g = Vector3.new(0,-game.Workspace.Gravity,0)
local x0 = character.HumanoidRootPart.CFrame * Vector3.new(0,0,0)
local v0 = (pos-x0-0.5*g*t*t)/t
local p = Instance.new("Part",game.Workspace)
p.Size = Vector3.new(3,3,3)
p.CanCollide = false
p.CFrame = character.PrimaryPart.CFrame
p.Velocity = v0
local p2 = Instance.new("Part",game.Workspace)
p2.Anchored = true
p2.Size = Vector3.new(1,1,1)
p2.CanCollide = false
p2.Position = pos
p2.Color = Color3.fromRGB(255,0,0)
p2.Material = Enum.Material.Neon
local weld = Instance.new("Weld")
weld.Part0 = p
weld.Part1 = character.PrimaryPart
weld.Parent = weld.Part0
character.PrimaryPart.Velocity = character.PrimaryPart.Velocity + v0
end
end