qPerfectionWeld - Allow SetPrimaryPartCFrame rotation while maintaining position

I’m using @Quenty’s qPerfectionWeld module to weld all of the parts in a helicopter model together, so that I only tween one part of the model and the rest of it follows. I’ve made one modification, which is to anchor the primarypart while unanchoring the rest of the model. This works perfectly, except one problem:

The helicopter’s rotors don’t spin due to the welds forcing their position and rotation to stay consistent.

The rotor is its own model and uses :SetPrimaryPartCFrame to turn.
qPerfectionWeld Source: Click

-- speed increases slowly over time
script.Parent:SetPrimaryPartCFrame(script.Parent:GetPrimaryPartCFrame()*CFrame.Angles(0,math.rad(speed),0))

The primary part of the rotor is the part with the red box below.

Is there any way to allow the rotor to rotate while still keeping its position relative to the model? If the qPerfectionWeld script “ignores” the rotor, when the actual helicopter moves the rotor gets left behind. My goal is to allow the helicopter to move while this upper portion is spinning (as that’s how helicopters work).

6 Likes
  1. qPerfectionWeld the helicopter body.
  2. qPerfectionWeld the rotor.
  3. Have a hinge constraint between the body and the rotor.
  4. Ta-da, qPerfectionWeld doesn’t care about constraints so it will stay, and you can use it to rotate the blades!

If you don’t want to use a hinge constraint, you will have to SetPrimaryPartCFrame the rotor into the right spot relative to the helicopter body. Let me know if you need help with this.

4 Likes

Can you explain how to set up the hinge constraint so it works properly? I’ve never had to use the new constraints before.

The spinning does work now, though (it just gets left behind because I haven’t set up the hinge constraint yet). :tada:

1 Like

Ditch the CFrame spinning - the hinge will handle it. And unanchor the rotor!

To add a hinge constraint, click this button:

image (in model tab)

and click on two points (the bottom of your rotor and the top of the helicopter?). I recommend turning on Constraint Details and Draw On Top as well. Under the hinge you can set the actuator type to Motor and adjust the torque and speed (via script if needed).

3 Likes

Worked, thanks a lot for your help!

2 Likes

As a bonus, constraints are physics-based so collisions and such will work. I always recommend constraints over CFraming :stuck_out_tongue:

You’re welcome!

2 Likes

It’s a helicopter so I don’t think physics are to worry about (hopefully). Still an added bonus!

1 Like

If you ever do make something like a user-controllable helicopter though, that added bonus is a real treat when people are climbing all over your helicopter :stuck_out_tongue:

But if you’re only making it as a background object or cutscene object or something that never sees physics interaction, it’s less important.

2 Likes

Yeah it’s a cutscene for when a user follows their friend. If we ever add user controlled vehicles I’ll keep that in mind though.

2 Likes

Every now and then the rotor gets left behind and the rest of the helicopter goes away without it. It continues to float mid-air, though, and sometimes will fix itself but continue to be horribly off from the rest of the vehicle. I’m not quite sure what is happening here; it seems to be completely random. Any possible fix for it?

Edit: okay, this is weird. It got left behind for the player who teleported, but not the player that was already there [the location that the player teleported to]. what

Edit 2: This happened during the takeoff animation

I think that is because the helicopter is sleeping. Use AlignPosition/Orientation with the helicopter unanchored but rigidly attached to an anchored part, sorry got busy but if you can’t figure it out by the time I get back I’ll explain further.

Can you explain further when you have time to explain? I don’t mind waiting, but I am confused as to what you mean.

  1. Helicopter is unanchored
  2. You CFrame an invisible, anchored part
  3. Use AlignPosition and AlignOrientation to rigidly attach the helicopter to the invisible part
  4. Helicopter never goes to sleep as it moves and the rotor never glitches.

Does every part of the helicopter need to have AlignPosition and AlignOrientation in it? I’d preferably only create as many instances as necessary (and apologies for my lack of knowledge on the subject, like I said I’ve never worked with constraints before).

…no, only the part you were CFraming before. Remember, moving one part moves the whole helicopter?

I think I’m misunderstanding here, specifically on step 3

AlignPosition and AlignOrientation both have two attachments. In any case, one of those attachments will be on the invisible part. However, where does the other one go? You only say “to rigidly attach the helicopter”, not specifying a specific part.

I’m not sure how I can be more clear.

You know that part of the helicopter that you are CFraming? Stop CFraming it. CFrame an invisible part in its place. Use both AlignPosition and AlignOrientation with Rigidity enabled to attach that part to the invisible part.

Let’s say you are CFraming PartX right now. Stop it. Make PartY that is invisible and anchored. Attach PartX to PartY. CFrame PartY.

By CFraming PartY you will be moving the helicopter. Because PartX is attached to it. Is that clear enough for you?

Didn’t work; helicopter does not move at all. Testing showed that the invisible part moved, but the helicopter didn’t go with it.

Have you made sure the entire helicopter is unanchored, and RigidityEnabled (or whatever) is enabled on the alignposition/orientation?

Additionally, maybe try flipping the attachments. RigidityEnabled is one-way. IIRC it’s Attachment0->Attachment1…

Hey, sorry for not getting back to you- I’ve been extremely busy with a whole variety of stuff. I’ll try this tomorrow and let you know how it goes. I do remember RigidityEnabled is on, though.