Search Unity

Horrible lag in 2d roguelike character movement

Discussion in '2D' started by Fragmental, Nov 7, 2015.

  1. Fragmental

    Fragmental

    Joined:
    Jun 30, 2013
    Posts:
    61
    I'm using a modified version of the game from the 2d Roguelike Tutorial . I've made only slight modifications to the original scripts. I've mainly added new UI elements and scripts to handle those UI elements.

    I'm having issues with character movement. In the editor, the characters will mostly move fine, but when I build, all of the characters move, VERY slowly. It takes roughly two full seconds for a character to move into position. Everything else seems to run at full speed, but the cpu usage in the build is much higher than in the editor.

    Also, even in the editor, there are still sometimes issues with the player character kind of weaving around and not staying square on a tile, so that if you walk by food it will pick up food on both tiles, etc.
    I don't know why any of this happening. There doesn't seem to be any bugs in my code that would cause this, and I don't know why movement would be so much slower in the build rather than the editor, or why cpu usage would jump.Any ideas about what might be causing this?

    edit:
    here's an example of the slow movement in the build. The character also doesn't seem to always stay within the bounds of the tiles and weaves just as it did in the editor, only much slower.

    and here's an example of the the weaving the player does in the editor.

    The character also glides from position to position without stop when holding the button down. And when checking the completed project today, the character seems to stop briefly before going on to the next tile when the button is held down. This behavior seems somewhat random, because even with nothing changed, the player will sometimes move normally.

    You can see more about the project at http://www.fragmentalstew.com/
    This is a demonstration of the game:


    The license of the Roguelike tutorial prevents me from redistributing the project, but I may be able to give you access to to the project if you message or email me.

    Here is a link to download the debug build
     
    Last edited: Nov 7, 2015
  2. Fragmental

    Fragmental

    Joined:
    Jun 30, 2013
    Posts:
    61
    I finally resolved this today by exporting all of my assets, with dependencies to a unitypackage. Then I created a new project and imported the package. I then closed unity(not sure closing was necessary just did it anyway) and copied the tagmanager.asset folder from the project settings of the original project to the new project. I then opened unity back up, updated the build settings in the new project, and built the project and everything seems to be working perfectly. At first there was a few issues with lines across the game board but it seemed to resolve itself when I updated the build settings.

    I think there was something wrong with the project itself. I've had multiple odd issues that clued me in to an issue with the project. I don't know if it happened during a unity upgrade or a crash of unity or when the computer crashed or during a hard shutdown or what. I just know that it's working now.
     
  3. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    From what I remember it use's fairly convoluted code to achieve the simple movement and gameplay which caused similar problems for others, including myself. I know when I went through it a while ago there were plenty of distressed people in the comments section :).

    It did use some interesting techniques but I felt like the same could have been achieved in a more readable, intuitive, and less error prone way.