I’m trying to create a movement system where the player will smoothly to each point, but like I have tried PivoTo, BodyPosition, and even AlignPosition and it all feels janky and they dont go exactly to the point?
1 Like
Have you tried TweenService? The player position are replicated to the server which mean if you tween it on the client it will do the same on the server too, so just set the Tween Easing Style to Linear so the player does not stop each time and tween the position to each point using a loop or something:
local TweenService = game:GetService("TweenService")
local parts = {} --here the table of the points which the player will follow
local root = game.Players.LocalPlayer.Character.HumanoidRootPart
for index,part in ipairs(parts) do
local tweeninfo = TweenInfo.new(0.2, Enum.EasingStyle.Linear)
local tween = TweenService:Create(root, tweeninfo, {Position = part.Position})
tween:Play()
tween.Completed:Wait()
end
1 Like
Hm so it seemed that when I was using BodyPosition before since it’s in 2D is wasn’t moving my character in the character axis and it was just being super weird but I finally got it working now!
Code
local bodypos = Instance.new("BodyPosition")
bodypos.P = 10000
bodypos.D = 200
bodypos.Position = humrp.Position
bodypos.Parent = humrp
local function DestroyPoints()
if connection then
connection:Disconnect()
connection = nil
end
bodypos.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
local count = 0
local toReach = #origins
while count < toReach do
for index, origin in pairs(origins) do
count += 1
bodypos.Position = Vector3.new(humrp.Position.X,origin.Y,origin.Z)
task.wait(.1)
end
end
for index, point : Part in pairs(points) do
point:Destroy()
end
bodypos.MaxForce = Vector3.new(0,0,0)
points = {}
origins = {}
end
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.