mnillz
(mnillz)
1
im making a door that is just a single part and i want it to open as if it has a hinge
the problem is it doesnt work when i rotate it
i want it to work regardless of its position and orientation
this is the code that im using:
Model:PivotTo((CFrame.new(Model:GetPivot().Position) + Vector3.new(-2.5, 0, -2.5)) * CFrame.Angles(0, 0, math.rad(90)))
this is the position of the part that works with this code:
cframes eat me up i really dont get them
2 Likes
local pivot = Model:GetPivot()
local hingeOffset = CFrame.new(-2.5, 0, -2.5) ā local hinge offset
local rotation = CFrame.Angles(0, 0, math.rad(90))
Model:PivotTo(pivot * hingeOffset * rotation * hingeOffset:Inverse())
chatgpt is really good at this kind of stuff btw
mnillz
(mnillz)
3
chat gpt is like asking donald trump to explain anything
and it gave me this exact thing that doesnt work right
Katrist
(Katrist)
4
What I would first do is set the pivot position to the hinge using the editor:
Then, in the code, just multiply the pivot by a rotational vector:
Model:PivotTo(Model:GetPivot() * CFrame.Angles(0, math.rad(90), 0))
If the door rotates in the wrong direction, instead of modifying the Y rotation, try doing the X or Z.
1 Like
Katrist
(Katrist)
5
This is identical to what the original code does, Iām not sure why you replied without testing.
mnillz
(mnillz)
6
tysm! i didnt know you could change the offset of the pivot
1 Like
system
(system)
Closed
7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.