Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to move a GameObject to get Cinemachine working smooth?

Discussion in 'Cinemachine' started by DrSpritz, Apr 20, 2021.

  1. DrSpritz

    DrSpritz

    Joined:
    Oct 6, 2013
    Posts:
    29
    Hi there!

    First of all, i want to appreciate Cinemachine dev team for the great tool! At this moment i working on mobile flight simulator and i'm sure that the Cinemachine able to implement all my ideas out the box. But, i have some troubles to understanding how working with that in some cases.

    To move fighters i have my own controller that hard control angular speed, movement speed and other properties and it works in Update() method.
    My problem is - jet fighters move extremely fast (up to 1000 m/s on the high altitude) and in this case, any frame time spikes have huge effect to Cinemachine smooth experience. I don't know what type of Magic happens "under hood" to dumping and smoothing, but i really don't understand what goes wrong.

    There is simple moving, it have a huge jittering.
    Code (CSharp):
    1. public class Moving : MonoBehaviour
    2. {
    3.     private void Update() => transform.Translate(Vector3.forward * Time.deltaTime * 1000f);
    4. }
    You can check it in a ready example, that i have attached to the thread.

    Can anybody help me and explain, how i need to move an objects from C# script to get Cinemachine smooth tracking?

    Unity 2021.1.3f1
    Cinemachine 2.7.3
     

    Attached Files:

  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
  3. DrSpritz

    DrSpritz

    Joined:
    Oct 6, 2013
    Posts:
    29
    Thanks for the answer

    Yes, using FixedUpdate give smooth results But this approach means move all components that working with Camera or Tracked objects to FixedUpdate. It huge part of game mechanics (HUD markers, Ryacast checkings, interception point calculations, aiming a missiles and turrets and etc).

    Does it good practice?