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

TweenService - Orientation Problem (door freaks out if isn't equal to 0,0,0?)

Asked by 5 years ago

Hi, I have been working on my own door in studio which uses the service TweenService but I have come across an issue when the orientation is changed.

I have come here because I can't seem to find an answer and was wondering if any of you guys could help me solve the problem. When the door is placed at an orientation of 0,0,0 the animation works perfectly however, if that orientation is changed to 0,-95,0 for example it will not do the correct animation and freak out somehow.

I have included two gifs below to demonstrate this problem.

The orientation in this gif is 0,0,0: https://gyazo.com/b2ed3ea6e0e10d5728292cc47717bd2a

The orientation in this gif is: 0,90,0: https://gyazo.com/77f9825d800f19238b17517f5391c702

If this can be solved somehow, that would be great! TweenService is great service to use on Roblox and I would love to use it instead of CFrame.

I have provided the code I used if it helps you in any sort. Notice: This code is only being used for testing purposes.

-- params : ...
local TweenService = game:GetService("TweenService")

local frame = script.Parent:WaitForChild("Frame")
local leftDoor = script.Parent:WaitForChild("LeftDoor")
local light = script.Parent:WaitForChild("Light")
--local modules = game.ReplicatedStorage:WaitForChild("Modules")
local rightDoor = script.Parent:WaitForChild("RightDoor")
--local debounce = require(modules.Debounce)

local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0, true, 1)
local leftOpen = {CFrame = CFrame.new(leftDoor.Position.X-2.15, leftDoor.Position.Y, leftDoor.Position.Z)}
local leftClose = {CFrame = CFrame.new(leftDoor.Position.X-0, leftDoor.Position.Y, leftDoor.Position.Z)}
local rightOpen = {CFrame = CFrame.new(rightDoor.Position.X+2.02, rightDoor.Position.Y, rightDoor.Position.Z)}
local rightClose = {CFrame = CFrame.new(rightDoor.Position.X+0, rightDoor.Position.Y, rightDoor.Position.Z)}
local tweenLeftOpen = TweenService:Create(leftDoor, tweenInfo, leftOpen)
local tweenLeftClose = TweenService:Create(leftDoor, tweenInfo, leftClose)
local tweenRightOpen = TweenService:Create(rightDoor, tweenInfo, rightOpen)
local tweenRightClose = TweenService:Create(rightDoor, tweenInfo, rightClose)

wait(0.1)
tweenLeftOpen:Play()
tweenRightOpen:Play()
0
Im not entirely sure, but I believe its because you are using the X axis to move the object, regardless of the objects orientation. I could be wrong, or right, I dont know to be honest. But its a start for you. WizyTheNinja 834 — 5y
0
I guess it's because when you use CFrame, you are already using the orientation. CFrame is basically a combination of the part's position and orientation (definition might be wrong), so if I'd rotate a part through TweenService I'd use CFrame.Angles() or CFrame.fromEulerAnglesXYZ(). Time_URSS 146 — 4y

Answer this question