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

Translating and resizing a part on an axis?

Asked by
KoreanBBQ 301 Moderation Voter
8 years ago

What is the mathematical function I have to use to match an effect like the one on Studio when you Resize.

Basically I want to resize a rotated brick on an axis and push that brick half of the resize increment on that same axis.

A little like in that GIF:

https://gyazo.com/abf8675b042613900bbc1b7c2307d6ef

I'm pretty sure it has to do with math.sin or math.cos but I'm not that good in trigonometry (I didn't learn that at school yet), so I'm unsure.

I'd really like it to have something like

local increment=.123
local oldCFrame=part.CFrame
for i=0,numberoftimes do
    part.Size=Vector3.new(part.Size.X+increment,part.Size.Y,part.Size.Z)
    part.CFrame=oldCFrame*CFrame.new(math.sin(part.Rotation.X)*increment/2,blahblah) -- this line is the one i cant figure out
end

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
8 years ago

You don't need math.sin or anything special, because oldCFrame * relative has relative in the object space -- that means x means in the part's x direction.

The line you want is just

part.CFrame = oldCFrame * CFrame.new( increment / 2, 0, 0)

but you have to set oldCFrame in the loop, just not before it.

Ad

Answer this question