BodyGyro and BodyPosition on an Anchored Part

Hello everyone,

I was wondering if it is possible to use BodyGyros and BodyPositions on an anchored part.

Currently, I’m using CFrames but I am encountering quite a lot of lag and other issues that I wasn’t when I was using bodyGyros and BodyPositions.

You can use TweenService on the CFrame for buttery smoothness

1 Like

It isn’t possible because the Body* objects rely on physics requiring unanchored parts.

Edit: What kind of lag are you encountering? CFrame should not lag in and of itself

Prob lerping with waits in between

I’ve made that mistake before. It’s choppy, not laggy.

1 Like

It appears to be quite choppy and definitely is more client and server intensive when there are multiple players in the game. Right now I’m gonna try rewriting the code to use the TweenService instead of lerping.

Client:

runService.Heartbeat:connect(function(d)
	if canContinue then
		local CFNew, CFAng, CFtoObjectSpace = CFrame.new, CFrame.Angles, CFrame.new( ).toObjectSpace
		local asin, pi, hpi = math.asin, math.pi, math.pi / 2
		
		local primaryPartCFrame = character:GetPrimaryPartCFrame()
		local new               = primaryPartCFrame
		
		if keys.w then
			new = new + camera.CFrame.lookVector * speed
		end
		
		if keys.s then
			new = new - camera.CFrame.lookVector * speed
		end
		
		if keys.a then
			new = new * CFrame.new(speed, 0, 0)
		end
		
		if keys.d then
			new = new * CFrame.new(-speed, 0, 0)
		end
		
		if speed < 1.25 then
			speed = speed + 0.02
		end
		
		local CameraDirection = CFtoObjectSpace(new, camera.CFrame).lookVector.unit
		
		game.ReplicatedStorage.Position:FireServer(primaryPartCFrame:lerp(new * CFAng(0, asin(CameraDirection.x), 0), speed))
		
		wait()
	end
end)

Server:

game.ReplicatedStorage.Position.OnServerEvent:connect(function(player, position)
	if player.Character then
		local character         = player.Character
		
		character:SetPrimaryPartCFrame(position)
	end
end)
1 Like

That’s not a good idea because TweenService will ignore parts that have the CanCollide property enabled, and it can cause them to go through any buildings or the map, etc.