- Home /
Question by
arunkarnann · Oct 08, 2018 at 08:40 AM ·
physics2d-platformerrigidbody2dphysics2dcamera follow
Camera following Rigidbody jitter every few seconds with background
Camera following Rigidbody2D jitter every few seconds with background (non rigidbody) objects (Obstacles). The FPS in profiler is fine it is near to 100. also Interpolate is also fine. Using Unity 2017.4.12 (LTS) Camera Follow Script
public class CameraFollow : MonoBehaviour {
public float followRange = 0.5f;
public float cameraZ;
public Transform Player;
public Vector3 newPos;
void Start () {
cameraZ = transform.position.z;
}
void FixedUpdate() {
newPos = new Vector3(Player.position.x + followRange, 0, cameraZ);
transform.position = Vector3.Lerp(transform.position, newPos, 0.5f);
}
}
Player Script :
public class PlayerBall : MonoBehaviour {
public float xSpeed = 10;
// Update is called once per frame
void FixedUpdate () {
this.transform.position = new Vector3(this.transform.position.x + Time.fixedDeltaTime * xSpeed,
this.transform.position.y , transform.position.z);
}
}
Comment
No luck. its happening in every few seconds (3 to 4).
Reduce lerp value. I normally use like 0.05f
Your answer
Follow this Question
Related Questions
2D Physics Problem? 1 Answer
Platformer2D Player sticks to platform corners 0 Answers
increasing knockback of a rigidbody as received damage increases (like super smash) 1 Answer
How much force does my 2d ball need to fly from point A to B ? 1 Answer
About Rigidbody2D.AddForce's duration... 2 Answers