trying to determine what is causing infrequent choppy gameplay

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.

Comments

  • mataruamatarua Auckland, New ZealandMember Posts: 854
    Spawns loading new data in to memory can cause slow down and frame drops.

    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@
  • @matarua
    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.

    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.
    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.
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    A nested rule is when you put a rule inside a rule and even again inside a rule.

    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@
  • So what is more efficient for rules within rules? For example lets say I have an actor that I don't want to do any behaviors till an attribute self.start is true. Is it better to make one rule saying if self.start is true then.. and place all the behaviors within this rule so Gamesalad is checking this rule once then doing the other behaviors? Or is it better to add if self.start is true as another check within all the other rules I have set up?
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    I was going to say you have bloated code. And yes rules within rules are better as it will bypass the other code in the scan. Every time you add an attribute to a rule it needs to be scanned at each rule rather than once when you nest inside a main rule. So if you have code you want blocked by game.start make a rule with game.start only and put the other stuff in it. Efficient code is the only true way to get smooth gameplay. See my video on integrated code.
  • @fryingbaconstudios thanks for the response and answer about rules. Question about bloated code, I believe that my ram usage is pretty low for me to be experiencing the little bit of lag at times. Does bloated code usually result in higher ram usage from the engine, or just non smooth gameplay like I am experiencing?
    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.
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    A single nest for your wee codelings is fine - more than that and things can get a bit hairy - I know that as I had rules not firing, so I had to bring them up one level and put two conditions on them - really it also depends on the game tho. With the game where I had that problem, it has many many things going so it's quite at the limit of GameSalad, well it was over the limit actually, and I had to bring it back. That was my optimising job and I learnt a lot doing that.

    Dave is right on with the nesting advice there, all good, cheers, M@

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Lag is usually a result of longer code scans not memory. Memory overloads cause crashes not lag. When the machine has more code to scan it takes longer to recognize the changes this is called lag or a time lapse. The more bloated and over burdened your code is the more lag one has as it makes the scan longer. The more efficient and organized your code is the shorter the scan will be resulting in faster recognition of variable changes. When I worked on some scanning for table searches it became evident long code sections slowed the process. We solved this by breaking the code into groups and separating them in different actors allowing for a more efficient scan which greatly reduced the scan time of the table search. Most GS user don't really understand how to design highly efficient code. They just see a video and add that code and on and on. This type of coding is not integrated at all and leads to lag and code conflicts. Again see the video I referenced to get an idea of the concept of intergraded code.
  • @fryingbaconstudios thanks that make sense and points me in the right direction. I watched your video last night, it was helpful. I believe I have done a decent job implementing the concept especially since I have figured everything out an written my own code rather than copying and pasting code, however I obviously need to do better and hopefully can point out some areas that can be simplified. You say moving code into different actors can help? My main character has quite a bit of code within him, perhaps I can find which code isn't necessary to be performed by that actor.
    Again thanks for taking the time to explain this will help me a lot.
  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659
    edited December 2013
    Here is a question about efficiency.
    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
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited December 2013
    Just try to observe what is happening when it lags.
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    Lag is usually a result of longer code scans not memory. Memory overloads cause crashes not lag. When the machine has more code to scan it takes longer to recognize the changes this is called lag or a time lapse. The more bloated and over burdened your code is the more lag one has as it makes the scan longer. The more efficient and organized your code is the shorter the scan will be resulting in faster recognition of variable changes. When I worked on some scanning for table searches it became evident long code sections slowed the process. We solved this by breaking the code into groups and separating them in different actors allowing for a more efficient scan which greatly reduced the scan time of the table search. Most GS user don't really understand how to design highly efficient code. They just see a video and add that code and on and on. This type of coding is not integrated at all and leads to lag and code conflicts. Again see the video I referenced to get an idea of the concept of intergraded code.
    Cheers, M@
  • Thanks guys really appreciate you taking the time to help, sorry I keep asking so many questions, just making a lot of changes but not seeing great results. I did realize that the game seems to run really smooth the first 1 or 2 times through a level then you start noticing the points with lag. Any insight what that could mean? I have it so it goes to a pause screen when you die or beat the level then if you hit retry it resets the scene as well as all the necessary attributes, not sure if this could mean certain processes are piling up on each other, doesn't make sense to me since everything is being reset.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    have you looked at it using Xcode instruments? I have a video on it.
  • @fryingbaconstudios
    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
Sign In or Register to comment.