cxcharlie
|
  |
| Joined: 26 Aug 2009 |
| Total Posts: 1414 |
|
|
| 16 Sep 2015 06:12 PM |
So I am running a RenderStpped function like this:
function() ... --print(type(CUBE_COLLISION)) >function --print(#BASE.Bin:GetChildren()) >1 print't' ocal z=(BASE.Bin.Part) print(CUBE_COLLISION(z.CFrame,z.Size,c+sub,MODEL_SIZE,true)) print'q' ... Where CUBE_COLLISION is a pretty expensive function, but the problem is that after using the expensive function, the loop restarts and does not return a value to the function.
The function is required from a module (specifically AxisAngle's box collision module: pastebin/xt0f1PpK
Why does it not return any value not even an error? Is it because it takes too long to calculate before the next frame? |
|
|
| Report Abuse |
|
|
cxcharlie
|
  |
| Joined: 26 Aug 2009 |
| Total Posts: 1414 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Sep 2015 06:23 PM |
Whenever I'm working with renderstepped, I do something like:
local last = tick(); while renderSteppedEvent:wait() do local dt = tick() - last; -- only if 'lost time' is important last = tick() -- do stuff end |
|
|
| Report Abuse |
|
|
Scripth
|
  |
| Joined: 23 Jun 2013 |
| Total Posts: 1724 |
|
|
| 16 Sep 2015 06:25 PM |
no need to do that anymore cntkillme they added a very very nice return value from the RenderStepped event game:service('RunService').RenderStepped:connect(function(step) end) step represents the difference of time between this step and the last |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Sep 2015 06:27 PM |
| But the thing is, if your code takes more than ~60th of a second then won't your function be called yet again in a new thread? Mine prevents that (basically a debounce without the overhead) |
|
|
| Report Abuse |
|
|
Scripth
|
  |
| Joined: 23 Jun 2013 |
| Total Posts: 1724 |
|
|
| 16 Sep 2015 06:29 PM |
| true, depends on how he's going to use it though |
|
|
| Report Abuse |
|
|
cxcharlie
|
  |
| Joined: 26 Aug 2009 |
| Total Posts: 1414 |
|
|
| 16 Sep 2015 06:48 PM |
| Yeah that's what I thought was happening; I was using scripth's method before hand and because of the expense there was not enough time to yield anything... :/ |
|
|
| Report Abuse |
|
|