Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by markcagatandavis · Apr 10, 2018 at 02:47 AM · renderingspriteslagbackgroundlaggy

Sprite Background Lags with Camera Script

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. :) I am using Unity 2017.3

I have tried turning off Anti-aliasing in quality settings. If I place my main camera object onto my player object, i get no lag on the background. Which leads me to believe it's something on my script?

Thanks, Mark.D

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image markcagatandavis · Apr 10, 2018 at 02:51 AM 0
Share

I did some further testing and if I child the "$$anonymous$$ain Camera" to my player, this issue doesn't occur. So this must have something to do with my camera controller script...

  public class PlayerController : $$anonymous$$onoBehaviour {
   
      public float moveSpeed;
   
      private Animator anim;
      private bool player$$anonymous$$oving;
      private Vector2 last$$anonymous$$ove;
   
      // Use this for initialization
      void Start () {
          anim = GetComponent<Animator>();
      }
     
      // Update is called once per frame
      void Update () {
   
          player$$anonymous$$oving = false;
   
          if (Input.GetAxisRaw("Horizontal") > 0.5f || Input.GetAxisRaw("Horizontal") < -0.5f)
          {
              transform.Translate(new Vector3 (Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime,0f,0f));
              player$$anonymous$$oving = true;
              last$$anonymous$$ove = 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));
              player$$anonymous$$oving = true;
              last$$anonymous$$ove = new Vector2(0f, Input.GetAxisRaw("Vertical"));
          }
   
          anim.SetFloat("$$anonymous$$oveX", Input.GetAxisRaw("Horizontal"));
          anim.SetFloat("$$anonymous$$oveY", Input.GetAxisRaw("Vertical"));
          anim.SetBool("Player$$anonymous$$oving", player$$anonymous$$oving);
          anim.SetFloat("Last$$anonymous$$oveX", last$$anonymous$$ove.x);
          anim.SetFloat("Last$$anonymous$$oveY", last$$anonymous$$ove.y);
      }
  }
avatar image markcagatandavis · Apr 11, 2018 at 09:30 AM 0
Share

Hey guys,

After some more testing, I found that if the moveSpeed of the camera is to low (below 20) the background renders slow Anything above 20 seems to do the trick, but if I do that I can't add some slack to the camera follow and will follow it more static like. I would like to be able to move a few pixels before the camera starts to follow. alt text

2018-04-11-19-27-33.png (9.0 kB)

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

83 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Practical solutions for lag reduction? 1 Answer

Anti Aliasing and Sprites on Intel HD Graphics 0 Answers

Simple 2D motion around a circle is laggy in Android. 1 Answer

Is it possible to render in Unity without the editor/scene/player being visible? 0 Answers

Big Jerk or Lag when starting the game in Iphone caused by Shader.CreateGPUProgram, BatchRenderer.Flush and MeshSkinning.Render 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges