• 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
2
Question by Raemon · Jan 16, 2011 at 05:34 PM · audiolagrhythm

Lag/jerkiness (as opposed to low framerate) in a Rhythm game

I'm working on a Rhythm-sidescroller. (Basically Mario, but you're encouraged to keep your actions in time with the music). The scene complexity is pretty low. Most of my objects are flat billboards or cubes. I have very good framerate (100+ in the editor, more in the executible). But periodically the game freezes momentarily, making it difficult for players to keep their actions in time with the rhythm. It also sometimes interrupts them in the middle of an action, and they need to go back and start over.

The one thing my level has that seemed potentially problematic is some blinking lights (they're visual cues to help with the rhythm). I tried removing them. It seemed to help a little but it didn't get rid of the lag completely, and given how simple the rest of the scene is I don't think it should be matter that much.

Does anyone know what sort of things cause intermittent lag spikes but not an overall drop in framerate?

I'm programming in java, if that matters.

Comment
Add comment · Show 2
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 Jessy · Jan 16, 2011 at 05:41 PM 0
Share

You can't program in Java, with Unity, so if you're making an app in Java, you've come to the wrong site.

avatar image fireDude67 · Jan 16, 2011 at 06:54 PM 0
Share

I think he ment JavaScript

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Jessy · Jan 16, 2011 at 05:42 PM

My first guess is garbage collection. Are you using Destroy() a lot? If so, is there anything you could recycle, instead?

Comment
Add comment · Show 2 · 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 Raemon · Jan 16, 2011 at 08:23 PM 0
Share

First off, yes I meant JavaScript. I'm relatively new to program$$anonymous$$g (I've been doing it for a while, but everything I know comes from picking stuff up from unity tutorials and asking questions on this site, so there may be basic concepts that I don't know).

Can you clarify what you mean by garbage collection? I'm not using Destroy() that often in this version, but if I were, why would that be bad?

avatar image Jessy · Jan 16, 2011 at 09:24 PM 0
Share

I don't have a great grasp of proper garbage collection practices in Unity. Read this and the doc link from it: http://answers.unity3d.com/questions/23223/how-to-stop-sound-from-skipping-during-gc-collection

avatar image
1

Answer by Jason B · Jan 18, 2011 at 03:41 AM

Have you decided for sure that it's your game that's the problem? I know it may sound weird, but you should try creating a quick "dummy" game in a separate Unity project. Write some scripts from scratch, add some very simple movement, stick with primitives for the game objects, maybe throw in a few sound effects.

Only reason I say this is because I've had similar things happen over the years in all sorts of different games. Sometimes it was software running in the background, sometimes I just needed to restart my computer.

If it's definitely your game that's causing it, you might want to investigate all the things that are being loaded on-demand. Does the game skip when your music loops? Does it skip when a sound effect plays for the first time? When something is instantiated for the first time? To test, you could comment out your code that plays sound effects, for instance, and see if not playing sound effects clears up the problem. Or if not playing the music fixes it. Or not instantiating a certain thing. I've also heard that using GameObject.Find too much inside of Update() can cause some trouble. You're unfortunately going to have to go by process of elimination.

As far as Jessy's answer, I would agree if you were running some complex simulation and using Destroy() fifty times a frame (slight exaggeration), but I can't imagine you're destroying much of anything in a musical 2D platformer.

Oh well. Report back if you figure out anything solid and maybe one of us can help you further.

Comment
Add comment · 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

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

No one has followed this question yet.

Related Questions

Rhythm game input latency issue 0 Answers

Does anyone know of a tutorial for a rhythm game? 0 Answers

Does Unity 5 help with rhythm games? Or should I stick to AudioSource.PlayScheduled? 2 Answers

Spawn object, or not, depending on audio properties 0 Answers

AudioClip huge lag on some android devices 0 Answers


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