Bascially, I’m trying to animate weapon and health pickups to both levitate and rotate but I have failed every attempt.
I’m struggling with the fact that the only way to tween models is to use the model’s primary part CFrame but since I want it to levitate and rotate at different speeds, I have not been satisfied the way it turns out.
Solutions I have tried:
-
Use the model’s primary part CFrame to both levitate and rotate. Problem: It is not what I want.
-
Create 2 tweens for levitation and rotation using the model’s primary part position and orientation. Problem: I have to move every child in the model.
-
Create 2 tweens for every part in the model. Problem: the child parts are not lined with the primary part.
-
Make the model 1 mesh. Problem: Materials and textures frighten me
-
Use a Motor6D to levitate the model. Problem: I did not achieve anything, but maybe I didn’t try enough.
So, is it even posible?
Theres something I did not try?
Some code:
-- Levitate animation info
local levitateTweenInfo = TweenInfo.new(
.6, -- Time
Enum.EasingStyle.Sine , -- EasingStyle
Enum.EasingDirection.InOut, -- EasingDirection
-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
true, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
-- Rotate animation info
local rotateTweenInfo = TweenInfo.new(
2, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.InOut, -- EasingDirection
-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
-- Moves every part--
for i, model in ipairs(self.primaryPart:GetChildren()) do
-- Levitate Animation Loop
local newPosition = model.Position + Vector3.new(0,0.5,0)
local levitateTween = tweenService:Create(model, levitateTweenInfo, {Position = newPosition})
levitateTween:Play()
-- Rotate Animation Loop
local newOrentation = model.Orientation + Vector3.new(0,360,0)
local rotateTween = tweenService:Create(model, rotateTweenInfo, {Orientation = newOrientation})
rotateTween:Play()
end