Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Best way to implement 2D parallex effect

Discussion in 'Scripting' started by mahdiii, May 15, 2019.

  1. mahdiii


    Oct 30, 2014
    Hi. Which one is better or if none of them, please share your approach
    1- Moving sprites in terms of distance to the camera
    2- Using a perspective camera instead of the orthogonal one and put sprites in different depths
    3- Moving several cameras rendering different layers (background, middle, foreground, etc)
    I prefer the third way.
  2. Doug_B


    Jun 4, 2017
    This strikes me as one of those questions where there simply is no 'one true answer'.

    Having said that, on first reading, my immediate thought was 1 or 2. 3 just seems like a bit more hassle to me. But I suspect this is as much a case of personal preference as anything else as there are going to be different pro's and con's with each approach.

    If your instinct is to go for 3, then try it out and see how it goes. It shouldn't be too difficult to adjust if you change your mind later on.
    mahdiii and lordofduct like this.
  3. lordofduct


    Oct 3, 2011
    Yep... no one true answer.

    It depends what visual style you want.

    If I was making a 2d style game and wanted to have that old school 2d parallax effect. I'd move the various layers of sprites at different speeds just like oldschool parallax does it.

    Where as the perspective camera approach is going to have a lot of different implications. It'll give everything the perspective look as it's true perspective projection rather than scrolled layers.

    To get that "farther distances scroll slower than near" you'll have to actually have those layers that far away. This will have ramifications from a draw distance perspective, as well as detail of those sprites since they'll be so far back.

    But this may work if your scrolling scales meet your needs.

    In the end though... use the technique that works for your exact visual requirements.
    mahdiii and Doug_B like this.