Assistance with 2D Background Render Times

Hi Guys,

I’m new to Unity3D and Game development/Programming. I’ve been following some tutorials on how to make an RPG on Unity (gamesplusjames on YouTube). When I run my game, I can see some sort of render lag on the background when I Move/Stop moving.

Essentially what is happening, when I move the map blurs and when I stop moving, the map is trying to catch up to itself (from what I can see). You can see an example(sorry video is downside, but you get the point): HERE

If you look at the grass as I move it blurs (which I guess is normal since when you move motion blur does happen) but when I stop moving, you can see the background image tries to catch up to the player position.

Here is my camera follow code in case it might be this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour {

    public GameObject followTarget;
    private Vector3 targetPos;
    public float moveSpeed;

    // Use this for initialization
    void Start () {
       
    }
   
    // Update is called once per frame
    void Update () {
        targetPos = new Vector3(followTarget.transform.position.x, followTarget.transform.position.y, transform.position.z);
        transform.position = Vector3.Lerp(transform.position, targetPos, moveSpeed * Time.deltaTime);
    }
}

By default does Unity render only what you see on the screen? Or do I need to create some sort of code on my camera script to render only what you see? I am guessing it could be something like this?

Any advise, tips, and assistance would be much appreciated. :slight_smile: I am using Unity 2017.3

Thanks,
Mark.D

You could try turning off Antialiasing in your quality settings, that’s what the engine uses to try and smooth out effects, which has odd effects in 2d. If that works you’ll need to do that for any quality setting you support.

Edit>Project Settings>Quality

Thanks for the fast reply, I should have said I have already done that. That resolved the “ghosting” of the player when he moves, but the background still does the same thing.

I did some further testing and if I child the “Main Camera” to my player, this issue doesn’t occur. So this must have something to do with my camera controller script…

Testing with Main Camera Child
3454238--273764--upload_2018-4-8_10-5-30.png

public class PlayerController : MonoBehaviour {

    public float moveSpeed;

    private Animator anim;
    private bool playerMoving;
    private Vector2 lastMove;

    // Use this for initialization
    void Start () {
        anim = GetComponent<Animator>();
    }
   
    // Update is called once per frame
    void Update () {

        playerMoving = false;

        if (Input.GetAxisRaw("Horizontal") > 0.5f || Input.GetAxisRaw("Horizontal") < -0.5f)
        {
            transform.Translate(new Vector3 (Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime,0f,0f));
            playerMoving = true;
            lastMove = new Vector2(Input.GetAxisRaw("Horizontal"), 0f);
        }

        if (Input.GetAxisRaw("Vertical") > 0.5f || Input.GetAxisRaw("Vertical") < -0.5f)
        {
            transform.Translate(new Vector3(0f, Input.GetAxisRaw("Vertical") * moveSpeed * Time.deltaTime, 0f));
            playerMoving = true;
            lastMove = new Vector2(0f, Input.GetAxisRaw("Vertical"));
        }

        anim.SetFloat("MoveX", Input.GetAxisRaw("Horizontal"));
        anim.SetFloat("MoveY", Input.GetAxisRaw("Vertical"));
        anim.SetBool("PlayerMoving", playerMoving);
        anim.SetFloat("LastMoveX", lastMove.x);
        anim.SetFloat("LastMoveY", lastMove.y);
    }
}