Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this object go to 0,0,0 orientation in a CFrame animation?

Asked by 6 years ago
Edited 6 years ago

I made a wave, which needs to be turned 90 degrees in order to line up with the rest of the wave. I made all parts in a CFrame animation, but the wave keeps turning back to its original (0,0,0) orientation. I tried the following script, which didn't work...

1local Orientation = Vector3.new(90,0,0)
2 
3for i = 1,1000 do
4    wait(.01)
5    Tsunami.CFrame = CFrame.new(StartPosition,Orientation) + Vector3.new(0,0,i*-5,0,0,0)
6 
7end

2 answers

Log in to vote
0
Answered by 6 years ago

Hi Zuru,

I think you're turning the part in the wrong way. You're using the good old lookAt method, where you declare a CFrame and give it two arguments, the position and the position it needs to look at. If you want to turn the part 90 degrees, you need to either change its Orientation, or multiply its CFrame by CFrame.Angles().

Keep in mind that turning 90 degrees on the X axis won't make the wave face up or anything. That's for the Z axis, if you want to make the wave face up, use the Z axis.

This Script Assumes The Necessary Variables Have Been Declared

1part.CFrame = part.CFrame * CFrame.Angles(math.rad(90), 0, 0);

Hope I helped and have a wonderful day/night.

Thanks,

Best regards,

~~ KingLoneCat

Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Use TweenService, this gives help to any object, commonly used to animate.

01local t = game:GetService("TweenService")
02 
03--do the function?
04local goal = {} --Don't forget, add this to your code/script!
05goal.CFrame = CFrame.new(POSITION,OF,CFRAME)
06local Tsunami = game.Workspace.PARTNAME
07Tsunami.CFrame = Tsunami.CFrame
08local tween = t:Create(Tsunami, TweenInfo.new(2), goal)
09tween:Play()
10end

Comment below for any errors.

0
Thank you for the answer, I'll try it ZURUgamer 7 — 6y

Answer this question