Make a Unity 2D Camera Follow Player in 15 seconds

  Рет қаралды 173,232

AIA

AIA

2 жыл бұрын

In this 15 second Unity tutorial, we cover how to make a unity 2d camera follow player.
► Socials
Twitter: / the_real_aia
Discord: / discord
My free web games: aiadev.fun/
► Download Unity 3D: on.unity.com/3cbxhXY
For more educational content on video game development, unity tutorials, and c# programming don't forget to subscribe!
****
Get a 90% discount on a .fun domain for one year on www.get.fun using the coupon “AIA”
****
#unity3d #unitytutorial #gamedev

Пікірлер: 166
@deadpool3442
@deadpool3442 2 жыл бұрын
No intro No unwanted stuffs Only Content that's much usefull! You gained my sub :)
@AIAdev
@AIAdev 2 жыл бұрын
Awesome, thank you!
@deadpool3442
@deadpool3442 2 жыл бұрын
@@AIAdev TBH you deserve 100k+ subs for quality contents pls don't stop posting videos bro you'll Really achieve your goal one day ❤️
@lusamine7925
@lusamine7925 2 жыл бұрын
Exactly!
@myblueskyyy
@myblueskyyy Жыл бұрын
Im in
@NovaJR9
@NovaJR9 Жыл бұрын
Same here
@CardGameAcolyte
@CardGameAcolyte 8 ай бұрын
Note that this tutorial is a tiny bit outdated: the Cinemachine menu now appears under the GameObject Menu
@editsbyr1
@editsbyr1 5 ай бұрын
thank u so much man
@robertbeke1170
@robertbeke1170 4 ай бұрын
thanks!
@nttainGG
@nttainGG Жыл бұрын
its funny how a 15 seconds tutorial can be better and easier than a 6 minutes one
@antiktestere
@antiktestere 2 жыл бұрын
that was fast, informative, and stright to the point.The perfect video
@AIAdev
@AIAdev 2 жыл бұрын
Glad you liked it
@quixpetric1943
@quixpetric1943 2 жыл бұрын
i just realized that you have to have a standard camera first 💀
@AIAdev
@AIAdev 2 жыл бұрын
😅
@carrotjuicegangsta272
@carrotjuicegangsta272 Жыл бұрын
THE SMOOTHEST LOOP HUMANITY HAS EVER SEEN
@rioualion
@rioualion Жыл бұрын
Exactly what I needed. Only a few seconds of my life on a video to get result I wanted
@stefanarctic1966
@stefanarctic1966 2 жыл бұрын
Or just parent the camera to the player(this takes away config tho)
@AIAdev
@AIAdev 2 жыл бұрын
certainly an option! I've done that on previous projects. The more projects I've worked on, the more I've started to prefer using cinemachine for its versatility.
@Punch_Card
@Punch_Card 2 жыл бұрын
but when the object rotates the camera rotates with it
@stefanarctic1966
@stefanarctic1966 2 жыл бұрын
@@Punch_Card yeah that's a problem that comes with it
@immortalhamster1645
@immortalhamster1645 2 жыл бұрын
I usually do that when I start out a project, just to save time, but then I write my own script. had no idea cinemachine had one.
@gloryxdev
@gloryxdev 2 жыл бұрын
Another option would be to unparent the camera entirely, and add an empty GameObject. Then you could set the position of the camera to the empty GameObject any frame, and add any extra camera shake or movement via script.
@5KFubi
@5KFubi 8 ай бұрын
From now on any tutorial that are not like this does not deserve my attention, thank you for the tutorial
@laned4314
@laned4314 Жыл бұрын
That's not something we see everyday on youtube. An awesome, straight to the point, video. Congratz.
@Crazyfamlam
@Crazyfamlam 2 жыл бұрын
Thanks this really helps as someone who is just starting out gained a sub💪
@AIAdev
@AIAdev 2 жыл бұрын
Awesome to hear! Thanks for the sub :)
@uniballpen
@uniballpen 11 ай бұрын
this 15 sec video was more informative then my schools 15 min lesson
@devmarboy4045
@devmarboy4045 2 жыл бұрын
thx I really needed this, I’m actually making a 2D game lol this was helpful
@IlliaZhdanov
@IlliaZhdanov Жыл бұрын
me too
@taurasjuozapavicius7743
@taurasjuozapavicius7743 Жыл бұрын
how do you get cinamachine there in the corner? i only find it at packages
@butterflytr3077
@butterflytr3077 Жыл бұрын
I didnt know cinemachine existed so I wrote my own code to make the camera smoothly follow. At least I know it now :D
@AIAdev
@AIAdev Жыл бұрын
haha I did the same thing. I just use cinemachine on new projects now though. It's really versatile.
@todaystheday271
@todaystheday271 Жыл бұрын
You have earned my respect
@ninewojcik9669
@ninewojcik9669 Жыл бұрын
THIS SAVED MY LIFE, THANK YOU AS A STUDENT!
@W5529Fortnite
@W5529Fortnite 11 ай бұрын
This is the most simple video out there
@CrossHairGamingTN
@CrossHairGamingTN 2 жыл бұрын
straight to the point I like it 👍
@AIAdev
@AIAdev 2 жыл бұрын
Thanks! I try to keep the youtube shorts... well... short. lol
@A-Brainless
@A-Brainless 3 ай бұрын
When i make follow it sets camera z to -10 i just want follow the character not see entire map and it don't allow me to move back.
@Basketeerr
@Basketeerr 2 жыл бұрын
This saved me some time, appreciate it
@fluffybunny510
@fluffybunny510 2 жыл бұрын
Man i didn't know this exist
@thatgreenfur6584
@thatgreenfur6584 2 ай бұрын
If you don't see Cinemachine in your package manager, make sure you're on the "All" tab instead of just "Services"
@alexanderdominguez8138
@alexanderdominguez8138 6 ай бұрын
Bro we did this same character for my first semester of video game design 😯😆😅
@jasomega2446
@jasomega2446 Жыл бұрын
Thank you
@athier5898
@athier5898 2 жыл бұрын
So glad I found this. Is good stuff
@bjar9533
@bjar9533 Жыл бұрын
Thx man keep up the good work :)
@aizadhassan9957
@aizadhassan9957 2 жыл бұрын
did not expect that HAHAHAHHAA. i thought that u will parent the camera to the player. +1 subs :D
@AIAdev
@AIAdev 2 жыл бұрын
haha ty!
@outhen
@outhen Жыл бұрын
best loop ever lol
@YayapipiStudio
@YayapipiStudio 2 жыл бұрын
incredible!
@AIAdev
@AIAdev 2 жыл бұрын
Cheers!
@yugnatata
@yugnatata 4 ай бұрын
Quick question, since i already had a Main Camera, when i deleted it, to replace it with the cinemachine virtual camera, when i pressed play, it gave me no vision, how do I make the cinemachine camera my main camera?
@caMgrejito
@caMgrejito Ай бұрын
Bro I fucking love you
@Baraafootballeditss
@Baraafootballeditss Жыл бұрын
you're are a LEGEND ❤️
@Jeddles
@Jeddles Жыл бұрын
great WORK!!!!
@seanalves3107
@seanalves3107 8 ай бұрын
Are there any disadvantages of using cinemachine? Or is it just like using a template?
@farnom7662
@farnom7662 8 ай бұрын
Do you happen to know why a virtual camera messes up my UI elements? I'm trying to keep UI elements in place but instead they fly around as I move the player.
@slizra5765
@slizra5765 Жыл бұрын
The Cinemachine option doesn't appear next to the components option. Probably just because of new updates but yeah.
@HGodVR
@HGodVR Жыл бұрын
Ye its in GameObject now
@ic3yfr0ggy51
@ic3yfr0ggy51 2 жыл бұрын
The tutorial I was watching made a separate script and have the camera have the same transform value of x and y but not z because maybe the play rotates or something?
@MohamedElHanoun
@MohamedElHanoun Жыл бұрын
With one step ,Simply Select the camera and drop inside the player and voilaa the camera following the player
@AIAdev
@AIAdev Жыл бұрын
This is certainly an option. However using cinemachine gives you a ton more options to customize the camera. These customizations can go a long way in making your game feel more polished.
@user-gk9vz5ck8b
@user-gk9vz5ck8b 10 ай бұрын
Thank you so much
@F_reak
@F_reak Жыл бұрын
Thanks again! =)
@blitzbot937
@blitzbot937 2 жыл бұрын
brooo tysm!!!
@AIAdev
@AIAdev 2 жыл бұрын
you're welcome! :)
@mr-divinus
@mr-divinus 8 ай бұрын
Thank you❤
@tgcHAI
@tgcHAI Жыл бұрын
Is there a way for the cinemachine cam to move faster when the player moves
@Kader_1
@Kader_1 Жыл бұрын
Underrated
@Pafkatax
@Pafkatax Жыл бұрын
How do i save a shorts vid😃 ty very much,man
@AlexAmayaGuitar
@AlexAmayaGuitar Жыл бұрын
Thanks!!
@stellar5706
@stellar5706 2 жыл бұрын
I should make how to make a 2d camera follow the player in 1 second. "Drags to player *drops*
@glazed3.010
@glazed3.010 Жыл бұрын
and how do you do for the smooth lerp in one second
@kitindra
@kitindra 2 жыл бұрын
OMG finally one that doesnt use code because whenever i use those they dont work! thanks!
@King_crimsone
@King_crimsone 11 ай бұрын
Do i have to install cinemachine or is it built into unity
@itzblikze
@itzblikze 2 жыл бұрын
Ty 😃
@raffiardhinaufal14
@raffiardhinaufal14 Жыл бұрын
thank you for help
@mukining0150
@mukining0150 Жыл бұрын
Awesome and quick stuff going on here. But just a question, any idea why the camera is jiggling with the gameobject? thanks!
@AmallieGames
@AmallieGames Жыл бұрын
I'm having the same problem - when I just move my game object around it appears smooth but as soon as I follow it with the 2D camera it gets all jiggly.
@emretokat897
@emretokat897 2 жыл бұрын
Thanks 🐢
@abd-elaziz-mahmoud
@abd-elaziz-mahmoud Жыл бұрын
Thanks man
@AIAdev
@AIAdev Жыл бұрын
You're welcome!
@Misioder
@Misioder Жыл бұрын
thank you so much
@AIAdev
@AIAdev Жыл бұрын
You're welcome!
@fraxbnezl
@fraxbnezl 2 жыл бұрын
ok i know this is old but it change to vritual camera?
@vipereaper
@vipereaper 2 жыл бұрын
Whats the difference between cinemachine and parenting the camera to the player?
@AIAdev
@AIAdev 2 жыл бұрын
Cinemachine will give you a lot more control of how the camera behaves and follows the player
@ggre55
@ggre55 2 жыл бұрын
Parenting directly to a moving object is bad and not cool so remember to write some code or just use cinemachine cuz it's awesome and easy
@eshaansometimes
@eshaansometimes 2 жыл бұрын
Bro subscribed
@isimsizanimator1291
@isimsizanimator1291 Жыл бұрын
thx
@GreatBritain105
@GreatBritain105 Жыл бұрын
nice loop
@n7pankake236
@n7pankake236 2 жыл бұрын
The 2D option is no longer available D:
@Shadoxite
@Shadoxite 9 ай бұрын
It is though. I just did it. maybe they renamed it?
@nico_3395
@nico_3395 Жыл бұрын
My player cant move normaly, he gets draged into the middle of the scene.Why is that? Anyone can help?
@sayyedalthaf827
@sayyedalthaf827 Жыл бұрын
Thx
@ovenfullofbread6512
@ovenfullofbread6512 2 жыл бұрын
Thanks
@AIAdev
@AIAdev 2 жыл бұрын
No problem
@Chocoletter
@Chocoletter 6 ай бұрын
Everything dissapears when i use it, how can i fix that?
@justanotheraddict180
@justanotheraddict180 Жыл бұрын
the Cinemachine tab doesn't appear for me. What do I do?
@AIAdev
@AIAdev Жыл бұрын
Install cinemachine through the package manager
@davis54748
@davis54748 Жыл бұрын
@@AIAdev They have moved cinemachine to GameObject menu
@ZoaibSihorwala
@ZoaibSihorwala Жыл бұрын
Nice
@AIAdev
@AIAdev Жыл бұрын
Thanks 😊
@GrimCrayontheWraithLord
@GrimCrayontheWraithLord 6 ай бұрын
Good video, just a bit confused about something... Why can't you just attach the main camera to your player character? It works for me?
@AIAdev
@AIAdev 6 ай бұрын
This is certainly a fine solution if you're starting out, but as you make more advanced and polished games you'll most likely come to find that doing this usually causes problems. For instance... walking up steps makes would make the camera movement jittery and jarring... and leading or trailing the camera becomes much more difficult to do when your camera is parented to your player.
@GrimCrayontheWraithLord
@GrimCrayontheWraithLord 6 ай бұрын
@@AIAdev Ah, okay! This explains my question, thank you!
@OakDoubleA12
@OakDoubleA12 Жыл бұрын
i dont see it when i download it
@FunnyLittleStars
@FunnyLittleStars 2 жыл бұрын
subbed
@AIAdev
@AIAdev 2 жыл бұрын
Thank you!
@EE-ou4pc
@EE-ou4pc 5 ай бұрын
Am I the only one that did void update { transform.position = new Vector3(player.transform.position.x, player.transform.position.y, -10) } ?
@GoShtag
@GoShtag 5 ай бұрын
Super save time
@Antumarin
@Antumarin 5 ай бұрын
Trying to learn how to do it myself but ok
@megaa973
@megaa973 Жыл бұрын
I installed it but unfortunately cinemachine doesn't come up at the top? can anyone help me?
@owynnarmstrong1446
@owynnarmstrong1446 Жыл бұрын
I had the same issue. Cinemachine shows up under the GameObject menu now instead of being at the top.
@megaa973
@megaa973 Жыл бұрын
@@owynnarmstrong1446 ok thanks
@timothyyusuf8939
@timothyyusuf8939 Жыл бұрын
Wait why u just put the camera in the player
@ggre55
@ggre55 2 жыл бұрын
Lol 😂😂😂 easier than ever I thought u was going to write some code so i was going to talk about cinemachine and how easy it is to setup any camera but yeah u already used it 😂😂
@weckar
@weckar 2 жыл бұрын
#shorts
@AIAdev
@AIAdev 2 жыл бұрын
#pants
@takacao8373
@takacao8373 Жыл бұрын
Hi! I tried this with the pixel perfect Camera but got jiggling animation. Can you help me, please?
@AVGVA
@AVGVA Жыл бұрын
did you fix it?
@hiepcao4150
@hiepcao4150 Жыл бұрын
@@AVGVA I think I did. Was a while ago. Make sure to disable the main camera. Attached the cinemachine brain to the main cam, and enable the cinemachine camera you want (might be free look cinemachine cam). Mess around with the smooth damp until you got what you want.
@AVGVA
@AVGVA Жыл бұрын
@@hiepcao4150 i found the solution by changing the updatr function to fixedupdate lol
@hiepcao4150
@hiepcao4150 Жыл бұрын
@@AVGVA good for u
@lejodev
@lejodev 2 жыл бұрын
Thanks, but a simpler way would be to put the Main Camera as a child to the player, and you are done, right? At least in 2D games, your way is better for 3D games, right?
@FunnyLittleStars
@FunnyLittleStars 2 жыл бұрын
it takes away the config so not really the best option
@lejodev
@lejodev 2 жыл бұрын
@@FunnyLittleStars ok, thanks, didn't know :)
@O_O-zf7xz
@O_O-zf7xz 2 жыл бұрын
i dont have the cinemamachine thing on the top
@n7pankake236
@n7pankake236 2 жыл бұрын
might be late but is inside Component
@obsidian3701
@obsidian3701 Жыл бұрын
I just drag main camera as a child to my player is that bad?
@christianlaverde1926
@christianlaverde1926 Жыл бұрын
It's not bad, just a little inflexible; for example if you wanted to have your camera lag behind your player and catch up when your player stops, that would be kinda hard if your camera was a child object of your player. Still I'm sure it works for some games.
@FloppaTheCatVR
@FloppaTheCatVR 3 ай бұрын
i put main camera in virtual camera then it fixed
@FloppaTheCatVR
@FloppaTheCatVR 3 ай бұрын
it says nocameras reendering
@reploidzero9058
@reploidzero9058 11 ай бұрын
0:00
@boredfellow7292
@boredfellow7292 2 жыл бұрын
I WAS LIKE NOT POSSIBLE
@trevorf6315
@trevorf6315 Жыл бұрын
Grrr
@megaa973
@megaa973 Жыл бұрын
when my sprite moves it goes blurry?
@AVGVA
@AVGVA Жыл бұрын
did you fix that bug?
@megaa973
@megaa973 Жыл бұрын
@@AVGVA no I just slightly adjusted the speed of the movement and made it look like motion blur
@AVGVA
@AVGVA Жыл бұрын
@@megaa973 i found the fix. You need to change the update function to fixedupdate
@megaa973
@megaa973 Жыл бұрын
@@AVGVA I’m good
@EGS3586
@EGS3586 Жыл бұрын
0:10
@Ngov
@Ngov 2 жыл бұрын
2:23
@crazyguy-69
@crazyguy-69 Жыл бұрын
Id rather see the code though.
@stellar5706
@stellar5706 2 жыл бұрын
Have none of you just scripted your own smoothed camera like I did or am I weird XD
@AIAdev
@AIAdev 2 жыл бұрын
I have before, but there's a lot of power in cinemachine. Once I started using it to do other more advanced things it made my script obsolete.
@n7pankake236
@n7pankake236 2 жыл бұрын
Not everyone does it unless you require something very specific.
@MerrStudio
@MerrStudio Жыл бұрын
that seems like an overkill
@orkhanabdullayev-sr5xe
@orkhanabdullayev-sr5xe 11 ай бұрын
I just attach the camera to the player lol.
@AIAdev
@AIAdev 11 ай бұрын
Putting the camera on the player can often cause issues and/or jitter. Doing it this way makes it so that you can easily do things like leading or trailing the camera, change camera, or transition cameras
@Narguille
@Narguille Жыл бұрын
no way it worked
@What-a-save
@What-a-save Жыл бұрын
i did it myself 😢
@grimkitten8254
@grimkitten8254 2 жыл бұрын
what is this cute game of a fox? owo
@n7pankake236
@n7pankake236 2 жыл бұрын
That's a free game asset :3
@_Sqyd_
@_Sqyd_ 9 ай бұрын
Aha
@Dashthepro
@Dashthepro Жыл бұрын
Didn't work X_X
@Rodrigo_xt8c2
@Rodrigo_xt8c2 8 ай бұрын
holy crap man, too fast!
How to Make a Good 2D Camera
11:38
Game Maker's Toolkit
Рет қаралды 395 М.
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 126 МЛН
MISS CIRCLE STUDENTS BULLY ME!
00:12
Andreas Eskander
Рет қаралды 20 МЛН
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 38 МЛН
Pixel Art Tips from a Professional Artist - Tips & Tricks
8:01
Goodgis
Рет қаралды 1,1 МЛН
We made Vampire Survivors BUT in 10 Lines of Code
7:08
PlayWithFurcifer
Рет қаралды 1 МЛН
6 Devs COMPETE to make the BEST AI
16:02
AIA
Рет қаралды 316 М.
The biggest lie in video games
15:18
AIA
Рет қаралды 1,7 МЛН
I remade MARIO KART but with RAGDOLLS
10:02
AIA
Рет қаралды 575 М.
I Made The World's Hardest Game
9:48
AIA
Рет қаралды 47 М.
This one mistake is killing my game
14:02
AIA
Рет қаралды 187 М.
Why Making Multiplayer Games SUCKS
6:46
Tom Weiland
Рет қаралды 415 М.
Making a difficult game about fitting in - Acerola Jam 0
19:17
jess::codes
Рет қаралды 325 М.
How I made an Excellent Platformer
8:25
GoldenEvolution
Рет қаралды 267 М.