Everything in the scene except the player looks blurry when the camera is moving | Unity2D
I started off my game using a simple camera follow script which only followed my player on the x axis with an offset and and some restrictions
I recorded a video on my android to show what I mean. In the recording the issue is a bit exaggerated ( due to recording) and only viewable once the spikes enter the view. When not recording, the player animation is perfectly smooth. Here's the video
using UnityEngine;
public class MainCamera : MonoBehaviour {
public Transform target;
public float xOffset, xPosRestrictionMin, xPosRestrictionMax;
private float yPos, zPos;
void Start ()
{
yPos = transform.position.y;
zPos = transform.position.z;
}
void LateUpdate ()
{
transform.position = new Vector3(Mathf.Clamp(target.position.x + xOffset, xPosRestrictionMin, xPosRestrictionMax), yPos, zPos);
}
}
However when first running the game everything looked "jittery". Despite all my player physics being inside fixed update, input inside update and camera updates being inside lateupdate. I tried setting interpolate to extrapolate on the players rigidbody2d. Now the player would look and animate smoothly but everything else look blurry when the camera is moving. I thought that maybe my script or settings were at fault so I tried to turn off vsync, set target frame rate to 60 and when nothing worked I downloaded Cinemachine. Even with cinemachine instead of my own script it still looks blurry and I can't figure out why. Here's a simplified version of my controls.
private void Update()
{
//Handle touch input
if (Input.touchCount > 0)
{
foreach (Touch touch in Input.touches)
{
switch (touch.phase)
{
// Touchdown
case TouchPhase.Began:
if (onGround || !doubleJumped)
{
jump = true;
touchReleased = false;
if (onGround)
anim.SetBool("jump", true);
}
break;
//Touch up
case TouchPhase.Ended:
allowGlide = false;
anim.SetBool("glide", false);
if (rb.velocity.y > 0)
touchReleased = true;
break;
}
}
}
}
void FixedUpdate()
{
rb.velocity = new Vector2(newMoveSpeed, rb.velocity.y);
onGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);
if (onGround && !jump)
{
gliding = false;
allowGlide = false;
anim.SetBool("glide", false);
anim.SetBool("jump", false);
doubleJumped = false;
}
//Slowly Accelerate if not at top speed and touching the ground
if (newMoveSpeed < moveSpeed && onGround)
newMoveSpeed += 0.0165f;
anim.speed = Mathf.Clamp(newMoveSpeed, 13, 18);
//Jumping
if (jump && onGround)
{
jump = false;
rb.velocity = new Vector2(rb.velocity.x, jumpHeight);
}
else if (jump && !doubleJumped && !onGround)
{
jump = false;
doubleJumped = true;
allowGlide = true;
rb.velocity = new Vector2(rb.velocity.x, jumpHeight);
}
//Add multiplier if falling down
if (rb.velocity.y < 0 && allowGlide)
{
anim.SetBool("glide", true);
if (!gliding)
{
rb.velocity -= Vector2.up * Physics2D.gravity.y;
gliding = true;
}
else
{
rb.velocity += Vector2.up * Physics2D.gravity.y * (glideMultiplier - 1) * Time.deltaTime;
}
}
else if (rb.velocity.y < 0)
{
rb.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
}
//Increase fall multiplier if touch is released mid jump
else if (rb.velocity.y > 0 && touchReleased)
{
rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
}
else if (rb.velocity.y == 0)
{
return;
}
}
Thanks, any help and feedback is appreciated!
Answer by vipydevelopment · Jan 05, 2018 at 12:09 AM
Tried to reset all quality and player settings, then setting the default android quality to ultra. It fixed my issue.