Skip/Laggy performance instead of slow/steady?

Discussion and feedback on Construct 2

Post » Wed Oct 01, 2014 4:27 pm

My game can fluctuate from 45-60fps during play on an ipad2 using CJS. When the fps does fluctuate, it doesn't just smoothly slow down the game, it kind of skips/lags a bit. A lot of my game is determined by bullet speed on several objects coming at the player, along with backgrounds.

I'm trying to figure if there is a way to "smooth" out that slowness. In old arcade and NES games, when the screen got loaded with bad guys, the game would kind of slow down for a bit, is that possible in C2? Or do I just need to live with the jitterness or try to get the game running at 60fps consistently?

I feel like I missing an obvious optimization step.

My game is an infinite runner. Everything is moving towards the player. Backgrounds, boxes, tires, etc. If there is something I can look for, that would be great. I know I am not giving much to go off. Just imagine it as a bunch of different sized bullets constantly spawning off screen and heading towards the player :).
B
101
S
32
G
11
Posts: 1,546
Reputation: 21,727

Post » Wed Oct 01, 2014 5:12 pm

That's just how C2 handles bad performance...it skips frames instead of slowing down which, unfortunately, can cause some major problems. I also would rather have slow down..it's what people expect.

Maybe you can code it yourself using time scale?
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Wed Oct 01, 2014 5:18 pm

Hmm, maybe checking if fps drops below, set time scale, etc. I could, but I also have a slow motion power up I would need to configure. Might be worth it, I guess I could try.

Just not sure it will actually fix the issue.
B
101
S
32
G
11
Posts: 1,546
Reputation: 21,727

Post » Wed Oct 01, 2014 6:06 pm

@ArcadEd
Do you create / destroy object often ?
I wonder if it's the garbage collector kicks in and causing the stutter because of that.

If you did, I'd have a set number of objects and keep reusing it, instead of create / destroy.
For example once the bullet go off screen, move the same bullet in the new position instead of destroying & spawning new bullet.
B
34
S
13
G
8
Posts: 134
Reputation: 8,118

Post » Wed Oct 01, 2014 6:34 pm

Hmm, that's in interesting idea. Yeah, they do destroy and create often, but it's all random, how many are on screen.

I'll play around with some ideas, thanks.
B
101
S
32
G
11
Posts: 1,546
Reputation: 21,727

Post » Wed Oct 01, 2014 6:41 pm

Sometime ago I read some articles about smoothing dt to handle performance spikes.

I made this test with two jumping objects and discovered that the one using smooth dt had a much more precise jump height than the one using normal dt.

Here's the results:
Normal Scenario
Extreme Scenario

- The orange object uses normal dt and the blue smooth dt.
- The orange and blue lines at the top are the maximum height of the last jump.
- The semi-transparent boxes around the lines indicate how much the jump height has drifted in the last jumps.

Notice that the jump height of the object with smooth dt barely drift compared with the one using normal dt.
What happens is that it creates some micro slow-downs or speed-ups on the object the more dt oscillates, that results in a more constant position increment.

Maybe it can help solve your problem.

I used a pretty naive smoothing, but there's better methods that take more frames into consideration and may give better results. The way I implemented doesn't work with behaviors, but I think it's possible to set the global timescale to (smoothDt/dt) and it will work with everything. Maybe you should give it a try.

Here's the capx:
prr-smooth-deltatime-02.capx

*It uses the Canvas plugin.
**For some reason it's not rendering the dt graph correctly in Firefox, but it works in Chrome.
You do not have the required permissions to view the files attached to this post.
Scirra Employee
B
154
S
53
G
17
Posts: 710
Reputation: 17,850

Post » Wed Oct 01, 2014 6:56 pm

Thanks for the info. I'll look over it.

The problem does not happen on a samsung tablet, but I believe this tablet has more memory(RAM) and the fps never drops below 60.

My game is using a lot of memory, debug shows it around 130mb during game time. Could be a factor.
B
101
S
32
G
11
Posts: 1,546
Reputation: 21,727

Post » Thu Oct 02, 2014 9:17 am

I'm having a similar problem; the FPS fluctuates and when it gets bad some of my important events aren't triggered!
B
11
S
3
Posts: 135
Reputation: 1,309

Post » Thu Oct 02, 2014 10:17 am

@Animmaniac
How would you use smoothDt/dt to control global time scale exactly? I've tried both 'Set time scale to 6 * (smoothDt/dt)', and just 'Set to smoothDt/dt'. All I get is a white screen :P
B
39
S
16
G
6
Posts: 543
Reputation: 7,619


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 3 guests