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

TweenService Easing Direction Problem?

Asked by 6 years ago

I am creating a gate that should tween down and upon command. It does but it rotates weird and then does not go where I want it to. After it is open whenever it goes up it should be at the same 90° angle - somewhat a 90° angle.- and it should go back to position but it fails to do so.

Rotation Of Gate: -24.09, 0, 0

Script:

01local Gate = workspace:WaitForChild("Gate")
02local TweenService = game:GetService("TweenService")
03local Activated = false
04local Tween1Information = TweenInfo.new(
05    1,
06    Enum.EasingStyle.Linear,
07    Enum.EasingDirection.InOut
08)
09local Tween2Information = TweenInfo.new(
10    1,
11    Enum.EasingStyle.Linear,
12    Enum.EasingDirection.InOut
13)
14local Tween1 = {
15    CFrame = CFrame.new(31.749, -26.276, 16.473),
View all 32 lines...
0
CFrame includes both position and rotation, when you don't include rotation values it sets it to 0 User#22604 1 — 6y
0
How would I include rotation values? namespace25 594 — 6y

1 answer

Log in to vote
1
Answered by
Y_VRN 246 Moderation Voter
6 years ago
Edited 6 years ago

You're probably missing "* CFrame.Angles()" in your code, which is after both CFrames in both TweenInfos. Try this

01local Gate = workspace:WaitForChild("Gate")
02local TweenService = game:GetService("TweenService")
03local Activated = false
04local Tween1Information = TweenInfo.new(
05    1,
06    Enum.EasingStyle.Linear,
07    Enum.EasingDirection.InOut
08)
09local Tween2Information = TweenInfo.new(
10    1,
11    Enum.EasingStyle.Linear,
12    Enum.EasingDirection.InOut
13)
14local Tween1 = {
15    CFrame = CFrame.new(31.749, -26.276, 16.473)* CFrame.Angles(math.rad(90),0,0) -- This is what is missing.
View all 32 lines...

Note 1: If you add CFrame.Angles() without changing the X, Y, and Z values to radians (assuming you're using degress (like 90)), put math.rad(DEGREES) first, and change DEGREES to your liking. math.Angles() reads degress as radians (Without math.rad: 90 degrees = CFrame.Angles reads value as rads = 90 rads = 5156.62 degrees (I depend on Google Calculator)). More about Radians at https://en.wikipedia.org/wiki/Radian

Note 2: I used X in CFrame.Angles(X,Y,Z) because I don't know how your gate is supposed to look like. I used a simple brick as a gate. If it is not the right rotation, transfer the math.rad(90) to Y or Z and/or make the value negative to achieve the right rotation.

Hope this works for you.

0
Sorry if I kinda bumped this question. Y_VRN 246 — 6y
Ad

Answer this question