• 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
0
Question by neobaba · May 31, 2014 at 02:25 PM · android2dlaglaggy

Simple 2D motion around a circle is laggy in Android.

This is my first time on Unity so sorry for all the noobness.

I am making a simple 2D game in which an object (call it M) keeps running around a circle, with simple obstacles(call it B) in its path. Thats pretty much it.

I do not use any gravity.

Have added a Rigid body on M. And have added box2d colliders both on M and B. Both the colliders are triggers.

I have made M go around the circle using the RotateAround method of unity.

The issue is that, the motion of M around the circle is very laggy in android. And this is not a phone issue, as this lags even on good phones like the nexus 5.

I have read quite a few of the threads on lags on android, have tried to implement those fixes. Still not much improvement.

There are just 4 images in total, and all of them are part of one png file, and have used the unity slicer to create separate sprites. Any inputs? I wouldn't mind sharing code as well.

Comment
Add comment · Show 3
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 DESTRUKTORR · May 31, 2014 at 02:28 PM 0
Share

Could we get the code you used to do this? If we can see what you've done, we can probably help a lot better. Are you doing this rotation in a FixedUpdate or an Update? Or are you using some other sort of inter-frame iterated method calling, such as a coroutine?

avatar image neobaba · Jun 01, 2014 at 04:05 AM 0
Share

You can check out the code over here. https://bitbucket.org/neilunadkat/unity-save-your-bananas. Have made the repo public for now. I tried the rotation in both Update and FixedUpdate. Not much of a change.

This is my first time in Unity, so my code might not be elegant .

avatar image neobaba · Jun 01, 2014 at 12:29 PM 0
Share

So I had started learning about Unity with the same project as above.. So there could be random scripts which would be executing update calls..

Today I sat and made the whole thing from scratch. Completely new project. And This time i knew what needed to be done, so nothing extra. There is hardly any lag..

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by NickP_2 · May 31, 2014 at 02:51 PM

Make sure that anything which affects a rigidbody (such as rigidbody.AddForce(...)) is in the FixedUpdate() function. This function is called right after, or during (not sure) the physics update!

Comment
Add comment · Show 1 · 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 neobaba · Jun 01, 2014 at 04:08 AM 0
Share

I am not using any force or gravity. The only physics part I am actually using is the collision detection using the box collider and rigid body. You can check out the code at https://bitbucket.org/neilunadkat/unity-save-your-bananas

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

22 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Massive lag when changing scenes on Android. 1 Answer

some android phone's touch won't work sometimes with my game app, but it works perfectly in my phone. 0 Answers

Semaphore.WaitForSignal is causing so much lag on Android!!! Help!!! 1 Answer

LAG when BACKGROUND OBJECT is ADDED ( mobile game) 0 Answers

Android lag when home key is pressed 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