Parallax Effect in Unity Tutorial - Infinite Scrolling Background

preview_player
Показать описание
In this video I'll show you how to create a Parallax 2D effect to mimic depth perspective in a 2d scene (orthographic camera).

ᐅGet the full Source Code Bundle to my Unity Tutorials 🤓


📥 Get the Source Code 📥

🤝 Support Me 🤝

►🔗 Relevant Video Links 🔗
ᐅKenney Assets Background Elements

►🔗 Assets Shown In Video 🔗
ᐅMAIN SALE 💸
ᐅCorgi Engine - 2D + 2.5D Platformer
ᐅUltimate Character Controller
ᐅQuibli: Anime Shaders and Tools
ᐅAmplify Animation Pack
ᐅAtmospheric House (Modular)
ᐅSpace Graphics Toolkit
ᐅ2D+3D Infinite Runner Engine

ᐅFLASH DEALS ⚡
ᐅGrabbit - Editor Physics Transforms
ᐅPaint in 3D
ᐅPolygon Arsenal
ᐅClayxels
ᐅBoing Kit: Dynamic Bouncy Bones, Grass, Water, and More
ᐅLiving Particles
ᐅHEROIC FANTASY CREATURES FULL PACK Volume 1

In this video I'll show you how to create a Parallax 2D effect to mimic depth perspective in a 2d scene (orthographic camera). First we have to add in an image and make it the size of the screen, duplicate it 2 times, and put it to the side of the original image, so that the sprite can be around 3 times the screen size of the camera. These two extra sprites are made children of the main center sprite. This is for the looping. Then we write a script that moves the sprite in relation to the camera at a different speed. We loop the parallax effect by shifting the position of the sprite forwards if the camera starts to cut off the sprite render. We add in different layers to demonstrate the different environment movements, background, middleground, foreground, and repeat the process.

►⏱️ Timestamps ⏱️
0:00 Intro
0:43 Sponsorship
2:02 Sprite Layer Set up
7:11 Parallax Effect Script
11:32 Loop Parallax Effect
16:49 Add in Other Layers
19:41 Y Parallax Effect
22:19 Camera Move Script
22:41 Outro

💖💖THANK YOU TO ALL MY PATRONS 💖💖

❯❯❯ My Links ❮❮❮
💗 Patreon 💗
💬 Discord Server 💬
🐦 Twitter 🐦
📚 Facebook 📚
👍 Like and Subscribe! 👍

🖥️ Computer Setup 🖥️
*As an Amazon Associate I earn from qualifying purchases.

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we have recommended. While clicking these links won't cost you any money, they will help me fund my development projects while recommending great assets!

#madewithunity #gamedev #unity
Рекомендации по теме
Комментарии
Автор

⏱️ April 11 - 29 ⏱️ Use code WELCOME2022 for an extra 25% off for new buyers <3

samyam
Автор

Wow this looks awesome! Gonna test it out on my game tomorrow:D

kwipxd
Автор

I happened to come across your channel while looking for tips for the new input system, and wow what an amazing channel I ended up discovering :D I immediately subbed, please keep it up <3

alxdrksoul
Автор

Nice job Sam!
*Rolls up sleeve* Time to go back and get this working properly for me xD!

ironcladvr
Автор

Awesome thanks, works perfect... no jittering

kamyasuraj
Автор

Thanks for the video sam your videos are Invaluable for beginners like me. God bless u. 😇🙏🏻

Aye_Sid
Автор

Awesome video thank you so much!!!
I've been watching your videos for quite a while specifically your input system tutorials. Im currently modifying the starter asset character controller and I was wondering how would you make the StarterAssetsInputs class with private functions. I don't really like leaving functions public but I understand that in order to access them in the player input component they need to be public.

omegawave
Автор

I have a doubt can you please help me Sam? Why u have written 1 here
float relativeCameraDist = CameraTransform.position.x * (1- parallaxSpeed);

Aye_Sid
Автор

does this only work if the sprites fit the camera? what if i have a bigger environment?

rayleigh
Автор

How do you walk then run with only the joystick I have no clue also I’m using input system

zialos
Автор

why dont you use the tiling mode on your sprites no need to code that into the parallax effect script right?
or is this just less jittery?

miserstecher