Hi all.
I recently started making a system for placing buildings, and I ran into a problem.
The system does not calculate the rotation coordinates correctly.
Having analyzed the whole situation with this problem, I realized that the coordinates by which the turn is calculated are incorrect.
According to its logic
Vector3.new(0,0,0) + Vector3.new(90) = 0.9931780099868774, -0.004358756355941296, 0.11652712523937225
Understanding that there can be no error in the calculations, I started printing the data, and received the following data
23:46:35.852 Model orientation - -0, -0, -1 - Client - LocalScript:8
23:46:35.852 What should be obtained - 90, 0, -1 - Client - LocalScript:9
23:46:35.853 What was actually obtained - 0.9931780099868774, -0.004358756355941296, 0.11652712523937225 - Client - LocalScript:10
I can’t even imagine where these values come from, because the formula for calculating the rotation is the same, which really pisses me off.
local model = workspace:WaitForChild("Wall").PrimaryPart
local TS = game:GetService("TweenService")
script.Parent.MouseButton1Click:Connect(function()
local cfrmValue = Instance.new("CFrameValue")
local pivot = model:GetPivot()
cfrmValue.Value = pivot
local goal = {Value = CFrame.new(pivot.Position,pivot.XVector+Vector3.new(90))}
warn("Model orientation -",pivot.LookVector)
warn("What should be obtained - ",pivot.LookVector+Vector3.new(90))
warn("What is actually obtained - ",goal["Value"].LookVector)
local tween = TS:Create(cfrmValue,TweenInfo.new(1),goal)
tween:Play()
cfrmValue:GetPropertyChangedSignal("Value"):Connect(function()
model:PivotTo(cfrmValue.Value)
end)
tween.Completed:Wait()
cfrmValue:Destroy()
end)
Thinking that the problem might be in the model itself, I checked the orientation of all parts of the model, and they turned out to be zero.
I’m already afraid to even guess what affects the calculation of a seemingly simple formula…