- Home /
              This post has been wikified, any user with enough reputation can edit it. 
            
 
             
               Question by 
               vividlydraws · Jul 20, 2016 at 08:56 PM · 
                orthographicperspectiveparallaxorthographic cameraperspective camera  
              
 
              Why is my parallax effect glitching out with my perspective camera?
https://i.gyazo.com/6a90b1e562343f99a7d06866d5551516.gif
I have a 2d game with a perspective camera. In the gif above, you can see that around the edges, objects are not rendering/glitching past others. I have seen answers for this, but the only solution seems to be switching to an orthographic camera and faking the parallax effect. I was just wondering if there was any way around this?
               Comment
              
 
               
              Can you post a shot of how your scene is set up? These objects are at different depths from the camera, right? And are they on the same sorting layer?
Answer by shohan4556 · Sep 18, 2016 at 02:42 PM
Try this code Its perfectly works for me
 using UnityEngine;
 using System.Collections;
 
 public class BackgroundScroll : MonoBehaviour {
 
     public float moveSpeed;
     private float offset;
     private Material currentMat;
 
     // Use this for initialization
     void Start () {
         currentMat = GetComponent<Renderer>().material;
     }
     
     // Update is called once per frame
     void Update () {
         offset += moveSpeed * Time.deltaTime;
         offset = offset % 1.0f;
         currentMat.mainTextureOffset = new Vector2(0f, offset);
     }
 }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                