I have wanted to know, whether its possible to tween circular motions, which can be used for tweening parts or potentially camera movement?
I have researched multiple things, but nothing seems to come up.
I have wanted to know, whether its possible to tween circular motions, which can be used for tweening parts or potentially camera movement?
I have researched multiple things, but nothing seems to come up.
By circular motions do you mean moving a part in a circle or rotating a part about an axis? Could you possibly give more info on what exactly you are trying to tween and how?
part in a circle, like say u want something to orbit around something, but u use tweening, is it possible?
You can use sine and cosine:
local Earth = workspace.Earth
local Radius = 10 -- The size of the circle
local Origin = Vector3.new(0, 10, 0) -- Our center point
--[=[
Add this function just incase a Tween.Completed already fired
which would lead the for loop to keep waiting.
]=]
local function WaitForTween(Tween)
if Tween.PlaybackState == Enum.PlaybackState.Playing then
Tween.Completed:Wait()
end
end
local function UpdatePosition(Part, Position, Speed)
local Tween = TweenService:Create(Part, TweenInfo.new(Speed), {Position = Position})
Tween:Play()
WaitForTween(Tween)
end
--[=[
Main part of the Script
which handles the orbit
]=]
while true do
for Degrees = 1, 360 do
local Radians = math.rad(Degrees)
local X = Radius * math.cos(Radians)
local Y = Radius * math.sin(Radians)
UpdatePosition(Earth, Vector3.new(X, 0, Y) + Origin, 0.2)
end
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.