Reputation: 318
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 or feedback is appreciated!
Upvotes: 1
Views: 1973
Reputation: 35
Maybe i think this is causing issues with the recording in the device which maybe took some computation power and caused issues, does this same thing happens while just playing and not recording?
Upvotes: 0
Reputation: 602
Have you checked the frame rate of your game running on device? I have a film/animation background (but new to Unity) and it looks to me like you have a frame rate issue. Although, if the recording software changed the graphics at all I'm not sure I am seeing the same thing you are. Why does your recording software do that? Have you tried using Rec? It works great for me.
Sorry for not posting this as a comment - my current rep won't allow me to.
Upvotes: 2