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 /
  • Help Room /
avatar image
0
Question by zerophase · Feb 15, 2016 at 11:29 PM · movementlerpslerpjitterghost

Ghost car movement jitters when replaying previous race

I'm having an issue with the movement of my replay being jittery. I've tried various different implementations for moving using lerp, slerp, and smoothstep, which each still jittering some what. I found this post, which has the same issue. He seems to suggest it's the physics system causing the problem. The only thing is my ghost car doesn't have any rigid bodies attached to it.

Here's what my Update currently looks like:

 void Update ()
     {
         if (GhostCar.Instance.HasPositions)
         {
             GhostCar.Instance.GrabNextPosition();
             time += GhostCar.Instance.GetDeltaTime();
             if (time >= GhostCar.Instance.UpdateFrequency)
             {
                 time = 0f;
                 previousPosition = transform.position;
             }
             
             transform.position =
                 Vector3.Slerp
                 (
                     previousPosition,
                     GhostCar.Instance.GetPosition(),
                     time * 10f
                 );
         }
     }


Any idea how I could address the issue? It's much smoother outside of the editor, but there's still a noticable jitter. I know it's not a framerate issue, since the profiler currently shows me at being above 250fps.

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 hexagonius · Feb 16, 2016 at 07:00 AM

I don't know how you picked your positions, but I think you should do this a little different. accumulate the time from the start. run through your positions until you find one that is smaller than the current time. subtract them to know how much you overshot it. also calculate the time between the picked position and the following. use lerp between those.
your problem is basically that you don't take the differences between the times from the race and the frame times you have during replay into account. frames can be little larger and smaller and never match during sessions

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 zerophase · Feb 16, 2016 at 08:48 AM 0
Share

@hexagonius So I should record Time.time, and not Time.smoothDeltaTime? Then I take the difference between the current runs Time.time, and the previous runs Time.time?

I do think what you're suggesting would fix discrepancies between two runs, but would that correct the stutter I'm receiving from the lerp?

So, the Lerp should look something like this:

   transform.position = Vector3.Lerp(previousPosition, SavedPosition, CurrentTime - PreviousRaceTime);

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

38 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 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

Frustrating Problem with Character Controller in FPS 0 Answers

How to Slerp / Lerp Rotation on a Single Axis? 0 Answers

Looking for the optimal smooth incremental movement method. 0 Answers

Unity network transform massive movement jitter jumps 0 Answers

Implementing a "flyer" game in with the old CardBoard Google sdk 2 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