Using welds to move objects, but keeping orientation locked in place

So to start off, my game uses object movement mechanics, very similar to those in this video:

Now, I’m currently using CFrame, but that makes object movement look pretty choppy. Versus in the video, it’s buttery smooth probably due to it being grid-based entirely. (mine isn’t)

With that said, I took a look at welds. They worked fantastic. I’d weld the core part of a game object to the player using like a WeldConstraint, and from there the object would move with the player seamlessly.

However, the caveat was sometimes as the player was moving this object, the object’s orientation would change slightly, and I can’t have that happen at all. It causes weird collision problems…

Is there any way I could attack the problem so I can keep using welds, but have it so the object’s orientation never changes? I’d be willing to use a hacky solution too, I’ve literally tried everything in the book, and nothing worked for my use case.

Thanks!

Not entirely sure I know which feature you’re referencing from that hour long video… If all you want is parts (or models) to maintain a relative offset from the character model, you basically have two choices:

  1. Begin with a root part of the character. Modify your character control system such that this root part’s rotation will always be aligned with the world axis. Then you can simply use a Weld or Motor6D (different than WeldConstraint) changing the C0 and/or C1 property of the weld or motor to maintain offset from the character.
  2. You can update the CFrame of the attached part or Model.PrimaryPart within a function bound to the render frame using RunService:BindToRenderStep(). Using this strategy you wouldn’t need to worry about maintaining the character’s root part orientation as you could simply negate rotation in the offset calculation:
attachedPart.CFrame = rootPartCFrame + Vector3.new(x,y,z) --change to whatever offset you'd like
1 Like

Thanks!

I feel like it’d probably result in the same problem though, I will try it when I get the chance.

I was referring to the general object movement mechanics in the video, when the player goes to push any object, it’s very smooth and seamless.

It’s a very weird problem. I weld the object to the player if its in his path, and sometimes that object will rotate slightly (as shown in the Orientation property) and this screws everything up. I change the C1 property of another joint in I believe the HumanoidRootPart to rotate the player model, and with that taken into account before I weld an object to the player, I make sure they’re not currently turning/rotating, and if they do at any point turn/rotate, I disconnect any existing game object from the player.

And with all that said, it still rotates. I really don’t get it.

Have you considered using AlignPosition with attachments on the front of the character and the appropriate side of the object being pushed?

If you use it in conjunction with BodyGyro or similar to keep the world orientation the same, it would do what you’re after.

AlignPosition can either be rigid like a weld, or physically simulated with various force parameters.

2 Likes