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

"Tweening" a Vector3? (Fading between two Vector3s)

Asked by 4 years ago

This question has been solved by the original poster.

So my question is this: What's the best way to "Tween" a Vector3? I know you can't actually Tween it, what I mean by that is what is the best way to take a Vector3, and then fade it into another one?

(e.g. [0,0,0] - [1,0,5], The value wouldn't just go strait to [1,0,5], it would fade at a set rate (speed). e.g. [0,0,0]-[0.2,0,1]-[0.4,0,2]-[0.6,0,3]-[0.8,0,4]-[1,0,5])

Here's some code I made that kinda works:

local Def_Offset =Vector3.new(0,0,0)
local Offset0 =Vector3.new(-0.52,0.25,0.5)

local FadeX =false
local FadeY =false
local FadeZ =false
while FadeX ==false or FadeY ==false or FadeZ ==false do
    if tool.Value.Offset.Value.X <Offset0.X then
        tool.Value.Offset.Value =tool.Value.Offset.Value +Vector3.new(0.01,0,0)
    elseif tool.Value.Offset.Value.X >Offset0.X then
        tool.Value.Offset.Value =tool.Value.Offset.Value -Vector3.new(0.01,0,0)
    else
        FadeX =true
    end
    if tool.Value.Offset.Value.Y <Offset0.Y then
        tool.Value.Offset.Value =tool.Value.Offset.Value +Vector3.new(0,0.01,0)
    elseif tool.Value.Offset.Value.Y >Offset0.Y then
        tool.Value.Offset.Value =tool.Value.Offset.Value -Vector3.new(0,0.01,0)
    else
        FadeY =true
    end
    if tool.Value.Offset.Value.Z <Offset0.Z then
        tool.Value.Offset.Value =tool.Value.Offset.Value +Vector3.new(0,0,0.01)
    elseif tool.Value.Offset.Value.Z >Offset0.Z then
        tool.Value.Offset.Value =tool.Value.Offset.Value -Vector3.new(0,0,0.01)
    else
        FadeZ =true
    end
    wait()
end
print("Done!")
tool.Value.Offset.Value =Offset0

It dose fade, but it never stops fading, just moves back and forth at the end. Also, I'd need to be able to change how much it adds to the value, but still get the end Vector3. (to make it fade faster/slower)

I tried some weird division solution, but that went horribly wrong, so here I am. Thanks for your time.

1 answer

Log in to vote
0
Answered by 4 years ago

So, uh. Apparently you CAN Tween Vector3s... My bad, Sorry everyone.

0
@mbramblet you can also tween CFrames. BlackOrange3343 2676 — 4y
0
Ya, I've seen the entire list. You can Tween all sorts of stuff now! Guess I should've looked into it a little more before asking. mbramblet 80 — 4y
Ad

Answer this question