Using Lerp in Class without Update?

Hello,

i have another question about classes that aren’t derived from MonoBehaiviour (so without Start/Update function).

I have a static function in this class, which is called from another Class (derived from MB). This function should do some steps and let the Camera move from one point to another (with Vector3.Lerp).
But my question is, how can i implement the smooth move(Lerp), because the Class has no Update function?

Thanks

At some point, you’ll need an update somewhere.

If your “another Class which derived from MB” has an update, then there it is; your entry point to updating the camera.

public class Potato : MonoBehaviour
{
    private void Update()
    {
         Muffin.MoveCamera(gameObject);
    }
}

public class Muffin
{
    public static void MoveCamera(GameObject go)
    {
        // Do Lerp stuff on the go.transform
    }
}

You don’t need Update; you can use coroutines (which are typically much easier to manage for lerps than Update). Without MonoBehaviour coroutines are somewhat tricky though; I believe there are some topics around about running coroutines without MonoBehaviour.

–Eric

Thank you, it works perfectly with Carroutines.