Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 fazol · Mar 14, 2017 at 01:58 PM · androidunity 5movementperformancelags

Smooth movement of simple GameObject on Android

Hi, I am making a simple game like Curve Fever. I have simple scene with few GameObjects and one dot which is moving linearly. The problem is that the movement is not smooth - only on very powerful devices which is weird because there is not much in the scene. On my phone i can see little lags, background is "jumping". I tried many things:

  • using Translate/MoveTowards/Lerp in different combinations

  • using Update/FixedUpdate/LateUpdate also with decreasing time between FixedUpdate calls

  • changing quality settings like Vsync

  • removing everything from scene (like canvas), only moving object was active

  • even I was testing with animation changing the position of object

So do you have any ideas what is wrong? Game was tested on many devices and the problem is repeating.

Object has Rigibody2D (kinematic) and circle collider.

Edit: Current code:

 void FixedUpdate()
     {
         transform.Translate(Vector2.up * speed * Time.fixedDeltaTime, Space.Self);
 
         if (direction != 0)
         {
             rotationSpeed = 2 * speed * radius;
             transform.Rotate(Vector3.forward * -direction * rotationSpeed * Time.fixedDeltaTime);
         }
       
         if (isAccelerating)
         {
             speed += speedIncrease * Time.fixedDeltaTime;
             EndlessModeGameManager.instance.SetTimerValue(speed);
         }
     }

But as I said i tried many other versions and still only powerfull phones can handle it

Comment
Add comment · Show 12
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 TreyH · Mar 14, 2017 at 02:00 PM 0
Share

link code?

avatar image Masterio · Mar 14, 2017 at 02:18 PM 0
Share
  1. Check if you have 60 fps.

  2. Post code, maybe you implement something wrong. (Remember: Time.fixedDeltaTime is for FixedUpdate and Time.deltaTime you using in Updates and LateUpdates)

  3. If game object contains rigidbody set interpolation on.

avatar image fazol · Mar 14, 2017 at 03:18 PM 0
Share

@$$anonymous$$asterio 1. Stable 45fps on my phone 2. I pasted the code 3. GameObject hast interpolation on now but still it is not perfect smooth movement ;/

avatar image Masterio fazol · Mar 15, 2017 at 08:42 AM 1
Share

It should be in Update. Next check profiler maybe you have some scripts what use a lot of cpu. Camera moves should be in LateUpdate.

Restore FicedUpdate refresh time to default 0.2

avatar image fazol Masterio · Mar 15, 2017 at 06:03 PM 0
Share

But I need to use FixedUpdate because game will be using multiplayer and i want to have equal steps between updates Also i checked profiler and founf that Graphics.graphics.presentandsync is using a lot of CPU. Now i am searching what is wrong with rendering(?)

avatar image Mughees_Mehdi · Mar 15, 2017 at 07:33 AM 0
Share

@fazol Can you post the camera code too , You need to sync both to get smooth movement

avatar image fazol · Mar 15, 2017 at 09:27 AM 0
Share

Camera is attached to gameObject. There isn't any script to move camera

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by lgarczyn · Mar 14, 2017 at 06:10 PM

Three solutions:

  • Try using Update() and Time.deltaTime,

  • Increase or decrease the fixed update interval to a multiple of your ideal framerate

  • Activate "interpolate" on your rigidbody2d (if you don't have one, add it, remove gravity, set as kinematic)

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.

Follow this Question

Answers Answers and Comments

8 People are following this question.

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

Related Questions

Bad performance on certain android devices 1 Answer

Android performance hit on changing Button.Interactable 1 Answer

Is it possible to get the forward and backward movement of android device 1 Answer

The bullet doesn't move correctly 1 Answer

IAPUnity - Processing Purchases Crash! 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