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).
Have a hinge constraint between the body and the rotor.
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.
Ditch the CFrame spinning - the hinge will handle it. And unanchor the rotor!
To add a hinge constraint, click this button:
(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).
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
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.
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.
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).
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.
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?
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.