Hi there.
I am making a side scrolling game and I’ve run into an issue with my camera. The camera is shaking/is jerky. Note that I have the rigid body set to interpolate.
I do all the physic stuff in FixedUpdate and all the cam stuff in LateUpdate.
Here is the problem.
If I have the camera in Late update the scene looks fine but when I move the character the camera renders him jaggy. All other animation stuff (not handled with physics) look fine.
If I try to move the camera logic to Fixed Update all the effects are reversed. It does not metter if I track the rigidbody or if I track a child transform of it. The effects are the same. Changing the rigidbody interpolation still does not change anything. I hope you can help me.
PlayerLogic
void FixedUpdate ()
{
if (grounded)
{
doubleJump = false;
}
grounded = Physics.CheckSphere(groundCkeck.position, groundRadius, whatIsGround);
rigidbody.velocity = new Vector2 (moveDirection * maxSpeed, rigidbody.velocity.y);
if (moveDirection > 0.0f !facingRight)
{
Flip();
}
if (moveDirection < 0.0f facingRight)
{
Flip();
}
}
// Update is called once per frame
void Update ()
{
if (Input.GetButton ("Fire1") Time.time > nextFire)
{ nextFire = Time.time + fireRate;
anim.Play(attackState);
}
if (moveDirection == 0 grounded)
{
anim.SetBool("Idle", true);
}
else
{
anim.SetBool("Idle", false);
}
moveDirection = Input.GetAxis ("Horizontal");
if (Input.GetButtonDown ("Jump") (grounded || !doubleJump))
{
Debug.Log(rigidbody.velocity);
rigidbody.velocity += new Vector3(0, jumpHeight, 0) ;
//rigidbody.AddForce(new Vector2(0, jumpSpeed)); //use this if the above method does not work
anim.SetBool ("Jump", true);
if(!doubleJump !grounded)
{
doubleJump = true;
}
}
else
{
anim.SetBool ("Jump", false);
}
if(grounded)
{
anim.SetFloat ("MoveDirection", Mathf.Abs (moveDirection));
}
else
{
anim.SetFloat ("MoveDirection", 0);
}
CameraLogic
void LateUpdate () {
transform.position = new Vector3 (target.position.x, target.position.y, transform.position.z);
}