January 7, 2021, 1:16pm
I’m new to scripting (more of a builder) so please go easy on me.
I want to rotate a mesh using CFrame but its off centered somehow. I imported it from blender and on blender, the mesh was centered to the 3D cursor like this:
But when rotated using CFrame, it isn’t centered:
This is the code I use to rotate it.
local fan = script.Parent.fan
while wait() do
fan.CFrame = fan.CFrame*CFrame.Angles(0, .05, 0)
How do I create a custom pivot point using CFrame to center the mesh? Google points me to setPrimaryPartCFrame but I’m not sure how or where to code it in. I’ve tried remodelling the mesh but it’s always off centered on studio.
Add an attachment in the direct middle then use that as your pivot point.
January 7, 2021, 1:21pm
How do I do that? I’ve inserted the attachment and positioned it to the center. What’s next?
January 8, 2021, 7:01am
Bump because I still can’t find a solution. (Hope it’s allowed)
Kinda a complicated response and probably a better way but I made a part and made it a anchor. Even scales to size.
local Fan = script.Parent
local RunService = game:GetService("RunService")
local FanOrientation = Fan.Orientation
local Anchor = Instance.new("Part")
Anchor.Name = "Anchor"
Anchor.Anchored = true
Anchor.CanCollide = false
Anchor.Size = Vector3.new(0.01, 0.01, 0.01)
Anchor.Position = Fan.Position
Anchor.Color = Color3.fromRGB(255, 0, 0)
Anchor.Transparency = 1
Anchor.Parent = game.Workspace
Anchor.Orientation = FanOrientation
local Weld = Instance.new("Weld")
Weld.Part0 = Anchor
Weld.Part1 = Fan
Weld.C0 = CFrame.new(Fan.Size.X / (-0.25 * 185), 0, Fan.Size.Z / (-0.4 * 65))
Weld.Parent = Anchor
Anchor.CFrame = Anchor.CFrame * CFrame.Angles(0, .05, 0)
January 8, 2021, 5:20pm
Thanks so much! You helped me a ton.