Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Certain CFrame Position During Animation??

Hey there fellas, I'm just looking for answer for my script, it's not that efficient, nor organized, but i wanted to know something: Let's pretend there is a weld to a certain block

weld.C0 = weld.C0 * CFrame.Angles(0,0,math.rad(-45)) * CFrame.new(-0.7800,0.2300,0) 

we do it like that, but, what if: few lines later, i made this:

weld.C0 = weld.C0 * CFrame.Angles(0,0,math.rad(45)) * CFrame.new(0.7800,-0.2300,0) 

which, I'm expecting the part to return to its normal position, although, it does not. It goes on to a certain [position] Here's a Gif: https://gyazo.com/abe77277d8f54fb70136586ff30ce59b

Anything i can do to fix this problem?

help

1 answer

✓ Accepted answer

Try doing it the other way around:

-- First Change
weld.C0 = weld.C0 * CFrame.Angles(0, 0, math.rad(45)) * CFrame.new(-0.78, 0.23, 0)

-- Revert Change
weld.C0 = weld.C0 * CFrame.new(0.78, -0.23, 0) * CFrame.Angles(0, 0, math.rad(45))

Why is this the case? Multiplying a CFrame by a CFrame moves the part in the direction of the first CFrame. Because you try to fix the rotation first, it is now translating by a different direction vector.

The same kind of thing can be observed in basic arithmetic:

a*3 - b = c

c/3 + b ~= a

But (c + b)/3 = a

2 comments

0

And..... it works! Wonderful, you're a life saver pal. I, therefore, accept your answer.

0

No problem! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.