How to create 2D scrolling background in Unity game | Unity 2D Tutorial

preview_player
Показать описание
#UnityTutorial #SimpleUnityGame #unityscrollingbackground #unitybackgroundmove
In this tutorial video I will show you the quick way how to create a 2D scrolling background in Unity game. The result of this video is a rocket that flies into deep space and it has a infinite scrolling sprite image with stars as a background. We use a simple C# script with Mathf.Repeat function to implement such feature.

TO BLAST! - My New Fun Relaxing Puzzle Game Available On Google Play Store

Consider purchasing my ULTIMATE UDEMY COURSE with great discount

What this video is about and what it can be used for also: unity 2d tutorial,
Рекомендации по теме
Комментарии
Автор

OMG! One method, two lines of code! I love you!

pennaverdeful
Автор

Awesome! Just 10 min and it wroks well even in 2021!

ivanartemenko
Автор

Great tutorial. Quick and straight to the point.

JustAGuyProduction
Автор

Finally a good video about endless scrolling background.
It is the only i found that works good without lines beside.

Thanks!

ARTHUR
Автор

Cool video! But also worth mentioning that in the script in the "Mathf.Repeat" method for me the second argument was wrong, with value 10 it works (I performed moving from top to bottom, not from right to left)!
Thanks for sharing!

relaxingmusic
Автор

Thanks, I was looking for this from 2 hours :D

newworldstream
Автор

well damn, finished watching this, was like "cool tutorial, wonder who made this", and it was this guy again...

citizengoose
Автор

Thanks a lot! Helped more than others did. Please make more of these short tutorials :)
(Except those you already did.) You deserve a sub!

phil
Автор

Thanks! This worked but maybe put a little emphasis on the fact that making the parent’s x-coordinate the negative value of the child’s offset should then put the child right on the main camera. Looking at my child’s initial x-coordinate gave me the wrong value, so I just dragged both the parent and child to the left so that the child is completely over the camera. Then, my parent’s negative x-coordinate value revealed the actual offset value of whatever image is used

DBJetsman
Автор

Top. Estou criando um jogo de nave 2D, e seu tutorial ajudou muito!

mateusaraujo
Автор

what I need to change if I want it to move vertically, i changed right to up and what else??

n.aclasheryt
Автор

Спасибо, огромное.У тебя самых лучшие уроки.

skywoker
Автор

hey do you get it to go scrolling vertically?

Dave-xpxg
Автор

I can't set it properly vertically

n.aclasheryt
Автор

I got it in right way but its jitters, can I do something about that??

n.aclasheryt
Автор

Thankyou, But Please Describe on 3D
i change code on 3d but when i restart game surface move not stopp position move continuously
what i do from proper restart
this code from running simulation from experinced running move surface go back on game

to visualise player move forward, like Running Smoothly! But Problem is, that
when i restart game surface not stopped they move continuously
I try, to stop Time.timescale = 0; and reset but they stop & continew on Time.timescale = 1;
in current positiion i try to other type OnReset(){Pos += originalPosition.position - transform.position;}
is moving current position, but they are deform some times

this Code is here;
public class MoveSurface : MonoBehaviour
{
public float scrolSpeed;
public Transform originalPosition;
public float pluscrolSpeed;
Vector3 Pos;

void Start()
{
Pos += transform.position;
Time.timeScale = 1f;
}

// Update is called once per frame
void FixedUpdate()
{
float newPos = Mathf.Repeat(Time.time - scrolSpeed, 290);
transform.position = Pos + Vector3.back * newPos;
Time.timeScale = scrolSpeed + pluscrolSpeed;
}

public void OnReset()
{
Pos += originalPosition.position - transform.position;
//Pos = new Vector3(0f, 0.489f, 0f);
}
}



Please! Your suggestion and Answer I Watting fromprobleme on restart Please! answer Sir

mayankkela
Автор

Hey game makers! we have free ships and asteroids and other assets for your games on our channel & tutorials best of luck with your project. if you do decide to use our stuff we would love to see your creations tweet or message us on facebook Instagram . stay awesome!

PixelMake
Автор

Me ajudou muito, o efeito scrolling utilizando um objeto quad 3D dava erro pra mim. Muito Obrigado!

Mixtli_
Автор

Its too laggy, i am using it in my game and it dropped my fps from 60 to 40

n.aclasheryt