Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 10 Jul 2014 01:19 PM |
Or has someone already made a tween function/method for parts?
Anyways, how would I tackle this problem? |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 10 Jul 2014 01:23 PM |
"Or has someone already made a tween function/method for parts?"
No duh. |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 10 Jul 2014 01:24 PM |
I'm thinking about using lerp method and getting alpha via sin/cos/tan.
|
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
| |
|
| |
|
|
| 10 Jul 2014 04:45 PM |
| yep, Crazyman32 wrote a tweening library which has more than what ROBLOX has, or if you still need better there are a few on github |
|
|
| Report Abuse |
|
|
bohdan77
|
  |
| Joined: 10 Aug 2008 |
| Total Posts: 7944 |
|
|
| 10 Jul 2014 05:03 PM |
| Eh, but ROBLOX doesn't have a tweening library...so anything would be better? |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2014 05:52 PM |
Well the best way would be this, this was written by stravant in a RBXDev thread This is a modulescript btw
-- Optimized CFrame interpolator module ~ by Stravant -- Based off of code by Treyreynolds posted on the Roblox Developer Forum
local fromAxisAngle = CFrame.fromAxisAngle local components = CFrame.new().components local inverse = CFrame.new().inverse local v3 = Vector3.new local acos = math.acos local sqrt = math.sqrt local invroot2 = 1/math.sqrt(2)
return function(c0, c1) -- (CFrame from, CFrame to) -> (float theta, (float fraction -> CFrame between)) -- The expanded matrix local _, _, _, xx, yx, zx, xy, yy, zy, xz, yz, zz = components(inverse(c0)*c1) -- The cos-theta of the axisAngles from local cosTheta = (xx + yy + zz - 1)/2 -- Rotation axis local rotationAxis = v3(yz-zy, zx-xz, xy-yx) -- The position to tween through local positionDelta = (c1.p - c0.p) -- Theta local theta; -- Catch degenerate cases if cosTheta >= 0.999 then -- Case same rotation, just return an interpolator over the positions return 0, function(t) return c0 + positionDelta*t end elseif cosTheta <= -0.999 then -- Case exactly opposite rotations, disambiguate theta = math.pi xx = (xx + 1) / 2 yy = (yy + 1) / 2 zz = (zz + 1) / 2 if xx > yy and xx > zz then if xx < 0.001 then rotationAxis = v3(0, invroot2, invroot2) else local x = sqrt(xx) xy = (xy + yx) / 4 xz = (xz + zx) / 4 rotationAxis = v3(x, xy/x, xz/x) end elseif yy > zz then if yy < 0.001 then rotationAxis = v3(invroot2, 0, invroot2) else local y = sqrt(yy) xy = (xy + yx) / 4 yz = (yz + zy) / 4 rotationAxis = v3(xy/y, y, yz/y) end else if zz < 0.001 then rotationAxis = v3(invroot2, invroot2, 0) else local z = sqrt(zz) xz = (xz + zx) / 4 yz = (yz + zy) / 4 rotationAxis = v3(xz/z, yz/z, z) end end else -- Normal case, get theta from cosTheta theta = acos(cosTheta) end -- Return the interpolator return theta, function(t) return c0*fromAxisAngle(rotationAxis, theta*t) + positionDelta*t end end
|
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 10 Jul 2014 10:42 PM |
I made one using coroutines and global functions a while back. It basically implements a tweening function into your game, and handles CFrame as well as angles:
http://www.roblox.com/Part-Tweening-Service-item?id=67222290 |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 07:15 AM |
| zzz .l. coroutine's to laggy noob ! |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 11 Jul 2014 09:13 AM |
@Tigre Right, my PC is probably way better than yours.
Really though, I ran that on my 6 year old craptop without lag. |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 11:31 AM |
I remember having a function like that, hold on.
function movePart(part, posx, posy) part.CFrame = CFrame.new(Vector3.new(posx.X.Scale, posy.Y.Scale, posx.Y.Scale)) end
function tweenPart(part, endPosition, dir, style, time) local frameXZ = Instance.new("Frame") local frameY = Instance.new("Frame") frameXZ.Parent = gui frameY.Parent = gui frameXZ.Position = UDim2.new(part.Position.X, 0, part.Position.Z, 0) frameY.Position = UDim2.new(0, 0, part.Position.Y, 0) frameXZ:TweenPosition(UDim2.new(endPosition.X, 0, endPosition.Z, 0), dir, style, time+.5) frameY:TweenPosition(UDim2.new(0, 0, endPosition.Y, 0), dir, style, time+.5) while wait() do movePart(part, frameXZ.Position, frameY.Position) if (frameXZ.Position.X.Scale == endPosition.X) and (frameXZ.Position.Y.Scale == endPosition.Z) and (frameY.Position.Y.Scale == endPosition.Y) then break end end part.Position = endPosition frameXZ:Destroy() frameXZ = nil frameY:Destroy() frameY = nil part = nil end
tweenPart(Workspace.Part,Vector3.new(0,10,0),"Out","Linear",3)
Something like that |
|
|
| Report Abuse |
|
|
Xeptix
|
  |
| Joined: 14 Mar 2013 |
| Total Posts: 1115 |
|
|
| 11 Jul 2014 12:07 PM |
@above
didn't work correctly, so I edited it up a bit and published it as a module.
http://www.roblox.com/TweenPart-function-item?id=165821246 |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 12:29 PM |
Oops (facepalm)
There is meant to be a line above the first function saying
local gui = Instance.new("ScreenGui",script) |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 02:18 PM |
@tigre Coroutines don't lag unless your doing something idiotic like running 5 while true do loops with 5 different coroutines. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 11 Jul 2014 02:22 PM |
| At most, my script runs 2 coroutines with 6 while true do loops. |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 02:23 PM |
| zzz .l. to mani coroutine lag mi game up to much to stop usin coroutien's and make no coroutine |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 11 Jul 2014 02:25 PM |
| Oops, I meant at most it runs 6 coroutines each containing a single for loop. |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Jul 2014 05:43 PM |
The previously posted script by stravant is actually a module he's published and has publicized as a reply to a few threads (both on RBXDev and Scripters).
http://www.roblox.com/CFrameInterpolator-Module-item?id=161739700 |
|
|
| Report Abuse |
|
|