Wittiest
|
  |
| Joined: 02 Mar 2009 |
| Total Posts: 9665 |
|
|
| 20 Feb 2016 12:35 AM |
How can I use RenderStepped to make my function wait 1/60th of a second in each step for my for loop?
|
|
|
| Report Abuse |
|
|
|
| 20 Feb 2016 12:38 AM |
local rs = game:GetService("RunService")
for i = 0,60 do print(i) rs.RenderStepped:wait() end |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 20 Feb 2016 12:38 AM |
| game:GetService'RunService'.RenderStepped:wait() |
|
|
| Report Abuse |
|
|
Wittiest
|
  |
| Joined: 02 Mar 2009 |
| Total Posts: 9665 |
|
|
| 20 Feb 2016 12:39 AM |
So this will essentially make a :wait() that is 1/60 of a second instead of 1/30?
|
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 20 Feb 2016 12:41 AM |
RenderStepped fires every time a frame is rendered, so it isn't a guarantee for it to be 60 times a second, but it has the potential since the maximum fps for roblox is 60.
But using :wait() doesn't mean it waits that amount of time, what is actually happening is :wait() is yielding until that event is fired. If you used workspace.DescendantAdded:wait() print'ye' it would wait until an instance is added to the workspace and then print 'ye' |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2016 12:41 AM |
| (kind of?) Isn't this dependent on the clients frame rate? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Feb 2016 12:48 AM |
| Yes but you keep track of how long it took and alter your calculations accordingly |
|
|
| Report Abuse |
|
|
DrHaximus
|
  |
| Joined: 22 Nov 2011 |
| Total Posts: 8410 |
|
|
| 20 Feb 2016 12:50 AM |
as cntkillme said, you can record the deltatime between frames and take any framerate spiking into account
that said, you shouldn't really rely on a perfect framerate :p |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 20 Feb 2016 12:54 AM |
| @Dr, bb y must u label it as delta time qq |
|
|
| Report Abuse |
|
|