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

Angle tween not working correctly?

Asked by
Muoshuu 580 Moderation Voter
10 years ago

I've used crazyman32's CFrame Tween and edited it so it works slightly correctly. My problem is that on line 2, if I don't add rs_Joint[3]* then it moves the part to the center of the character, but if I do, I can only tween it from a 0,0,0 angle, otherwise it screws up. I need it to tween from any angle to that one, though I can't figure out what to do

F.Y.I. I'm not very fond of CFrame...even though I've been using Lua for over 4 years..

coroutine.wrap(function()
    local NewCF=rs_Joint[3]*CFrame.Angles(math.rad(30),0,0)
    local oldangle=Vector3.new(rs_Joint[3]:toEulerAnglesXYZ())
    local oldpos=NewCF.p
    local newangle=Vector3.new(NewCF:toEulerAnglesXYZ())
    local newpos=NewCF.p
    for i=0,1,.04 do
        rs_Joint[3]=CFrame.new((oldpos*(1-i))+(newpos*i))*CFrame.fromEulerAnglesXYZ((oldangle.x*(1-i))+(newangle.x*i),(oldangle.y*(1-i))+(newangle.y*i),(oldangle.z*(1-i))+(newangle.z*i))
        wait()
    end
end)()

Answer this question