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 alexpell00 · Jun 30, 2016 at 02:29 PM · 2d gameendless runnerjitter

Jitter on 2d movement along the y-axis

Hello. I have a sprite in a 2d that I want to move at a constant speed down a long the y axis. My object settings and code are below:

alt text

 // In BodyPart.cs
 public void FixedUpdate() {
         Vector3 pos = transform.position;
         pos.y -= 2f * Time.deltaTime;
         transform.position = pos;
 }

I have tried only setting the velocity of the rigidbody, but the jitter persisted. I have also tried moving the update code to LateUpdate and just Update, but this also does not fix the problem. The jitter is seems to be small and somewhat constant. What is the best approach to remove the jitter and have the objects move down smoothly.

screen-shot-2016-06-29-at-104154-am.png (82.7 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KBEK · Jun 30, 2016 at 05:22 PM

Seeing as you have a Rigidbody2D, the best way to go about creating "smooth" movement would be to use the "AddForce" function. It may also help to use Time.fixedDeltaTime instead of just deltaTime. Last thing I would suggest is to try building and running as this may help keep your framerate at a consistent level.

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 Asgardr · Jun 30, 2016 at 05:59 PM 1
Share

As a matter of fact, it is rather critical to use fixedDeltaTime in the fixed update loop. As the Unity documentation says, it is possible for the FixedUpdate to be called multiple times before another Update is called. Therefore, the deltaTime will be the same over multiple FixedUpdates.

OP, using fixedDeltaTime alone should help quite a lot.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to keep a gameobject on the ground ? 1 Answer

2d look at workaround creates jitter 0 Answers

How to change variables inside FindGameObjectsWithTag objects 0 Answers

Trying to create an endless vertical level 2 Answers

,How to gradually make my character go faster 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