1

I'm using Windows 7 Ultimate (SP1), Unity 5.3.2 (also tested with 5.3.0, 5.3.1, 5.2.4).

I've caused a bug which is visible in editor, standalone builds, Android builds.

Simple sceene contains: Sphere - GameObject without sphere colider and with Rigidbody2D which is used by movement script:

private Rigidbody2D m_rigidbody; void Start() { m_rigidbody = GetComponent<Rigidbody2D>(); } void Update() { if (Input.GetAxis("Horizontal") > 0) //RIGHT { m_rigidbody.velocity = new Vector2(1, 0); } else if (Input.GetAxis("Horizontal") < 0) //LEFT { m_rigidbody.velocity = new Vector2(-1, 0); } else { m_rigidbody.velocity = new Vector2(0, 0); } } 

3 Cubes - static GameObjects (for abillity to see that sphere is moving) MainCamera - classic camera, that follows shere using CS script:

public Transform m_Target; void Update () { transform.position = Vector3.Lerp(transform.position, new Vector3(m_Target.position.x, transform.position.y, transform.position.z), 1f); } 

Problem: while camera moves, we can see, that (static) GameObjects are "twitching" on the screen...

I've used FixedUpdate in scripts(didn't solve the problem).

Used different Interpolate settings: even used on both (sphere and camera) kinematic Rigidbody2D Extrapolate setting (didn't solve the problem).

Tried to use Rigidbody (instead os Rigidbody2D).

I've found similar question Link to unity3d.ru forum

(didn't solve the problem)

Update: I've set a movement script to Camera and turned off "camera follow". Just simple standart camera moving right (or left) with constant speed and result - static objects are twitching...

0

1 Answer 1

0

In your code,

transform.position = Vector3.Lerp(transform.position, new Vector3(m_Target.position.x, transform.position.y, transform.position.z), 1f); 

...your interpolant factor is 1f. That would just make it jump directly to the target value rather than lerping it. I suggest changing that to something else, like 0.75f. That is,

transform.position = Vector3.Lerp(transform.position, new Vector3(m_Target.position.x, transform.position.y, transform.position.z), 0.75f); 

I hope that helps!

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for a respond, but the problem is in twitching objects, while camera moves

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.