FPS drop affecting speed / collisions

Discussion and feedback on Construct 2

Post » Tue Jan 21, 2014 3:30 pm

Edit 3 : Even after coming up with a bit of a hack to solve this, I'm still dealing with game breaking behavior due to spikes / lag in FPS. ;-;

Edit 2 : My final solution >>> So I tried a few things, but nothing was working well... then it finally hit me!

I looked at the FPS dip that was causing the problems (surprisingly started as low as 55 fps) ... and implemented a very minor time scale slowdown (0.9) when the game went below 55 fps.

It fixed everything! While I appreciate what C2 does to try and make a game run smoothly when FPS drops, it's going to look choppy regardless, so I'd rather it be a tad slower and work well then choppy and be wonky at different frame rates. :3

I know it's a bit of a hack, but it works well for my purposes and fits the retro nature of the game! :D




Edit : I think I found a decent answer to my problem here : http://www.scirra.com/forum/deltatime-and-framerate_topic49729.html

I am incredibly new and wasn't sure what to search to see if this has been brought up before.

I'm creating an action platformer that relies on quick movements and knives that stick into walls.

The current online demo can be found here : www.deviever.com

The thing is, I have noticed that if I have a program, like bandicam or xsplit recording while I am playing the game online in browser, specifically in Fire Fox (I haven't tried other browsers yet... the sprites collisions work MUCH differently, often times falling through walls, flying through walls, etc. etc.

The game definitely seems to be running a little more slowly with those programs on, and I'd be totally okay with that, but on top of the slow down / jerkiness is this weird collision behavior.

Anyhow. Thank you advance! C2 has been an amazing inspiration for me as a budding developer, and I appreciate any words of wisdom / advice ya'll have to offer!

deviever2014-02-06 14:05:44
B
5
S
1
Posts: 24
Reputation: 423

Post » Tue Jan 21, 2014 4:01 pm

Fun game. Here's a few things to consider.

- Most of C2 games runs on the GPU. Those screen recording tools likely run on the GPU also. So, they would affect each other.
- Have you properly set the collision polygon? (When you double-click on a sprite, the bottom-left tool/icon allows you to do this.)
- As you may know already, animations (like throwing knives) are not perfectly smooth. They are typically around 30 or 60 frames/images per second. For each frame, the location of the knife is calculated and sometimes it skips quite a few pixels. The moving sprite will skip more pixels the faster it is moving, and the slower the frames per second (fps) is. Sometimes, so many pixels are skipped that the knife sprite will go all the way through the wall.


Having said all that, I think it's a good game. I wouldn't have called that a bug where the knives going inside the blocks. But, I didn't try it on a "slow" machine either.
B
20
S
4
G
1
Posts: 185
Reputation: 2,563

Post » Tue Jan 21, 2014 4:47 pm

Thanks for the response!

The knives sticking in the walls are a designed part of the game. The collision polygons have all been set correctly, and I'm aware that when things are moving quickly they will simply skip a bunch of pixels (and thus will not detect collision if it's going fast enough).

What it "feels" like is happening, is that when the recording programs are on, the game is "skipping steps"... so that where normally a knife would collide with a wall and thus triggering its speed to 0 (the way I get them to stick), it instead flies right through the wall.

Either that, or the weird performance issues make it such that the speed of everything is increased in a way it normally wouldn't be.... if no one else is having the same issues, I'll do some debugging to get back to everyone with more concrete performance figures.

The same thing happens with sprites that have the platformer behavior.

For instance, if the main character is falling fast enough and the recording programs are on, thus making everything jerky (inconsistent fps?) where the character would normally collide with the ground and stop, they'll just fall straight through.

The same thing happens with the ninja characters that are flying towards you... when you throw a knife at them (which is also going pretty fast), they would normally collide with no problem... instead they fly past each other with no hint of a collision what-so-ever.

Maybe this is what you were saying, about the FPS affecting such things, but I was under the impression that a changing FPS would simply mean the program would run slower... not affect the physics / collision of the game.

I hope that makes sense, and thanks again!deviever2014-01-21 16:54:37
B
5
S
1
Posts: 24
Reputation: 423

Post » Tue Jan 21, 2014 4:48 pm

If it would help, I could record video... ha ha, after all, recording video is how I realized there is a problem!
B
5
S
1
Posts: 24
Reputation: 423

Post » Tue Jan 21, 2014 5:16 pm

I have not tried the game but, If you are using bullet behavior for the knives it uses delta time to calculate pixels moved per tick, so a lower frame rate will result it it moving more pixels each tick, if that is more than the width of the wall then it could glide right through without a collision being detected.

You can counter this by either making the sprite hitbox larger, slowing the knives down or making the wall thicker... a combination of all three would probably be best...
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Tue Jan 21, 2014 5:36 pm

[QUOTE=Pixel perfick] I have not tried the game but, If you are using bullet behavior for the knives it uses delta time to calculate pixels moved per tick, so a lower frame rate will result it it moving more pixels each tick, if that is more than the width of the wall then it could glide right through without a collision being detected.

You can counter this by either making the sprite hitbox larger, slowing the knives down or making the wall thicker... a combination of all three would probably be best... [/QUOTE]

Thanks!

That definitely explains part of the problem, but the main character is also being affected when they fall.

So I'm guessing it's the same kind of calculation problem?

Unfortunately making walls thicker / hitboxes larger is going to create more problems then they'll solve, especially since I intended on having the game contain precision based fighting / puzzle mechanics.

Is there no way to lock in a certain FPS?

I find it kinda odd that there'd be such a game breaking mechanic built into the engine.

I was very excited at the prospect of having browser based games, and LP'ers these days are an important part of getting the word out about games, but if having them record a game will ultimately change the way the game behaves... well, it obviously makes for a pretty bad situation.

More than anything, I want a level of consistency and reliable expectations across platforms in terms of collision behavior. I don't mind the FPS dipping down on slower setups and the game being a bit choppy, but if the game acts completely differently / becomes unplayable... well, I'm sure you can understand my concern.deviever2014-01-21 17:39:50
B
5
S
1
Posts: 24
Reputation: 423

Post » Tue Jan 21, 2014 5:46 pm

I think I may have found a more specific answer to my problems here : http://www.scirra.com/forum/deltatime-and-framerate_topic49729.html
B
5
S
1
Posts: 24
Reputation: 423

Post » Tue Jan 21, 2014 6:07 pm

played the game, like the pixel retro look...

The knives are very fast and small, you could make the collision box larger without increasing the size of the actual graphic, just increase the canvas size,with bounding box collision, same goes for the walls...
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Wed Jan 22, 2014 10:02 am

So I tried a few things, but nothing was working well... then it finally hit me!

I looked at the FPS dip that was causing the problems (surprisingly started as low as 55 fps) ... and implemented a very minor time scale slowdown (0.9) when the game went below 55 fps.

It fixed everything! While I appreciate what C2 does to try and make a game run smoothly when FPS drops, it's going to look choppy regardless, so I'd rather it be a tad slower and work well then choppy and be wonky at different frame rates. :3

I know it's a bit of a hack, but it works well for my purposes and fits the retro nature of the game! :D

B
5
S
1
Posts: 24
Reputation: 423

Post » Wed Jan 22, 2014 2:03 pm

@deviever your game is cool i also like the retro
B
7
S
2
Posts: 44
Reputation: 668

Next

Return to Construct 2 General

Who is online

Users browsing this forum: paradine and 2 guests