Forlapse
|
  |
| Joined: 07 Jan 2014 |
| Total Posts: 122 |
|
|
| 01 May 2016 07:31 PM |
Here's a simplified version of my animation:
function module.Animation() for i=1, 200 do w3.C0 = w3.C0:lerp(script.Parent.P1F1.CFrame,i/200)--CFrames the part to i/200 of the way there wait(0.00125)--Timed to take 0.25 seconds for the animation to be completed end end
After this animation is complete, I want to start the next one. Is there a way to do this within the same loop? Will something like: for i=200, 400 do work? |
|
|
| Report Abuse |
|
|
|
| 01 May 2016 07:37 PM |
just make another function that does the loop. and call it right after |
|
|
| Report Abuse |
|
|
Forlapse
|
  |
| Joined: 07 Jan 2014 |
| Total Posts: 122 |
|
|
| 01 May 2016 07:49 PM |
local i = 1
function module.Reload() for i=1, 200 do w2.C0 = w2.C0:lerp(script.Parent.A2Frame1.CFrame,i/200) w3.C0 = w3.C0:lerp(script.Parent.P1F1.CFrame,i/200) w4.C0 = w4.C0:lerp(script.Parent.P2F1.CFrame,i/200) w5.C0 = w5.C0:lerp(script.Parent.P3F1.CFrame,i/200) w6.C0 = w6.C0:lerp(script.Parent.P4F1.CFrame,i/200) w7.C0 = w7.C0:lerp(script.Parent.P5F1.CFrame,i/200) w8.C0 = w8.C0:lerp(script.Parent.P6F1.CFrame,i/200) w9.C0 = w9.C0:lerp(script.Parent.P7F1.CFrame,i/200) w10.C0 = w10.C0:lerp(script.Parent.P8F1.CFrame,i/200) w11.C0 = w11.C0:lerp(script.Parent.OutputF1.CFrame,i/200) wait(0.00125) if i == 200 then break end end
for i=200, 400 do w2.C0 = w2.C0:lerp(script.Parent.A2Frame2.CFrame,(i-200)/200) w3.C0 = w3.C0:lerp(script.Parent.P1F2.CFrame,(i-200)/200) w4.C0 = w4.C0:lerp(script.Parent.P2F2.CFrame,(i-200)/200) w5.C0 = w5.C0:lerp(script.Parent.P3F2.CFrame,(i-200)/200) w6.C0 = w6.C0:lerp(script.Parent.P4F2.CFrame,(i-200)/200) w7.C0 = w7.C0:lerp(script.Parent.P5F2.CFrame,(i-200)/200) w8.C0 = w8.C0:lerp(script.Parent.P6F2.CFrame,(i-200)/200) w9.C0 = w9.C0:lerp(script.Parent.P7F2.CFrame,(i-200)/200) w10.C0 = w10.C0:lerp(script.Parent.P8F2.CFrame,(i-200)/200) w11.C0 = w11.C0:lerp(script.Parent.OutputF2.CFrame,(i-200)/200) wait(0.00125) end
end
I added a second loop that begins right when the first loop ends, i=200. Only it doesn't begin right at i=200, it waits a few seconds. Why? |
|
|
| Report Abuse |
|
|
Forlapse
|
  |
| Joined: 07 Jan 2014 |
| Total Posts: 122 |
|
|
| 01 May 2016 07:52 PM |
| *** Some output testing revealed it actually does start on i=200, only the animation reaches its goal long before i=200. I want it so that when the last diget of the lerp is equal to one (i/200 in this case) it reaches its goal. Is this a lerp problem? |
|
|
| Report Abuse |
|
|
|
| 01 May 2016 07:59 PM |
| From what I know the quickest you can wait for is 0.03 seconds or 1/30th of a second. You can have an event that is even quicker though (1/60th of a second or 0.017 seconds) which is the RenderStepped event of RunService. That's the smallest waiting time though. I don't think you can have wait(0.00125) without it defaulting to 0.03. |
|
|
| Report Abuse |
|
|
sayhisam1
|
  |
| Joined: 25 Nov 2009 |
| Total Posts: 2092 |
|
|
| 01 May 2016 08:04 PM |
Yeah I think that's how it works as well. I don't think you would need more than 1/60th of a second though- that is the speed the game is rendered at, so that should result in the most fluid looking animation. However, if you want to speed up your animation, I suggest skipping frames - Implement something in your code that skips every other frame (using the module function already built into lua) and it will render twice as fast, and you can keep skipping to make it even faster. Or you can just increase the amount you lerp by.
|
|
|
| Report Abuse |
|
|
Forlapse
|
  |
