How to use AngularVelocity, Attachments and Ballsockets to create a smooth Wind Turbine spin

Video
Creating a super smooth spin has never been easier! No scripting involved what so ever. This method can be used on anything you want, as long as you have the creativity to apply it to your creations :slight_smile:

Step 1: Have 2 Mesh Parts(It can also work with parts but meshes are a lot smoother and laggy) In my case I have the main mesh then the blades!

Step 2: Next apply an attachment to your main mesh( in my case the pole of the turbine) and to your blade mesh. It should look something like this:

Step 3: Now apply a BallSocketConstraint to the main mesh(Pole of turbine) once you have done that go into the BlockSocketConstraints Properties and scroll all the way down and it should say Attachment0 and Attachment1.
Click Attachment0 and your cursor should now have a small block with arrows. Apply this to the attachment on the blades of your wind turbine which is your second mesh. Do this by going into Explorer and Clicking the attachment. You will also see Radius, you can mess around with that! I recommend .15 though
Video

Step 4: Now do the same thing with Attachment1 but this time apply it to the Attachment in the same location as the BallSocketConstraint like shown below:
Video

Note: At this point you should be seeing a green box!

Step 5: Now apply an AngularVelocity object to the main mesh(Pole of turbine) Now scroll all the way to the bottom of the AngularVeloctiys properties and you will see Relative To and Attachment0. The Relative To tab is a drop down menu, select Attachment0. Now click Attachment0 and its the same process as Step 4, apply this to the blade mesh as shown below in the video:
Video

Step 6: Your end result should look like this:


And when you play your game it should be spinning!

IMPORTANT NOTE: Make sure not to anchor anything!

Hope this was useful! If it was leave a like, if it didn’t work shoot me a message and I can try helping you out!

20 Likes

I don’t get it, what’s better about this than us doing:

while true do
    script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(.1, 0, 0)
    wait()
end

Maybe a performance boost? I’m not sure. You set out the tutorial very nicely though.

Your code will make the turbine drift over time due to floating point errors. (this can be solved by keeping a reference to the original cframe somewhere and using that in the calculation)

Additionally, if you do it with physics, it will interact with other parts of the world (i.e. objects flinging into the windmills will interrupt the cycle, which might look more realistic) and it will be better synchronized across clients. If you modify the cframe then you risk the windmill clipping into nearby physics objects and rotating/flinging them off with unnatural force or other physics mishaps like that.

8 Likes