I am trying to use TweenService to make sliding doors, which is going good except for the fact that the door is spinning because the orientation of the door is not 0, 0, 0. If I were to try and set it to 0, 0, 0 it will go side aways and not be the correct way. I need the orientation to be 0, 0, 0 without it rotating.
How can I have the door rotated the way I want with the orientation at 0, 0, 0? Or is there something I can do with the tween script to make it slide regardless of the orientation?
Since it is a group game that is set to release soon I am not allowed to disclose photos of it, but I will supply pictures of the script as necessary.
TLDR: Door is not sliding properly due to the orientation being incorrect, and if I reset the orientation it will turn the door the wrong way.
I don’t want the door to rotate, I want it to slide without the rotation, but it is rotating because I can’t get the orientation to 0, 0, 0 without turning the Union(door part) the wrong way.
I am not changing the orientation, but the way the union was made the Orientation is not how it is supposed to be, I want to reset the orientation without turning the Union sideaways.
I think I read you’re statement wrong as well. Maybe you should give us an example of what you’re looking for. Maybe a video clip from another game?
You can’t rotate something without changing a rotational component of it. If you’re experiencing trouble with a door not facing the right way, then handle rotations in local space instead of world space, which I suspect is your chief culprit.
My tutorial on tweening models does include a little section about creating pivot-based doors with TweenService. You can read over it for ideas and guidance.
Simple! Just multiply the CFrame by .FromEulerAnglesYXZ(part.orientation.x,part.orientation.y,part.orientation.z) and it will move with the orientation you’ve set for the part. There’s an article on CFrame math operations here.
I think I finally understand what you’re problem is…
You are trying to tween a sliding door that is rotated already, the tween is playing incorrectly.
If you look through colbert’s thread, you can see that he welds all the pieces of a model to a root part. To tween the whole model, you just need to tween the root part.
What you can do is, have another invisible, non-collide part, where you want the door to be tweened to. Make sure that you keep the invisible part’s orientation the exact same as the door’s and just tween the door’s CFrame to the inivisble part’s CFrame.
This is what the code would look like:
local ts = game:GetService("TweenService")
local info = TweenInfo.new(0.75, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local newtween = ts:Create(ROOT_PART, info, {CFrame = INVISIBLEPART.CFrame})
newtween:Play()
This is my first dev forum post, so please excuse any problems with the formatting of my post.
I thought I would chime in here, since I am not sure this is completely answered. I had the same problem on a part where the orientation had been changed during the tween. I was able to get this working in my game by doing the following. This may not be the best way to do this, but I thought I would share how I was successful. Constructive feedback welcome.
--[[-------------------------------------------------------------------------------------------------
LOCAL VARIABLE DECLARATION & INSTANTIATION
-------------------------------------------------------------------------------------------------]]
local button = script.Parent
local panel = script.Parent.Parent.Panel
local toggle = false
local TweenService = game:GetService( "TweenService" )
local tweenInfo = TweenInfo.new( 4, -- the time it takes to perform the tween
Enum.EasingStyle.Linear, -- the animation style for the object(s), Linear
Enum.EasingDirection.In, -- check dev hub for explanation on Directions
0, -- number of times it repeats
false, -- does it reverse?
0 ) -- the delay
local goal = { Position = Vector3.new ( -162.5, 0.888, -274.57 ) } -- using Vector3 to make sure the orientation isn't changed/reset
local tweenPanel = TweenService:Create( panel, tweenInfo, goal ) -- the tween for the panel from closed to open
--[[-------------------------------------------------------------------------------------------------
Function: openPanel
Purpose: This function plays the part tween using the TweenService and
properties stored in tweenPanel.
-------------------------------------------------------------------------------------------------]]
local function openPanel( )
tweenPanel:Play( )
end -- end function openPanel
--[[-------------------------------------------------------------------------------------------------
This function calls the openPanel function when the players clicks on the ClickDetector on the
button part. Once clicked, the openPanel function is called.
-------------------------------------------------------------------------------------------------]]
button.ClickDetector.MouseClick:Connect( function( player )
openPanel( )
end ) -- end function