Welds applying strange offset

Hi, so for my game I was trying to improve object movement mechanics by making it smoother, versus using CFrame to move the objects which creates a choppy effect. One idea I had was to use welds, to attach game objects to the player so when the player moves, the object also moves, and it’s buttery smooth.

I originally started by using a WeldConstraint for this, which worked perfectly however I have no desire for the object to rotate at all or move in another fashion other than in a straight line, which when using the WeldConstraint it did both.

I thought of trying to use a regular weld to see if it handled that better at all, but for some reason despite however I try to negate offset from the weld, the object I’m attempting to move always jumps into the air for some reason…I’m stuck on this.

Here’s the code, followed by an example of the problem:

Thanks.

1 Like

Hi!
It’s easier for people to help if you post the code as text instead of screenshots.
You surround it with three backticks
```
like this
```
and it will appear in the post

like this

Anyways, normal Welds will also rotate with the player. So it probably wouldn’t fix your problem. Maybe consider updating the CFrame every frame (using RunServer.Stepped) instead, or a BodyPosition.

That being said, this is the math to maintain relative offsets with a Weld (but again, this will give you the exact same results as a WeldConstraint):

local weld = Instance.new("Weld")
weld.Name = "PushWeld"
weld.Part0 = self.player.PrimaryPart
weld.Part1 = object_model.PrimaryPart
weld.C1 = weld.Part1.CFrame:Inverse() * weld.Part0.CFrame
weld.Enabled = true
weld.Parent = object_model

(you may wish to swap Part0 and Part1).

2 Likes

Thank you.

I’ve been struggling to figure out a way to smoothen out object movement, nothing seems to be an ideal option other than just offsetting it directly using CFrame, but that creates a choppy look :confused:

I would really recommend BodyPosition for this!

1 Like