| Joined: 07 Jan 2014 |
| Total Posts: 122 |
|
|
| 01 May 2016 08:07 PM |
Thankyou, that just saved me a HUGE headache. I tested it for only i=10 with wait(0.1) and it worked flawlessly :D
(Well it looked ugly, but you get the idea)
I'll play around with the numbers to get it to render better, thanks again guys! |
|
|
| Report Abuse |
|
|
| |
|
sayhisam1
|
  |
| Joined: 25 Nov 2009 |
| Total Posts: 2092 |
|
|
| 01 May 2016 08:09 PM |
Also I would suggest putting all the stuff you are lerping into a table (defined before the loop), and just looping through a table 200 times instead of manually typing out all of the stuff you are lerping. Just a thought - makes it easier to add new things to lerp, and looks neater in the long run.
|
|
|
| Report Abuse |
|
|
Forlapse
|
  |
| Joined: 07 Jan 2014 |
| Total Posts: 122 |
|
|
| 01 May 2016 08:31 PM |
if step == 0 then for i=1, 30 do w2.C0 = w2.C0:lerp(script.Parent.A2Frame1.CFrame,i/30) w3.C0 = w3.C0:lerp(script.Parent.P1F1.CFrame,i/30) w4.C0 = w4.C0:lerp(script.Parent.P2F1.CFrame,i/30) w5.C0 = w5.C0:lerp(script.Parent.P3F1.CFrame,i/30) w6.C0 = w6.C0:lerp(script.Parent.P4F1.CFrame,i/30) w7.C0 = w7.C0:lerp(script.Parent.P5F1.CFrame,i/30) w8.C0 = w8.C0:lerp(script.Parent.P6F1.CFrame,i/30) w9.C0 = w9.C0:lerp(script.Parent.P7F1.CFrame,1) w10.C0 = w10.C0:lerp(script.Parent.P8F1.CFrame,i/30) w11.C0 = w11.C0:lerp(script.Parent.OutputF1.CFrame,i/30) print(i) wait(1) if i == 30 then print("End first animation") step = 1 break end end end
Perhaps it wasn't that simple... I set wait = 1 to remove that variable, but it still seems to reach its goal around i=12. I set one random weld to 1, and as expected, it instantly reaches its goal... Is there something else at work here?
|
|
|
| Report Abuse |
|
|
|
| 01 May 2016 08:33 PM |
| Can someone explain welding to me ;-; DON'T LINK ME TO ROBLOX WIKI!! |
|
|
| Report Abuse |
|
|
Forlapse
|
  |
| Joined: 07 Jan 2014 |
| Total Posts: 122 |
|
|
| 01 May 2016 08:42 PM |
Well, I figured something out... Its just exponentially decreasing in the ammount it moves by because its resetting the value of w3.C0 each frame! So here we have another instance of an accidental discovery of the natural number e...
As to help sombody in this almost mess of a script, heres my best explaination of welding:
local w1 = Instance.new("ManualWeld")--1 w1.Parent = script.Parent--2 w1.Part0 = script.Parent.Handle--3 w1.Part1 = script.Parent.Part--4 w1.C0 = CFrame.new(X, Y, Z)*CFrame.Angles(Xrad,Yrad,Zrad)--5
Line one creates the weld Line 2 Places the weld inside of the model (The model being the parent of the script) Line 3 sets "Handle" as your standard. Everything you weld will follow this part relative to your offset point. Line 4 Says what part you want welded to "Handle" Line 5 is where you want it relative to "Handle". So:
w1.C0 = CFrame.new(0, 0, 5)
Will make that part hover above the Handle exactly 5 studs up.
CFrame.Angles(Xrad,Yrad,Zrad) Represents, in radians, the angle of rotation you want the Part relative to the handle. So if you want it facing 90 degrees to the right, you would change Y, (or whatever axis of rotation that would be) to Pi/2 |
|
|
| Report Abuse |
|
|
|
| 01 May 2016 08:47 PM |
| ;-; I cri... I don't get the last line... ;-; |
|
|
| Report Abuse |
|
|
|
| 01 May 2016 08:49 PM |
| So if i wanted it 90* i would do pi/4? |
|
|
| Report Abuse |
|
|