c# - Why does my character/camera stutter in Unity 2d? -


ever since i've added new camera script, character (which camera trying follow) keeps on stuttering when moving. if keep character still, won't stutter anymore.

here's video of mean.

using unityengine; using system.collections; using system.collections.generic;  public class camerafollow : monobehaviour {    public transform lookat;  private bool smooth = true; private float smoothspeed = 0.1f; private vector3 offset = new vector3 (0, 0, -6.5f);   void lateupdate() {      vector3 desiredposition = lookat.transform.position + offset;      if (smooth) {         transform.position = vector3.lerp (transform.position, desiredposition, smoothspeed);     } else {         transform.position = desiredposition;     }  } 

}

please - it's driving me crazy! edit: ignore error @ bottom - it's part of else i'm working on.

edit2: never mind, turning on interpolation in rigidbody2d fixed it! help!

first of all, make sure code changing position of lookat transform running in update() , not lateupdate().

if case or didn't solve problem, try running code shown in fixedupdate(). don't know why, should work.

source


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -