trying to determine what is causing infrequent choppy gameplay
RossmanBrothersGames
Member Posts: 659
Hey everyone, I would greatly appreciate the help of some of you who have been using gamesalad a bit longer than me. I am trying to determine why at times my game gets a little bit choppy. Not extremely noticeably but enough to bug me and make the game not feel completely smooth. Really it comes every once and a while at it is basically a split second lag or delay that doesn't really hamper gameplay, its just annoying. My game is using retro style low res graphics, so not using resolution independence. While testing total ram usage goes from 35-45 MB, images:2-3 mb sounds: 50 KB Engine: 9-10 MB Other: 29-33 MB. FPS stays around 56-60. Playing on an iPhone 5s
My game is a auto-runner platformed, (not endless runner) kind of like rayman, but with small 20 second levels. Fast paced, character can shoot which spawn a bullet, jump on enemies heads, when enemies are destroyed they spawn an actor with a particle explosion. I do have a lot of percise controls, such as double tap controls. And the main character is made up of 4 actors constrained to eachother, however when I test without the 4 actors I still get the same results so the issue I believe isnt there. For the camera I have an invisible actor constrained to the main actors x controlling the camera, the camera never moves vertically. I have buttons on a nonscrolling layer. I usually only have like a max of 4 enemies on the screen at a given time, and have changed it so they are destoryed once leaving the screen.
I believe my code is pretty efficient, even after this problem I have gone through and found areas where I was able to shorten the code to accomplish the same thing, and when through all my actors did that. I am using timers are for chumps method for just about all my timing. But with all this I must be missing something. With only 35-45 ram usage playing on an iphone 5s I would think I should getting really smooth gameplay. Any ideas for some common causes that some of you veterans know to look for in a situation like this? Since the ram usage is low could it possibly be some way that I am controlling the camera or something else? Any help would be very appreciated, I have put a lot of work into this game and hope I can overcome this problem.
My game is a auto-runner platformed, (not endless runner) kind of like rayman, but with small 20 second levels. Fast paced, character can shoot which spawn a bullet, jump on enemies heads, when enemies are destroyed they spawn an actor with a particle explosion. I do have a lot of percise controls, such as double tap controls. And the main character is made up of 4 actors constrained to eachother, however when I test without the 4 actors I still get the same results so the issue I believe isnt there. For the camera I have an invisible actor constrained to the main actors x controlling the camera, the camera never moves vertically. I have buttons on a nonscrolling layer. I usually only have like a max of 4 enemies on the screen at a given time, and have changed it so they are destoryed once leaving the screen.
I believe my code is pretty efficient, even after this problem I have gone through and found areas where I was able to shorten the code to accomplish the same thing, and when through all my actors did that. I am using timers are for chumps method for just about all my timing. But with all this I must be missing something. With only 35-45 ram usage playing on an iphone 5s I would think I should getting really smooth gameplay. Any ideas for some common causes that some of you veterans know to look for in a situation like this? Since the ram usage is low could it possibly be some way that I am controlling the camera or something else? Any help would be very appreciated, I have put a lot of work into this game and hope I can overcome this problem.
Comments
One thing early on that I found was if an actor is animating over a lot of layers it can also make play a bit choppy. I learnt this when actually building my scene within Gamesalad, now I just use flat tiles and a background.
Timers - some people swear they are ok some people hate them, I try to use the clock time as much as possible like the chumps method rather than create a timer but I still use them now and then.
Are you destroying things as they go off stage? If they just keep on going off to infinity they are going to build up?
It could be down to something I am little confused with, the four actors are an animating running thing? Do you have to have another separate actor just to constrain the camera to which is in itself a three step process when only two is needed? Not sure there may be reasons for that. Can't say without seeing it sorry.
Do you have any nested rules? They sometimes do not fire - or could cause a slowdown.
Is your phone checking for mail or something in the background (Slender Man perhaps) AAAAAAAAAAAGGGHHGH.
Anyway in all seriousness - to solve this, duplicate the project and delete half the actors and see if that fixes it - if it does - delete quarter - it comes back - you can narrow it down. That is an old task method to quickly go through a lot of data to find a bug in messed up html or something like that - these are better days and most text editors help you with that now. You are narrowing down your search - then destroy those nasty bugs.
Particles? Perhaps that could be it, they sometimes don't fire bang on time and you might be able to see if there's lots of particles screen at the time when it happens. Even tho they are designed to be memory friendly with a short life - is it as full on as this?
I have a game that is not as particle driven as this but is about as full on - but my explosions are flat images that spawn and flash for a brief moment. I also - if you can believe it am firing out way more bullets from the hero ship.
It has been an optimisation lesson for me this game. So I did that through the way I used my graphics and gamesalad together - I hit 330MB, got that down to 130 on this game so that's fine that you are 100MB less than that.
Are you in the viewer? Sometimes it can be a bit screwy and laggy. It needs a quit and a restart.
That's a long list but it's everything I could think of - Hope it might help
Cheers, M@
Thanks, I appreciate you taking the time to respond. Definitely gave me some things to think about.
To answer some things:
yes I am destroying enemies off screen. The main character is an invisible actor with controls, physics, and collisions. Then three animated actors so that animations can happen separate from eachother, for example one is a cape that moves based on the vertical velocity and seperate from what the body is doing, so when you go to shoot and the body animation changes the cape keeps going smooth.
However like I said when I remove the other two and just have the one animated actor I still get the same gameplay results, so I think this is not the problem.
And yes I have an actor that I constrain the camera to, it is an invisible actor that is constrained about 200 pixels in front of the main actor so that the character stays on the left of the screen. I spawn my main actor into each level so I don't have access to the scene.camera.x.
Maybe I will try playing with the camera on the main character just to see if this is the problem?
Also, what is a "nested" rule?
And this problem happens both in the viewer and ad hoc build.
Again thanks alot, maybe I can get a video up of the gameplay for people to look at and maybe give more insight if I cant fix it from some of these suggestions.
www.rossmanbrosgames.com
Are you spawning things on stage that could be using a bit of memory?
When I have had a choppy actor - just one - when the others were all fine I had 3 constrain attributes on it, and it was moving slowly - I changed one to a simple rotate and sped the cos sin equation up a bit and smooth now - too many constrains on the same actor can be an issue sometimes when things are busy and lots of other actors are doing the same.
Anyway, you just have to hunt around and investigate, maybe get the DBA Project Optimiser and run that over the project too.
Cheers, M@
www.rossmanbrosgames.com
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
I have worked on different game engines before, and actually watched part of your integrated logic video in the past and have tried to make sure I wasn't putting any unnecessary steps in my game. I think I've done a good job but obviously not good enough. I'll go back and watch your full video for some insight.
www.rossmanbrosgames.com
Dave is right on with the nesting advice there, all good, cheers, M@
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Again thanks for taking the time to explain this will help me a lot.
www.rossmanbrosgames.com
I have a number of actors that need to know the horizontal speed of my main character, so I constrain the x velocity to a game attribute. Really they just need to know if he is sprinting/jogging/or stopped behind something.
Would it be more efficient rather than constraining that attribute in one behavior to make a integer checking for these three states? I know that would introduce some rules but would it be more efficient than a constrain behavior?
For example
if velocity is 0, change attribute game.herovelocity to 0
otherwise
if velocity is less than 250 change attribute game.herovelocity to 1
otherwise
change attribute game.herovelocity to 2
www.rossmanbrosgames.com
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
www.rossmanbrosgames.com
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
thanks, watched your video, trying it out however it tells me "target failed to run: permission denied, The app must be signed with a development identity.
Very strange since obviously I was only able to put that app on their through my developer license...
hopefully I can figure it out
www.rossmanbrosgames.com