IlIll
|
  |
| Joined: 28 Aug 2011 |
| Total Posts: 896 |
|
|
| 26 Oct 2014 06:21 PM |
I just can't get it to work D: I'm new to tweening; it's the first time I've ever tried using lerp
local Vector3toColor3 = function(vec) return Color3.new(vec.x/255, vec.y/255, vec.z/255) end
local function Color3toVector3(col) return Vector3.new(col.r*255, col.g*255, col.b*255) end
local function addColor3(a1, a2) return Color3.new(a1.r+a2.r,a1.g+a2.g,a1.b+a2.b) end function _G.TweenFog(eC, alpha) local lighting = game.Lighting local startColor = Color3toVector3(lighting.FogColor) local endColor = Vector3.new(eC.r, eC.g, eC.b) local result = Vector3toColor3(startColor:lerp(endColor,alpha)) local increments = Color3.new(result.r/10, result.g/10, result.b/10) print(increments) for i = 1, 10 do lighting.FogColor = addColor3(lighting.FogColor, increments) wait() end end |
|
|
| Report Abuse |
|
|
IlIll
|
  |
| Joined: 28 Aug 2011 |
| Total Posts: 896 |
|
| |
|
anaIyze
|
  |
| Joined: 29 May 2014 |
| Total Posts: 2048 |
|
|
| 26 Oct 2014 06:58 PM |
| You're doing it wrong, noob. |
|
|
| Report Abuse |
|
|
IlIll
|
  |
| Joined: 28 Aug 2011 |
| Total Posts: 896 |
|
|
| 26 Oct 2014 06:59 PM |
| I said nevermind!! I figured out how to do it, noob. |
|
|
| Report Abuse |
|
|
anaIyze
|
  |
| Joined: 29 May 2014 |
| Total Posts: 2048 |
|
|
| 26 Oct 2014 07:32 PM |
"local function addColor3(a1, a2) return Color3.new(a1.r+a2.r,a1.g+a2.g,a1.b+a2.b) end function _G.TweenFog(eC, alpha) local lighting = game.Lighting local startColor = Color3toVector3(lighting.FogColor) local endColor = Vector3.new(eC.r, eC.g, eC.b) local result = Vector3toColor3(startColor:lerp(endColor,alpha)) local increments = Color3.new(result.r/10, result.g/10, result.b/10) print(increments) for i = 1, 10 do lighting.FogColor = addColor3(lighting.FogColor, increments) wait() end end"
for i=1,10 do wait''; game.Lighting.FogColor=Color3.new(game.Lighting.FogColor.r+.1,game.Lighting.FogColor.g,game.Lighting.FogColor.b); end; -- so on
Lol Learn to script Bud |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 26 Oct 2014 07:34 PM |
^ That's not the same
and wait" is ugly... |
|
|
| Report Abuse |
|
|
anaIyze
|
  |
| Joined: 29 May 2014 |
| Total Posts: 2048 |
|
|
| 26 Oct 2014 07:39 PM |
It's not the same? --// l=game.Lighting; spawn(function()while(wait'')do for i=1,10 do wait''; l.Ambient=Color3.new(l.Ambient.r+.1,l.Ambient.g,l.Ambient.b); end; for i=1,10 do wait''; l.Ambient=Color3.new(l.Ambient.r,l.Ambient.g+.1,l.Ambient.b); end; for i=1,10 do wait''; l.Ambient=Color3.new(l.Ambient.r,l.Ambient.g,l.Ambient.b+.1); end; for i=1,10 do wait''; l.Ambient=Color3.new(l.Ambient.r-.1,l.Ambient.g,l.Ambient.b); end; for i=1,10 do wait''; l.Ambient=Color3.new(l.Ambient.r,l.Ambient.g-.1,l.Ambient.b); end; for i=1,10 do wait''; l.Ambient=Color3.new(l.Ambient.r,l.Ambient.g,l.Ambient.b-.1); end;end;end);
|
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 26 Oct 2014 07:44 PM |
That will tween it up and down, so that would work if you configured it for something like (100,100,100) to (90,90,90) or even (100,100,100) to (100,100,90) but suppose you want to do (215,65,78) to (51,95,126)
You can do it with a for loop and division, but you should use lerp. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 26 Oct 2014 07:44 PM |
Extract...
local pow, sin, cos, pi, sqrt, abs, asin = math.pow, math.sin, math.cos, math.pi, math.sqrt, math.abs, math.asin
local function inOutQuad(t, b, c, d) t = t / d * 2 if t < 1 then return c / 2 * pow(t, 2) + b end return -c / 2 * ((t - 1) * (t - 3) - 1) + b end
local tStart = Color3.new() local tEnd = Color3.new(1,1,1) local object = game.Lighting local duration = 1 type = inOutQuad property = "FogColor" local diffR = tEnd.r - tStart.r; local diffB = tEnd.b - tStart.b; local diffG = tEnd.g - tStart.g; local nTime = 0; coroutine.wrap(function() while nTime < duration do nTime = nTime+wait(); object[property] = Color3.new( type(nTime, tStart.r, diffR, duration), type(nTime, tStart.g, diffG, duration), type(nTime, tStart.b, diffB, duration) ) end object[property] = tEnd end)()
-- Disclaimer: Might not work because I extracted it and cut it up from my tween library without even looking at your code |
|
|
| Report Abuse |
|
|
IlIll
|
  |
| Joined: 28 Aug 2011 |
| Total Posts: 896 |
|
|
| 26 Oct 2014 07:53 PM |
I said I already got it!!! It just didn't work the first time because I was unsure of how lerp worked.
local Vector3toColor3 = function(vec) return Color3.new(vec.x/255, vec.y/255, vec.z/255) end
function _G.TweenFogColor(eC) --[[ (Color3 in 255 range) Tweens the current fog color to eC; the end color. --]] local lighting = game.Lighting -- convert the endColor to a Vector3 value so it can be lerped local endColor = Vector3.new(eC.r, eC.g, eC.b) local changes = 15 for i = 1, changes do local sC = lighting.FogColor -- since FogColor uses tuples between [0,1], multiply it by 255 local startColor = Vector3.new(sC.r*255, sC.g*255, sC.b*255) lighting.FogColor = Vector3toColor3(startColor:lerp(endColor,(i/changes))) wait(.075) end end
|
|
|
| Report Abuse |
|
|