• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Fragmental · Nov 09, 2015 at 11:06 AM · 2dlagtopdownroguelike

Horrible lag in 2d roguelike character movement

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?

https://youtu.be/RKtuwGfCxGk 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.

https://youtu.be/6RyJNPqkNq4 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: https://youtu.be/FyUlUlBhzqs

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fragmental · Apr 20, 2017 at 10:22 AM 0
Share

So....this bug is back, but in a much later version, after I've made a lot of changes. Except this time the fix I did previously doesn't work. Additionally, character movement seems fine in the editor, only not in the build. :/

6 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by o-super · Nov 11, 2015 at 01:20 AM

Hello FragMental,

I had the exact same issue tonight while reaching the step 11 of the tutorial. I tried to build the game for windows and my unity stoped working. I killed the process and launched a new instance of unity.

The only loss I had in the process was my "Main Camera" parameters and the Player who disapeared from my hierarchy. I linked back my GameManager prefabs to the Main Camera and put my Player prebad in the hierarchi and here we go, problem solved.

The only one advise I could give you is to try to create a new scene, remake the steps I did and try.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fragmental · Nov 11, 2015 at 03:57 AM 0
Share

Your characters in the game were moving slowly? Your player was weaving and not staying inside the tiles?

Building works fine for me, it's just the performance after the game is built that is an issue. There are a few issues with movement even in the editor, however.

I have a lot of UI and code additions so redoing the whole thing would be a big ordeal. Any one of the videos will show you what it looks like. You did give me an idea though. I wonder if I could prefab my UI elements and then import them back into a new scene to skip a lot of the work. Then I could rebuild the scene and see if it still has the same performance issues. That's still a lot of work, even if I can do that. I don't know if will, but it might be worth a try, since I'm currently completely stuck.

avatar image o-super Fragmental · Nov 11, 2015 at 02:36 PM 1
Share

Hey back,

Yes my characters were moving slowly and the player was weaving and not staying inside the tiles. The entire application was running slow and because of this I could move my player before the end of his previous move causing the player to end on a bad location.

In fact I reproduced this problem multiple times, it always happens when I test the game in the Unity IDE after recovering my windows session from a SLEEP mode.

To be clear, If I turn off my PC in sleep mode with Unity open, the next time I turn on my PC I will have to close my Unity and start a new one to make it work properly.

avatar image o-super Fragmental · Nov 12, 2015 at 01:04 AM 1
Share

Another thing, I did another mistake that could be related to the problem (not sure). I'm sharing this just in case, it might help.

$$anonymous$$y game was instanciating multiple scenes at the same time causing the slow effect. To be sure you're not instanciating multiple scenes make sure you did remove the Game $$anonymous$$anager fromyour Hierarchy (sometimes hidden under $$anonymous$$ain Camera) and that your game manager prefab is attached to your Loader script in the main camera.

Lemme know, I really want you to go threw that problem.

avatar image Fragmental o-super · Nov 12, 2015 at 04:12 AM 0
Share

That would be a good reason for issues.

No gamemanager object in my scene here. Just the loader script. I did notice something different about the completed scene and my scene though. The completed scene loads the soundmanager in the loader script, and my soundmanager is in the scene. I don't think it really matters either way for the soundmanager though.

  • ‹
  • 1
  • 2

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I make my character move on the Z axis on 2d rigidbody? 0 Answers

How to check if mouse is above or below player? 2 Answers

2D movement with transform.translate and collision detection...? 1 Answer

How to make LineRenderer in GameObject Facing? 1 Answer

Moving A 2D Object Forward 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges