Acceleration Dots are jumping

Hi, I develope an AR-Application where the real time acceleration of my data source (vehicle) should be visualized in a circle around the Center Field of View like the following picture shows:

Therefore I receive a speed value via UDP. The value is beeing updated every 10 MS (in the code this value is called reloadSpeed).
With this dynamic speed value I calculate the acceleration in the following way.

acceleration = (speedValue - lastSpeedValue) / (reloadSpeed/1000.0d);

In another script I wrote a Coroutine which should move the two dots up and down around the circle depending on the calculated value of my acceleration. Here you can see the coroutine:

    IEnumerator alignAccDots()
    {

        float referenceValue = 90.0f / maxAcceleration;

        acceleratation = acceleratation * (referenceValue * Mathf.Deg2Rad);

        rightAccelerationDot.transform.localPosition = new Vector3(Mathf.Cos(acceleratation) * 85.0f, Mathf.Sin(acceleratation) * 85.0f, 0.0f);

        leftAccelerationDot.transform.localPosition = new Vector3(-Mathf.Cos(acceleratation) * 85.0f, Mathf.Sin(acceleratation) * 85.0f, 0.0f);

        yield return new WaitForSeconds(reloadSpeed/1000);
    }

The only problem is, that the acceleration dots jump around crazy in their Position and don´t move in a fluent way as they should. I was wondering if the reason for my Problem is the render time of each Frame, which is around 7 MS but I can´t believe that this is the reason. If it is, is there a way to work around this Problem?

I´d really appreciate some help.

That coroutine only runs once and then stops. Are you sure everything is set up correctly? It’s possible you’re starting a new coroutine every frame, which could explain why the positions are jumping all over the place.

I’d also look into interpolating between the last given position and the current one, rather than immediately jumping to it, for smoother results.

1 Like

Thank you GroZZleR,
this reply gave me a lot of help, the coroutine start every frame might me a reason I guess.
I will also have a look at the interpolation thing, I didn´t think about this until now.

So you think the calculation as well as the coroutine itself is correct?

Thanks a lot for your comment anyways! :slight_smile: I will check those two approaches.