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

Can TweenService tween orientation?

Asked by 4 years ago

Hi, what I'm trying to do is tween a part's orientation. I'm not using SetPrimaryPartCFrame because it's not in a model, and I want to tween it over time. I don't want it to happen instantly. How would I go about tweening the position and orientation. It's kind of like tweening it on a hinge point or locking it's rotation around a single corner of it. Here is what I have so far, but it throws an error.

local main = script.Parent.Parent.Main

local TweenService = game:GetService("TweenService")
        local info = TweenInfo.new(3,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)

        local to = {
            Position = CFrame.new(-387.251, 1189.812, -627.261),
            Orientation = CFrame.Angles(57.5, 180, 180)
        }
        local openBox = TweenService:Create(main,info,to)
0
Maybe change it to vector3.new..? Idk never tried it Nguyenlegiahung 1091 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

A CFrame is both position and rotation. They are far more flexiable that just setting the position and orientation.

The error is due to Position and Orientation being Vector3 types and you are passing it a CFrame.

You can use the following to create a CFrame and change its rotation. Note that CFrame.Angles is in radians so you may need to use math.rad([degrees]).

local to = {
    CFrame = CFrame.new(-387.251, 1189.812, -627.261) 
            * CFrame.Angles(57.5, 180, 180) -- change this to radians
}

I hope this helps. Please comment if you have any other questions about this post.

0
Yes, that works. But the issue is that now since it's tweening it to that position, during the tween the bottom part of it is under the object that I'm tweening it over. Skychiild 4 — 4y
0
Also, if I try to reverse the value, by multiplying it by the negative of the value I originally rotated it as, it doesn't go back it just kind of stands up. Skychiild 4 — 4y
0
i did Rotation = Vector3.new(Insert Orientation here), maybe this will help? beargoespoopandpee 8 — 4y
Ad

Answer this question