Scrolling Repeating Background in Unity

preview_player
Показать описание
In this video I'm going to show you how to create an endless background in Unity
============

In this video, we cover:
1:10 - Create C# Script
1:50 - Calculating Screen Boundaries
2:45 - Cycle through each of our background objects and load them on the screen
3:50 - Creating a function to setup the scene
6:40 - Creating a function to move our background elements to create a seamless effect
9:15 - Repositioning objects to fill the screen
10:20 - Adding a choke value to fix seams
11:00 - Final Product

IF YOU FOUND ANY VALUE FROM THIS VIDEO CONSIDER JOINING OUR PATREON CLUB:

COPY & PASTE CODE FROM THIS TUTORIAL:

MORE TUTORIALS:
Рекомендации по теме
Комментарии
Автор

Seriously you got the best logic out of all those scrolling tutorials...I tried all of them, yours is the best for scrolling so far.

akitsuneke
Автор

Your definitely one of the better channels for unity tutorials

idontdogood
Автор

I swear to god I threw your code on the camera and another camera follow code and another parallax code that doesn't repeat the backgrounds and all the sudden I have the smoothest Parallax I've ever done in my life. Thank you for the amazing video. Time to analyse that long ass code to understand wtf is going on :D

EnemyOTS
Автор

gonna be completely honest, really helpful even though i only used 3 lines of code lol. thank you so much for the tutorial, people like you are amazing!

nand
Автор

You have an excellent explanation in your video that is very easy to follow, this is really well done!

KnrdoftheRoundTable
Автор

Wow, this worked surprisingly well, thanks man!

ryan_garfield
Автор

Finally found something useful and works thanks man.

mouad
Автор

really good tutorial. I coded along side you and this code worked like a charm. Thanks man.

marcusmorrow
Автор

Hey :-) Wondefull and advance tutorial! I wrote whole script but my transform is y-asis, and i don't know how force move camera.

pawesajnog
Автор

It does what you said it would. Good job.

benhoreluk
Автор

Nice video and animation again
But this so hard to understanding the code for noob like me 😆,
i will need this video later

ossiexs
Автор

what if I have a vertical camera and background movements and not in horizontal movements?

augustgustavo
Автор

Everyone suffering from background loading late in visible area:.

if (transform.position.x + screenBounds.x > + halfObjectWidth / 2)

This solved the issue for me.

cAnuL
Автор

this by far the best Infinte scrolling by far Keep Up

SocrateA
Автор

Hey!
Very helpful tutorial, but how to make that this elements would move with diffrent speed?
Thanks in advance :D

dariuszcegieka
Автор

thank you very much! I couldn't figure out why mine was looping only 3 times... until I discovered it only does it with a prefab bckgrnd..

cheery-hex
Автор

This is very good! TY. Now, I need to try and adapt this for moving in any direction. This only seems to work going left to right. If I turn and go up or down along the y, it does not work. :-( Its a good start though. Thanks.
Update: ok so getting to be endless in the y direction is simple enough, just add another if/if else section to repositionChildObjects that looks at the
transform.position.y, screenBounds.y > lastChild.transform.position.y, and - halfObjectWidth * 2 of the new vectors y coordinate.
The only real challenge now is fixing the flicker between images on x and y IF you move towards a corner. Any help on this would be great!

codersexpo
Автор

The script gave some issues with my camera position. I Fixed the calculation of the camera width by adding a new function.
private Vector2 GetCameraBounds(Camera camera)
{
Vector2 lowerLeft = camera.ScreenToWorldPoint(new Vector3(0, 0,
Vector2 upperRight = camera.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height,
return new Vector2((upperRight.x - lowerLeft.x), (upperRight.y - lowerLeft.y));
}

MartinvanZ
Автор

Great tutorial! Used this but for vertical sadly didn't work.

Tiny_Tree
Автор

when installed to android...there's a blank area like a glitch before the bg repeats.. Help plz

hishamfarag