Simplest movement possible: Stutter!

Hello,

I want to move some GameObjects with a fixed speed and wrote the simplest code possible:

void Update() {
    if(gameManager == null)
        return;
    foreach(ManipulatorObject manipulatorObject in obstacles) {
        // go is the GameObject
        manipulatorObject.go.transform.Translate( Vector3.back * 4.0f * Time.deltaTime );
    }
}

Surprisingly the movement of the GameObject is stuttering! They move and suddenly I can see a mini lag. I don’t understand how this super simple code without any physics can lead to stuttering movement. I am trying to fix this for hours and at this point really need some help!

Is it the same in a build? Don’t check for such things in editor.

If you’ve done that, you could also try switching to Time.smoothDeltaTime;

If you’ve also tried that, then read this thread : Time.deltaTime Not Constant: VSync CameraFollow and Jitter

Hello AcidArrow,

I have tried smoothDeltaTime and the movement is also stuttering.

Until now I only tested it in Editor PlayMode. Is the performance in PlayMode from within Editor not very meaningful?

Yep, exactly.

I just tested it with “Build and Run” (for the first time ever) and its actually smooth! Oh man, can’t believe I have tried to solve a problem for hours that isn’t even there! Thank you very much! :slight_smile:

1 Like

Just one last question: Somehow my objects don’t react on mouse clicks (Input.GetMouseButtonDown(0)) so I wanted to debug my build via logfile. I found a logfile output_log.txt under C:\Users\MyName\AppData\LocalLow\DefaultCompany\MyGame, but I does not contain any of my Debug.Log prints. Do I need any settings to see my Debug logs in output_log.txt?

Try : C:\Users\username\AppData\LocalLow\CompanyName\ProductName\Player.log

CompanyName and ProductName is what you have set up in your Unity project.

(from)

I don’t have a Player.log in the ProductName Folder (only file output_log.txt and folder “Unity”). Why is it missing? (“Use Player Log” is checked in Player settings)

You’re probably looking in the wrong folder then. If you’re having trouble finding it, you can force the log to a specific location by specifying where you want the log file from the command line.

MyCoolBuild.exe -logFile c:\CantMissThisLogFileNow.log

https://docs.unity3d.com/Manual/CommandLineArguments.html