pyth_n
|
  |
| Joined: 21 Jun 2016 |
| Total Posts: 1322 |
|
|
| 22 Jul 2016 08:33 AM |
currently have animations that use lerp (client only) and it uses tick and renderframe along with a duration value;
is it inefficient to also have a framewait() (it seems to be closer to the actual duration than a regular wait() function
local frameWait = function(duration) local start = tick() repeat game:GetService('RunService').Heartbeat:wait() until tick() >= start + duration end
local start = tick() frameWait(1) local end = tick() print(end-start)
is closer to 1 than
local start = tick() wait(1) local end = tick() print(end-start)
- pyth_n |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2016 08:37 AM |
i think that's extra
just printed a wait(1) and got:
1.0081633567083
That's off by like 8/1000 of a second.
|
|
|
| Report Abuse |
|
|
pyth_n
|
  |
| Joined: 21 Jun 2016 |
| Total Posts: 1322 |
|
|
| 22 Jul 2016 08:39 AM |
it seemed to screw with things like my reload audio not perfectly matching up. seems much better with the framerate wait, but is it more inefficient?
- pyth_n |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2016 08:41 AM |
| if you really care so much about tiny fractions of a second then do you, but i would just use wait(1) |
|
|
| Report Abuse |
|
|
pyth_n
|
  |
| Joined: 21 Jun 2016 |
| Total Posts: 1322 |
|
|
| 22 Jul 2016 08:42 AM |
mk
what exactly goes on "behind the scenes" of the roblox wait() function, because I know that lua doesn't actually have a wait() function
- pyth_n |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2016 08:44 AM |
| the thread is delayed until 1 second has passed? idrk |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2016 08:44 AM |
| but why don't your audio and animation match up don't you play both at the same time? |
|
|
| Report Abuse |
|
|
pyth_n
|
  |
| Joined: 21 Jun 2016 |
| Total Posts: 1322 |
|
|
| 22 Jul 2016 08:45 AM |
It's not a roblox animation, I have set CFrame keyframes.
- pyth_n |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2016 08:46 AM |
| ok but don't you still run both at the same time??? |
|
|
| Report Abuse |
|
|
pyth_n
|
  |
| Joined: 21 Jun 2016 |
| Total Posts: 1322 |
|
|
| 22 Jul 2016 08:47 AM |
I do, and the wait() function seems to be incredibly variable.
- pyth_n |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2016 09:00 AM |
wait() is obviously more variable because it is a smaller amount of time
what i do is use tick() with wait(), but without making a custom wait function
for example, use tick() to see how much time has passed since the last frame, and move your animation along accordingly
|
|
|
| Report Abuse |
|
|
pyth_n
|
  |
| Joined: 21 Jun 2016 |
| Total Posts: 1322 |
|
|
| 22 Jul 2016 09:02 AM |
That's what I do. I have a function for animation, but for keyframe animation (which I only use for reloading, the function doesn't wait (which is necessary for other stuff I'm doing)
module.interpolateWeld = function(Weld,NewC1,easingStyle,Duration) spawn(function() math.randomseed(tick() * math.random() * math.random()) easingStyle = easingStyle or 'Linear' local NewCode = math.random(-1e9,1e9) if Weld:FindFirstChild('TweenIndication') then Weld:FindFirstChild('TweenIndication').Value = NewCode else local tweenIndication = Instance.new('NumberValue',Weld) tweenIndication.Name = 'TweenIndication' tweenIndication.Value = NewCode end local tweenIndication = Instance.new('NumberValue',Weld) local StartTime = tick() local StartC1 = Weld.C1 while game:GetService('RunService').RenderStepped:wait() do if Weld:FindFirstChild('TweenIndication').Value ~= NewCode then break end local alpha if tick() >= StartTime + Duration then alpha = 1 else alpha = (tick() - StartTime)/Duration end Weld.C1 = StartC1:lerp(NewC1,easingStyles[easingStyle](alpha,0,1,1)) if tick() >= StartTime + Duration or Weld:FindFirstChild('TweenIndication').Value ~= NewCode then break end end end) end
- pyth_n |
|
|
| Report Abuse |
|
|