GameMaker: Studio

GameMaker: Studio

データを表示:
Why Does My Game Lag?
Greetings everyone,

I'm hoping that someone can help me figure out why my game is lagging! I've only just started building with GM over the past few days and have put together a simple twin stick shooter game. I have moderate to advanced programming knowledge in general so picking up GML wasn't an issue, but this is my first time programming a game.

Iv'e uploaded the game to the workshop, which I will link below. I'm not sure if you can open my game in GM and dig through the code or not, but if not I will be happy tp provide the source files. The game isn't big, at all, so I am not sure why it's lagging so badly.

Iv'e tried stripping the game down, removing all the particles and most of the step events, but I still get the lag. The lag is not consistent, it happens at various times and I haven't been able to tie it down to a single thing. The game requires a gamepad, unfortunately I haven't gotten around to adding keyboard support yet, i'm almost wondering if that isn't what's causing the lag.

What's really strange is that when I run the game in debug mode and watch the FPS, even when I see the lag the FPS reports up in the multi-hundreds, so I don't understand... It happens in testing and with the final install. I have the game set to not interpolate colors, and setting it to v-sync did not fix the issue. And on the note of v-sync, when I enable it my FPS doesn't change in debug mode, I still see multi-hundred fps with it on, that can't be right?

Here's the game
http://steamcommunity.com/sharedfiles/filedetails/?id=497243396

Thank you
< >
1-8 / 8 のコメントを表示
Blind 2015年8月10日 13時47分 
You are supposed to see multi-hundred fps. Studio uses separate metrics for calculating the visual display speed and the actual frame buffer in the background. Much like when I play World of Warcraft I consistently get 200fps, but only 60 is displayed.

I didn't notice any lag after start up - which might be the only lag you are seeing. When a Studio project first runs it has to cache everything, this isn't unique to Studio - almost every game does this and is one of the reasons for lengthy introductory and credits sequences.

After the initial load there was no additional lag.

Things of note though, are, your screen resolution is gigantic - so it's using more resources to keep it active. I predict this will be an increasing problem in the new generation of developers who start their "jumping box game" in 4k resolution.

Secondly, I have a kickass CPU so I might not notice any lag that others might. It's always helpful to run your projects on a Potato for compatibility purposes.


And as a slight minor bug... you can multifire your weapons when you hold multiple weapon buttons, allowing for turbo-torpedos. Also, when an enemy ship dies their explosion continues to rotate to face you.
BBX, hey man, thanks for a great response. I am really confused about this lag though, as I am not sure what is causing it. I am getting intermittent intervals of lag every couple dozen or so seconds, but not always. Sometimes I might got a while and it's fine, and then suddenly it will start happening for a few seconds, then go back to normal, just come and go randomly.

I've literally stripped away everything except for the background image, the view that the player is set to, and the ability to move the player, that's it... No sound, no step events (other than the controls), no bullets, no particles, nothing... I still freaking get the lag! I don't understand, I would almost think it has something to do with a driver or something with how my pc renders gamemaker games or something, but other games run just fine.... So I really, really don't understand lol.
Daynar 2015年8月10日 23時39分 
I'm not sure if this is a professional only feature, but I would open it up in debug mode and run the profiler to see if anything specific is hogging cpu cycles.
Article into to the profiler
https://www.yoyogames.com/tech_blog/56
Thanks for the link Daynar, ill check it out.

On a positive note, I brought my game to work and tried it on my office computer which is incredibly slow and junky and the game ran just fine, no lag issues... which means it's gotta be my home pc, but that pc I'd pretty good and should be able to play the game without even the slightest lag.

4ghz 8 core amdfx
8gb ddr3 memory
2 radeon r9 270x (maybe crossfire enabled is the problem?)
Windows 8.1 64bit
Ahh I still don't understand why I am getting this lag at home, I checked out the profiler like you mentioned and while it is very informative it hasn't really helped me figure out why. My Min, Max, Avg FPS is 80, 811, 370 and the memory being used when I am seeing lag is only ~10mb (10,000k) so I really don't see why it would lag. I tested this with a new game, with only a single object to move around on screen, a single background image for reference, a room and a view to follow me around and I still got the lag. It wasn't as noticeable, but I would see get it infrequently just flying around.

What could be the issue here? I have all updated latest drivers for everything im sure.
What is the room speed for all the rooms in your game? That acts as a frame rate cap if you code your game based around that and not delta time. By default it will be 30. I tend to set it anywhere between 60-120. Don't set it too high though as it can cause issues with entire logic skipping around 200-300+ speeds and code will become ignored occasionally.

One other thing I think it could be is your processor. From what I've read up, game maker only uses a single core/process thread which really chokes how much performance you can expect from it. My tower can handle game maker no problems but my gaming laptop struggles sometimes even when I just turn on 3d drawing and don't render anything.
GproKaru の投稿を引用:
What is the room speed for all the rooms in your game? That acts as a frame rate cap if you code your game based around that and not delta time. By default it will be 30. I tend to set it anywhere between 60-120. Don't set it too high though as it can cause issues with entire logic skipping around 200-300+ speeds and code will become ignored occasionally.

This is ironic, I am actually just coming back here to post that I figured it out, and now I see that you have posted with the same thing I have come here to post. I had my room set to the default 30, but now that I have set it to 60 the game runs extremely smooth with no more stutters.

I still don't understand why I was seeing periodic lag. Sometimes it ran very smooth, so I don't see why that would fluctuate.
Ok last words for who still have the problem like me :
- Try to set your room speed to 120 or 240, and adapt your code for it, then the lags/"framerate drops" will disapear.
There is no logic reason to do it, but it works. I've a 960gtx and a i7 4Ghz, and my tiny 2d games in gamemaker have lags every 5-10 seconds, a big hard juicy lag very frustrating, and in gamemaker only when the speed is set to 60.
2 more things to know :
- you can set it even at 1920 fps (just be sure to set at a multiple of 60, so 240, 960, etc, why ? why not!), but your processor will work harder (i mean really) and can cause some bugs if you try 1920fps on a 2Ghz processor i presume.
- and you can change the speed in your code via the variable "room_speed = 120;", so you can change it in game via an option or a simple key.
< >
1-8 / 8 のコメントを表示
ページ毎: 1530 50

投稿日: 2015年8月10日 7時05分
投稿数: 8