Then I’m stumped. There’s no reason it should be any different if all the meshes have the exact same positions and orientations and are all being given the exact same offset. Something else is affecting that third mesh. math.rad
is what you should definitely be using here though, considering you want a specific angle of 270 degrees. math.deg(270)
isn’t going to give you 270 degrees in radians, it’s going to give you 270 radians in degrees, which is actually 349 degrees.
it does not only happen to the blue potion only it happen to any potion and may happen to many potion at the same time
the potion are not in the same position but they has the same angle
You can use math which is probably even a little bit faster than built-in function
Radian is basic angle unit soo you should use them if you can, but in gui we have degree
local function RadiansToDegree(angleInRadians: number)
return angleInRadians * (180 / math.pi)
end
local function DegreeToRadians(angleInDegree: number)
return angleInDegree / (180 / math.pi)
end
print(RadiansToDegree(1)) --> ~57
print(DegreeToRadians(57)) --> ~1
as i said before the issue happen when using whatever math.rad or math.deg
I provided you with math equation, math.rad and math.deg are built-in functions that may sometimes not work, if math itself doesn’t work then your angle might be different every time
EDIT: You might also find that your angle is out of sync, check if your loop or anything that you use to trigger those frames to spin don’t change
you mean that math.deg and math.rad may be bugging ?
sometimes built-ins are inaccurate or they might not work if we give them specific scenario, also calling them might be a few nano-seconds slower but it’s not important, you should use your own math functions if you know how to create them, you can even sometimes optimize them and understand many new concepts
The built in ones are 4-5 times faster than the custom implementations.
Test using math.pi
local function RadiansToDegree(angleInRadians: number)
return angleInRadians * (180 / math.pi)
end
local function DegreeToRadians(angleInDegree: number)
return angleInDegree / (180 / math.pi)
end
local t0 = tick()
for n = 1, 1000 do
for i = 0, 3600 do
local Rad = math.rad(i)
local Deg = math.deg(Rad)
end
end
local t1 = tick()
for n = 1, 1000 do
for i = 0, 3600 do
local Rad = DegreeToRadians(i)
local Deg = RadiansToDegree(Rad)
end
end
local t2 = tick()
print("Time for standard:", t1 - t0) -- ~ 0.03432035s,
print("Time for custom__:", t2 - t1) -- ~ 0.16485238s
Test using 3.14159265
local function RadiansToDegree(angleInRadians: number)
return angleInRadians * (180 / 3.14159265)
end
local function DegreeToRadians(angleInDegree: number)
return angleInDegree / (180 / 3.14159265)
end
local t0 = tick()
for n = 1, 1000 do
for i = 0, 3600 do
local Rad = math.rad(i)
local Deg = math.deg(Rad)
end
end
local t1 = tick()
for n = 1, 1000 do
for i = 0, 3600 do
local Rad = DegreeToRadians(i)
local Deg = RadiansToDegree(Rad)
end
end
local t2 = tick()
print("Time for standard:", t1 - t0) -- ~ 0.034108877s,
print("Time for custom__:", t2 - t1) -- ~ 0.11953330s
@Krant19worlddv, are you able to provide a repro file containing the issue, so I can mess around a bit with changing different things? (A repro file shouldn’t really contain anything other than what is relevant to the issue, so you can keep the rest of your game secret)
not about math.pi but math.rad and math.deg, pi is constant also
Try rotating the ItemClone rather than the camera, and set the camera’s CFrame to a fixed offset on the z-axis:
local cframe = CFrame.new(ItemClone.Position) -- This is a CFrame consisting of only the ItemClone's position
-- Please use math.rad to convert angles in degress into angles in radians
-- The function is not responsible for the issues you're experiencing
ItemClone.CFrame = cframe * CFrame.fromOrientation(0, 0, math.rad(270)) -- You'll need to adjust the rotation to your liking
Camera.CFrame = cframe * CFrame.new(0, 0, 1.5) -- You might need to adjust the camera's offset as well
for now i set all the potions positions to 0 , it is now working but i will not mark this as solved because it may happen again , thank you for all of your help i appreciate it