Unity 2D Platformer for Complete Beginners - #6 CAMERA MOVEMENT

  Рет қаралды 77,797

Pandemonium

Pandemonium

Күн бұрын

In this video we're make our camera move from one room to another, then to follow our player.
➤ Starting Project: github.com/nickbota/Unity-Pla...
➤ Complete Project: github.com/nickbota/Unity-Pla...
Subscribe and turn on the notifications if you don't want to miss the fourth episode!
➤ Discord : / discord
➤ Patreon: / pandemonium_games
➤ Instagram: / pandemonium_games
➤ Twitter: / pandemoniumnick​
➤ Itch: nickbota.itch.io/​
#pandemonium​ #unity2dplatformer​ #unitybeginner​
Tags: Unity 2D Platformer for Complete Beginners,Unity 2D Platformer episode 6,Platformer for Complete Beginners,unity platformer complete beginner,unity 2d game tutorial,unity beginner tutorial,pandemonium games,unity sprite editor,unity 2d,unity 2d camera,unity camera follow player,unity camera movement,unity platformer,unity camera tutorial,Unity 2D Platformer for Complete Beginners - #6 CAMERA MOVEMENT,camera movement,unity 2d platformer,2d camera movement
0:00​ Intro
0:12 Room Camera
4:52 Minor Fixes
5:16 Camera Follow Player
6:18 Camera Lookahead
8:35 Final Result & Outro

Пікірлер: 220
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
I missed this in the video at 4:13, you need to drag the main camera into the door script in Unity. Alternatively you can add this code to your Door.cs script to avoid doing this step: private void Awake() { cam = Camera.main.GetComponent(); }
@Elijahsing1
@Elijahsing1 2 жыл бұрын
omgg thank you! I almost got to that solution on my own and then i wasnt sure if that was it! thanks for the amazing tutorials! I tried to start learning video game development almost a year ago and gave up quickly feeling rather overwhelmed. I am having a great time following your tutorial so far! thanks!!
@nimishbansal4752
@nimishbansal4752 2 жыл бұрын
Why did we add RigidBody to our Door??
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
@@nimishbansal4752 Ultra late reply, sorry. An object needs a rigidbody to register collisions, in the Door script we have OnTriggerEnter2D and it doesn't work if we don't have a RB component.
@jackychan7511
@jackychan7511 Жыл бұрын
Hi, maybe you should pin this comment
@PandemoniumGameDev
@PandemoniumGameDev Жыл бұрын
@@jackychan7511 It was pinned already, wasn't it?
@user-bx6th4bs8x
@user-bx6th4bs8x 3 жыл бұрын
Bro i just started with Unity and wanted to say that these tutorials are AWESOME! thank u for the good work and quality
@pudge-yp6by
@pudge-yp6by 2 жыл бұрын
i continue to be amazed at how helpful you are in this series. bravo!
@shamsullahahmadzai635
@shamsullahahmadzai635 3 жыл бұрын
Love these simple and wonderful tutorials brother! Keep up the amazing work. Hope to see enemies, complex platforms, and possibly procedurally generated maps soon. Fingers crossed 🤞
@mizukiux
@mizukiux 3 жыл бұрын
These tutorials are so helpful! Thank you so much, can't wait for the new part :)
@bettercallyass152
@bettercallyass152 Жыл бұрын
Bro these tutorial series are incredible, keep up the good work !
@GizShi
@GizShi 3 жыл бұрын
I recently found this channel and wanted to tell you to keep up the good work :D
@carenborn
@carenborn 3 жыл бұрын
You do a great job and really inspire me to want to develop games. Many thanks and keep them tutorials coming :)
@jonathanflores-xb6tl
@jonathanflores-xb6tl 3 жыл бұрын
This is really helpful man! Can't wait for the next one!!! keep up the good work!
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
Thank you 🙌
@jjkilpi
@jjkilpi Жыл бұрын
Awesome tutorial. Thank you for these. Once again there was a problem at the end. Luckily I found the bug myself chasing the y coordinate problem. Fortunately, I got to 7 tutorials without GitHub
@Davieu101
@Davieu101 3 жыл бұрын
Another really awesome tut!
@heroweasel790
@heroweasel790 2 жыл бұрын
At 3:26 you say to delete the left wall after duplicating the rooms, makes sense. I was unable to pass between the rooms because you didnt tell us to resize the box collider for the left wall segments we deleted. I figured it out on my own eventually. I just want to say this has been an excellent tutorial series. Very educational. I would request that you dial back the speed on the code and unity editing. Sometimes I miss little things as they happen so fast; I mean sometimes I just need an extra second to pause so I can look at stuff. Wonderful content, thanks again. (ctrl+f search terms for people with my issue; can't move through door, stuck at door, between rooms, room transition; solution - edit box collider for duplicated left wall blocking door)
@FrosenHell
@FrosenHell 2 жыл бұрын
Thank you. @Pandemonium heart or pin this
@amitkesari2000
@amitkesari2000 2 жыл бұрын
Thanks @HeroWeasel!
@vihangabandara4284
@vihangabandara4284 2 жыл бұрын
had the same problem, but how am I supposed to resize a box collider in a deleted wall
@heroweasel790
@heroweasel790 2 жыл бұрын
@@vihangabandara4284 Go back to earlier in the video when we sized the box collider (when it was the left wall before we copied it over to make the right wall). Watch the part when we size collider to fit the wall sprite. Then follow those steps to resize it for the newly shaped wall. Let me know if that helps any.
@gameswithparzival4971
@gameswithparzival4971 Жыл бұрын
OMG IM SUCH AN IDIOT! Thank you!!! :D
@EagleNestGames
@EagleNestGames Жыл бұрын
This is really helpful! thankyou so much!!!
@theordinaryduck
@theordinaryduck 2 жыл бұрын
thanks for the idea of unity u helped
@kavyapurohit3881
@kavyapurohit3881 3 жыл бұрын
Waiting for next episode Love From India Bro!❤️
@karliskazaks8422
@karliskazaks8422 2 жыл бұрын
Thanks im learning alot from you...
@hipmonkgaming821
@hipmonkgaming821 2 жыл бұрын
For anyone trying to change the camera on the Y level here's an easy solution! // Update is called once per frame Create a Variable called currentPosY , In the MovetoNewRoom set currentPosY to equal the _newroom's Y position and add 0.53(may vary) to center your camera. Hope this helps someone! took me hours to realize how easy it was! void Update() { transform.position = Vector3.SmoothDamp(transform.position, new Vector3 (currentPosX, currentPosY, transform.position.z), ref velocity, speed); } public void MoveToNewRoom(Transform _newRoom) { currentPosX = _newRoom.position.x; currentPosY = _newRoom.position.y + 0.53f; }
@alfiandm5782
@alfiandm5782 Жыл бұрын
try to use cinemachine its much easier
@agustinquindimil6594
@agustinquindimil6594 Ай бұрын
you certainly are the best
@techoutlook9235
@techoutlook9235 3 жыл бұрын
You're awesome men
@ADEEGANTENGG
@ADEEGANTENGG 2 жыл бұрын
Thanks!
@danielfolks6997
@danielfolks6997 Жыл бұрын
Any idea why the left edge of my rooms are cut off? I have my room set a x0 y0 z0 and the camera is more than big enough to see the room, yet as soon as the game starts the camera moves slightly to the right and hides the left of my screen, then when i move into a new room, it doesnt center completely
@pythonwithdp8373
@pythonwithdp8373 3 жыл бұрын
waiting for your next video
@maenoire2173
@maenoire2173 3 жыл бұрын
I can't see in the video the moment when you drag the Main Camera to Cam. It took me a while to realise that was the issue I was having. Did yours automatically assign? Otherwise I'd suggest specifying how to do it in the video
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
you're right, that was a miss on my part at 4:13, I'll pin the solution. You can also avoid dragging the reference if you add this code to your Door.cs script: private void Awake() { cam = Camera.main.GetComponent(); } Thank you for the feedback!
@maenoire2173
@maenoire2173 3 жыл бұрын
@@PandemoniumGameDev thanks a lot! :) I forgot to mention the video is still great haha
@rttracy
@rttracy 3 жыл бұрын
hey when is the next video going to be up, i have a school project thats due in about 2 weeks and i found the tutorial really helpful so far, i want to know when is the enemies and health bar episodes are, and is there only going to be fireball attacks or will there be melee combat as well thank you so much for this tutorial
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
It's already done but scheduled to come out in 1.5 hours, it's about health and enemies. Only fireball attacks planned for now.
@rttracy
@rttracy 3 жыл бұрын
@@PandemoniumGameDev thank you
@LemonGuy1
@LemonGuy1 2 жыл бұрын
Pls do enemies tutorial too. That will be helpful
@sackboyx9128
@sackboyx9128 Жыл бұрын
Any advice on how I can make the camera follow me down should I decide to make a platform that goes further down or up?
@StigDesign
@StigDesign 3 жыл бұрын
Great Video :D cameraspeed=9000; :D
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
Go ahead and try that 😃
@StigDesign
@StigDesign 3 жыл бұрын
@@PandemoniumGameDev hehe :D :D
@saint_sam
@saint_sam 2 жыл бұрын
How would I go about creating a mix of both? A camera that follows the player when it is inside a room, but stop at the edges of said room & does not leave unless the player crosses the door? (Potentially with a black screen transition) I don't know if I'm asking for too much, haha.
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
This one could be interesting to tackle but I don't have an easy answer for now. You could set the X position lower limit and upper limit in the Room script and pass that to the camera and then clamp it's position based on that.
@stephbk123
@stephbk123 3 жыл бұрын
Hi! Love the videos! Just a quick question, I want to change the size of my character - if I change the scale once I move anywhere it changes back to original scale. I tried changing the vectors inside the code but it only works when walking left (-1 input), once I turn right or jump it reverts back to scale 1. Thanks so much!
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
You'll need to replace Vector3.one with new Vector3(your scale here)
@stephbk123
@stephbk123 3 жыл бұрын
@@PandemoniumGameDev Hi thanks for getting back so fast. I've tried Vector3.two, gives me an error. Is there a different way I should be writing it? Thanks
@stephbk123
@stephbk123 3 жыл бұрын
@@PandemoniumGameDev The error is 'Vector3 does not contain a definition for two. Thank you.
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
@@stephbk123 if (horizontalInput > 0.01f) transform.localScale = new Vector3(2, 2, 1); else if (horizontalInput < -0.01f) transform.localScale = new Vector3(-2, 2, 1); This is an example, replace 2 with the value that you have, if you have a decimal value use 1.5f, make sure to put f after the value.
@stephbk123
@stephbk123 3 жыл бұрын
@@PandemoniumGameDev Thank you so much! Looking forward to the next part, have been loving the tutorials so far. Thanks :)
@andrewlau7521
@andrewlau7521 3 жыл бұрын
Thanks so much for the tutorial! How many episodes do you plan on making?
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
About 15 probably
@rokstrogaming7366
@rokstrogaming7366 Жыл бұрын
Hey Pandemonium I have tried both method you show in your video but my camera doesn't move a bit...pls help me!!
@lukke6720
@lukke6720 2 жыл бұрын
does it effect much is i change order in layer value because my fire balls flashes when i shoot when i changed the value now it works fine
@cosmo736
@cosmo736 2 жыл бұрын
I dont know if u still read the comments but i have a problem when i move to the second room my camera has aprox -6.2 ofset on the x and the camera is not seeing the 2nd room compleatly and when i go back to room 1 i have the same problem! Do u have any ideea how can i fix this? (srry for my bad eng)
@timbirtles8516
@timbirtles8516 Жыл бұрын
How would I make the camera move vertically instead? I've moved the door to a place above the player, changed transform.position's new Vector3 to 'new Vector3(transform.position.x, currentPosY, transform.position.z)' , updated currentPosX to currentPosY and told it to get the y position of _newRoom, and changed in Door.cs to check the collision transform position.y instead of x, but for some reason the camera will move to the new room but not back to the previous room if the player falls back through the door. Hope you can help!
@asadshah5640
@asadshah5640 3 жыл бұрын
thnk u bro
@asyhhaz3882
@asyhhaz3882 2 жыл бұрын
hey can i know why i cant move my room like yours in video at 3:20. I already duplicate the room 1. I I have to take one by one
@fawwazmehmoodmeer2692
@fawwazmehmoodmeer2692 Жыл бұрын
Can you tell me what i should do about this error, ('Fireball' AnimationEvent has no function name specified!), because of this my fireball is not firing and not showing. Help would be appreciated
@WitlayX
@WitlayX 2 жыл бұрын
Heya! First off, thanks so much for the tutorials, you earned a sub!!!! But may I ask a little help? How can I get the camera to follow the player when he jumps or falls? Since it seems the camera only follows the player horizontally Thanks in advance
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Thanks a lot for the sub! In the Camera controller script where we assign the transform.position just replace transform.position.y with player.position.y
@WitlayX
@WitlayX 2 жыл бұрын
@@PandemoniumGameDev THANK YOU SO MUCH!!!!
@ryanlipshin8579
@ryanlipshin8579 Жыл бұрын
Hi, I followed along with the video, but when I tried to implement the look ahead feature, the camera moves so far left or right that my character is no longer in frame at all, it also seems to side scroll much faster than my character runs. If anyone can help me, it’d be greatly appreciated!!
@inhhuuiem6230
@inhhuuiem6230 2 жыл бұрын
i see there is a bug, when the player goes to wallleft, there will be an extra space on the left side, can you fix it
@jayaprasanthsingh1775
@jayaprasanthsingh1775 2 жыл бұрын
i have this issue like if i go from previous room to new room nothing happens but when i come from new room to previous room it moves the camera to new room i have checked that both are set correctly in their slots
@karliskazaks8422
@karliskazaks8422 2 жыл бұрын
May i suggest you make some AR tutorials because all the other ones are outdated
@lukspie
@lukspie Жыл бұрын
Hi, I have a problem.. My camera moves itself.. It should move only when I pass the doors but it happens already when I start the game.. any fix?
@pub2409
@pub2409 Жыл бұрын
I have a fix for the camera not panning correctly on your Room1 or Room2. When you click on Room1 or Room2 attach an icon and you will see that it may be off-center from the actual room and that's why the camera is not focusing on the whole room properly. (Cutting off parts of the room and keeping them from being visible.) You know we dragged the Room1 object into the door script for previous room and Room2 for Next Room. I can't change the position of the icon without moving everything else inside the room. So what I did was made an empty object called "Room1Cam" and gave it an icon and placed it in the center of Room1. Then I made an empty object called "Room2Cam" and again placed it in the center of Room2. I then dragged the "Room1Cam" and placed in the door script for Previous room and did the same with "Room2Cam" and Next Room. Maybe this is a bit of a long explanation but it's an easy fix. I hope this makes sense.
@rounakghosal9727
@rounakghosal9727 Жыл бұрын
You are a lifesaver mate cheers!
@hyperk1035
@hyperk1035 Жыл бұрын
Absolutely saved me thanks so much
@waltzthinking2462
@waltzthinking2462 Жыл бұрын
like the previous commenters... THANK YOU!
@genericusername369
@genericusername369 Жыл бұрын
Don't know if i missed this in the video, but if someone has the problem of the camera not centering on the first room on game start, just add the start() method to camera control and add the first room as SerilaizeInput
@genericusername369
@genericusername369 Жыл бұрын
[SerializeField] private Transform firstRoom; // new variable to store the position of the first room private void Start() { // set the initial camera position to focus on the first room currentPosX = firstRoom.position.x; }
@KisameBG
@KisameBG 2 жыл бұрын
Great tutorial as always. I have a problem with my camera since i have levels that go up and down. I managed to make the camera go up like that - if(player.position.y > 4) { transform.position = new Vector3(transform.position.x, player.position.y, transform.position.z); } (no idea if it's a right way or not) but for some reason i can't make it go down afterwards. Any ideas?
@thesilentwisp
@thesilentwisp 2 жыл бұрын
What I ended up doing was making a new lookAhead variable and putting in this code: transform.position = new Vector3(player.position.x + lookAhead, player.position.y + lookAhead2, transform.position.z); lookAhead = Mathf.Lerp(lookAhead, (aheadDistance * player.localScale.x), Time.deltaTime * cameraSpeed); lookAhead2 = Mathf.Lerp(lookAhead2, (aheadDistance * player.localScale.y), Time.deltaTime * cameraSpeed);
@jackychan7511
@jackychan7511 Жыл бұрын
@@thesilentwispbrooo! was looking for this for days, thanks so much!!
@slepoi28
@slepoi28 4 ай бұрын
tnx bro! @@thesilentwisp
@nimishbansal4752
@nimishbansal4752 2 жыл бұрын
Hey man awsm work!!1I just have one doubt, why are we adding RigidBody component to our Door??
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
You need a Rigidbody component if you want an object to register collisions, if you don't put it there the OnTriggerEnter2D method is not gonna work.
@liquidjar9710
@liquidjar9710 Жыл бұрын
@@PandemoniumGameDev then how will you make the door not affecting the fireball?
@glaDos-
@glaDos- 2 жыл бұрын
What would be the best way to stabilize the camera movement on the x axis while the player is climbing. Is an if statement who checks for the Layer the right way?
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Not sure I got your question. If you're climbing a ladder the camera movement on X axis should be static since you're moving vertically not horizontally. Maybe you meant on the Y axis? It would be easier if you sent me more details on the Discord DM.
@JohnJames-yt1gh
@JohnJames-yt1gh Жыл бұрын
Is there a way to set boundaries for the camera? I want it to follow the player but when walk towards the wall on the left at the start the camera shift off screen. And then half the screen is black. So I am looking to have the camera follow the player but for it not to pane off the level board.
@naejimba
@naejimba Жыл бұрын
^This. Basically set boundaries where the camera can't move past that point. Anyone figured it out yet?
@PanRaptor13
@PanRaptor13 Жыл бұрын
I have a problem, In my project I wanted to use the camera following the player, everything works okay, but I have a problem with the look ahead setting, once game starts it instantly pans to the right (depending on the ahead distance, if i have 5, then by five, if i have by -5 it goes to the left). Instead it should happen only when I move, do you know what may be the issue?
@scorpiusjones5436
@scorpiusjones5436 Жыл бұрын
Honestly I think this means it's functioning properly. Mine does the same, and it looks like the video is same also. This cam option auto looks ahead, whie the first method only moves when you pass through a 2d trigger.
@mischievoussaw
@mischievoussaw 3 ай бұрын
hello there, i hope you still respond the comments. i have problem witm room camera. the camera takes me to weird position in the 2nd room(not the center), and upon returning back to the previous room, the camera becomes slightly shifted to the right. i hope u can provide any solution of that.
@KingsNerdCave
@KingsNerdCave 3 жыл бұрын
Loving these tutorials thank you for them. Question though, when my player goes through the first door the camera only shifts over 1/4 of the next room .What is it I could be missing?
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
The camera goes to the position of the Room2 object, so I believe that you either: a) Placed another object into the NextRoom reference field b) Didn't center all the object in Room2(the parent object is a bit more to the right but the walls, background etc is a bit more to the left) c) Missed something in the code.
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
If you still can't find it hop on to Discord
@Somewhere_sometime_somehow
@Somewhere_sometime_somehow 2 жыл бұрын
Im having the exact same problem, did you find a solution?
@cookie-vi6fp
@cookie-vi6fp 2 жыл бұрын
@@PandemoniumGameDev I've also got this problem if anyone has a solution
@cookie-vi6fp
@cookie-vi6fp 2 жыл бұрын
I figured it out! 1. Select Room2 and assign a colored icon from the inspector window to help see it better 2. Adjust the position of the "room 2" icon way over to the right (even though it moves everything with it) 3. Manually readjust the ground, background, wall etc. to align properly with room 1
@harperhejter7766
@harperhejter7766 2 жыл бұрын
Hey I'm using circle collider for walking (so I can walk on slopes etc), but then when camera is following my player, its position.y causes shaking. Circle collider is not stable enough. Does anyone have any idea how to handle this? EDIT this have nothign to do with position.y cause I rounded cameras y to 2 decimal float and it is still shaking when running fast EDIT I fixed it Edit -> Project settings -> Time and then I lowered timestep
@none8361
@none8361 11 ай бұрын
Whenever I go back to the previous room the camera is a bit to the left, is there a way to fix this?
@pnin2383
@pnin2383 2 жыл бұрын
when I start the game it moves right immediately how can I fix this? edit: I fixed it by making a start method and doing cam.MoveToNewRoom(previousRoom); which just moves the camera to the previous room when the game starts
@danyhawari9019
@danyhawari9019 2 жыл бұрын
Hello! im currently having an issue where once i move through the door, the camera only goes half into new room, where the door is in the center of the screen. Ive no idea how this happened
@aluizioneto8126
@aluizioneto8126 Жыл бұрын
I have the same problem bro, and I can't find a way to fix it
@jaspurg8573
@jaspurg8573 2 жыл бұрын
My camera wont move when i try to touch the door, i tried to print and it worked fine its just the camera that wont move
@exceededfox
@exceededfox Жыл бұрын
question why do you make [SerializeField]private float speed when you can just make it public for same effect?
@PandemoniumGameDev
@PandemoniumGameDev Жыл бұрын
Public would work too, but public variables are also exposed to other scripts therefore you can change the speed somewhere in the code and completely forget about it and go crazy trying to find the issue. Keeping variables private is a good practice
@exceededfox
@exceededfox Жыл бұрын
@@PandemoniumGameDev thanks for answering i was rly curios lol
@tailsbutsingular669
@tailsbutsingular669 2 жыл бұрын
Hi I got some problems on the camera. When it moves, it tends to stop on a point which is on the right side of the center of the room, which makes the scene a little bit weird cuz I can't see the wall on the left side
@hatestorm16
@hatestorm16 4 ай бұрын
Captain too late here, but try changing the `MoveToNewRoom` method to this ` currentPosX = _newRoom.localPosition.x;`. Apparently `position` takes the global value, while localPosition takes the local value of the room, which will center it properly.
@The_McLaughlin
@The_McLaughlin 2 жыл бұрын
Minor question. Everything is working. I'd prefer to have the camera follow the player as discussed in the 2nd half and its working fine. But once the secondary code was entered in even with the // on the code moving the camera from room to room. Unity is still acting like its trying to read that code over the player movement camera and is giving me a "NullRefrenceException: Object Reference not set to an instance of an object". I've tried removing the door script from the doors, and fully removing the doors. I've even tried removing the parts on the camera movement script referencing the doors just leaving what is needed for the camera to follow the player. However removing the code gives me an error that makes it unplayable so I just added it back in and have just been ignoring the NuffRefrenceException error. Everything is working fine it seems regardless as I'm pretty sure its just referring to the door reference which again I'm not using. Its just more of an annoyance seeing it in the bottom of the Unity Window. How would I modify the code to not break it, or what would I need to remove in unity to so it stops trying to reference the doors. I didn't want to try and delete the door script all together, I know I could rewrite it but seeing as removing the code referencing it broke the script I figured doing so would probably also just break the code. So I'm clearly not removing the correct aspects of the code.
@The_McLaughlin
@The_McLaughlin 2 жыл бұрын
If it helps for more information. When I attempt to remove the room camera codes leaving everything else I get the error: "The name currentPosX does not exist in the current context" Which was referring to the move to new room bit when the camera was tied to the room. So I removed that bit and get the error "CameraController does not contain a definition for MoveToNewRoom and no accessible extension method accepting a first argument of type CameraController could be found(are you missing a using directive or an assembly reference)" The line it refers to for the error has no code on it though so my only guess is that its referencing the door script. which isn't referenced in the code once the by room code has been removed and removing the elements in unity attached to the door script don't fix the issue either. Not sure if I'm explaining it well. I've only been using unity for a few weeks and I'm new to coding as well... so none of it is my strong suit. There's probably an easy solution that's just going over my head.
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
If you don't need the doors you can just remove that object and it should solve it, no?
@The_McLaughlin
@The_McLaughlin 2 жыл бұрын
@@PandemoniumGameDev It wasn't initially it was giving me the nullrefrence error I mentioned previously but was still working properly. However I opened Unity again later with the doors saved as removed and the error had disappeared. So restarting Unity got the error to go away.
@Yeehaw_Kat
@Yeehaw_Kat 2 жыл бұрын
how do you make the camera zoom out when entering a bigger room
@naejimba
@naejimba Жыл бұрын
... and alternatively zoom in if they are moving through a small space. Anyone figure it out yet?
@hamzahhassan7520
@hamzahhassan7520 2 жыл бұрын
Hi Nick! Hope you are doing well?
@bolasiebest29
@bolasiebest29 Жыл бұрын
i´m getting a Object reference not set to an instance of an object inside of Door.OnTriggerEnter2D can anyone help?
@angelkaki5707
@angelkaki5707 2 жыл бұрын
So,ive dragged the main camera to the script, yet when i enter the 2nd room it just cuts automatically, it doesnt have that smooth transition like yours does, the script its identical to yours, any reason why this happens??
@ninjagraphics1
@ninjagraphics1 Жыл бұрын
I have the same issue currently.
@daanyaal101
@daanyaal101 2 жыл бұрын
Hey love these tutorials. Question, when my character touches the doors box collider the character gets stuck by the door and doesn't move to the next room. How do I fix this?
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Thanks a lot! Make sure that the door collider is a trigger, sounds like it isn't right now.
@daanyaal101
@daanyaal101 2 жыл бұрын
@@PandemoniumGameDev Thanks for getting back to me. I have the door collider as a trigger, that's why I'm unsure why it is not working.
@jothelol6496
@jothelol6496 2 жыл бұрын
I have the same problem as well but how do you fix it?
@Thydus.
@Thydus. 2 жыл бұрын
@@jothelol6496 Hey, I just fixed it. You've probably forgot to change the box collider of the 2nd room's left wall.
@Animalistoria
@Animalistoria Жыл бұрын
i got a same problem, fixed it big thanks @daanyaal @pandemonium
@usernamehard4780
@usernamehard4780 2 жыл бұрын
Do u need to add the door script and make the door if your doing the second camera move option
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Nope, you can skip it. But there will be some code later on that activates/deactivates enemies when you enter/exit rooms so you might get into a bit of a pickle.
@usernamehard4780
@usernamehard4780 2 жыл бұрын
Thanks 👍
@kastrosimaves
@kastrosimaves 5 ай бұрын
Hello, I am currently new to Unity and I need your help. I have progressed smoothly through the Unity 2D Platformer for Complete Beginners series up to the sixth episode. However, my character is not transitioning from the first room to the second room. Additionally, in a way that I don't understand, my character is being pulled towards the center of the first room every time it moves. I don't know how to fix this issue.
@mubashwirazayan1369
@mubashwirazayan1369 5 ай бұрын
Faced the same issue then I deleted the box collider of the left wall from Room2. You could give it a try!
@fatihbayhan1
@fatihbayhan1 3 жыл бұрын
Firstly, thank you very much for the course, best in youtube I think. May i ask you why i cant go throu the door, did the same with you.
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
Hey thank you so much, crazy to hear that. If you can't go through the door check if the collider on the door is a trigger. If that's not the issue I'll need more details
@fatihbayhan1
@fatihbayhan1 3 жыл бұрын
@@PandemoniumGameDev Thank you very much, it worked
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
@@fatihbayhan1 awesome!
@3.0world86
@3.0world86 Жыл бұрын
Hey bro my camera isn't able to move after making the camcontroller script and even after dragging it moreover i when i made the door object and placed it in between the level my player isn't moving through the gate even is trigger is pressed bro please can you or someone who is reading the comment please help me out thankyou
@nomex.x03
@nomex.x03 Жыл бұрын
How did you turn on the autocomplete in visual studio?
@PandemoniumGameDev
@PandemoniumGameDev Жыл бұрын
It should've been working after you installed Unity in episode 1 but if it doesn't try this: kzbin.info/www/bejne/nWTWeZV8ot-kaas&ab_channel=qubodupDev
@v4mp1ru56
@v4mp1ru56 2 жыл бұрын
The box where i
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Are you sure that you put SerializeField in front of the variable and there are no errors?
@paradrake2231
@paradrake2231 2 жыл бұрын
Hello, at 4:48 when you press play, I noticed that your screen doesn't flash. Mine does for some reason. Do you know what might be causing this? Edit: Realized the problem. Its a bug with unity. Nevermind lol
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Love those, sometimes you can spend a day looking for the issue just to realize that it wasn't your fault :D
@eduardovarela4176
@eduardovarela4176 Жыл бұрын
the camera is very far from a room, I have everything the same and I don't know how to solve it, help
@dani3lH
@dani3lH 2 жыл бұрын
I cant add the script to the main camera when i drag the script to the Add component button under the main camera page it says "The script don't inherit a native class that can manage a script." but if i drag it above the audio it says "Can't add script compnet 'CameraController' because the script class cannot be found. Make sure that there are no compile errors and that the file name and the class name match."
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
The script name doesn't match the name you have it in Unity. Make sure to call it CameraController in both places
@dani3lH
@dani3lH 2 жыл бұрын
@@PandemoniumGameDev what two places? sorry i dont understand
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
@@dani3lH the script has a name in Visual Studio like "public class CameraController: MonoBehaviour" and it also has a name in the Unity Editor where you created it, these names have to match. If you still can't figure it out DM me on discord.
@dani3lH
@dani3lH 2 жыл бұрын
@@PandemoniumGameDev i figured it out thanks
@AdamJamesUK
@AdamJamesUK Жыл бұрын
I'm getting this error stating that "MoveToNewRoom" is protected. Anyone else getting this error? ""Assets/Scripts/Door.cs(15,18): error CS0122: 'CameraController.MoveToNewRoom(Transform)' is inaccessible due to its protection level"
@kyru_art
@kyru_art Жыл бұрын
It is still bugging me to this day that intellisense is working fine but somehow it cannot auto-complete or highlight blue the OnTriggerEnter2D method :/
@PandemoniumGameDev
@PandemoniumGameDev Жыл бұрын
Weird. Did you try the solution posted on episode 1? kzbin.info/www/bejne/nWTWeZV8ot-kaas
@benjaminli3808
@benjaminli3808 2 жыл бұрын
I don't know exactly what's happening, but I think my Rooms are not centered or something? Like If I try giving my room objects a sprite, the sprite doesn't sit in the center of the room, how do I fix this? Because when the camera switches between rooms, it doesn't center itself, but it starts out centered. edit: I found a very ugly solution that should be enough for now, but just for the future, how do you ensure the room object is centralized (The 5.03f increment adjusts for the off center camera), (the counter tracks how many times the rooms have been switched, saying that if no rooms have been switched, the camera will be at it's default position, because for some reason it starts out properly centered) public void toNextRoom(Transform _nextRoom) { counter++; if(_nextRoom.name == "Room1" && (counter == 1)){ currentXPosition = _nextRoom.position.x; } else if(_nextRoom.name == "Room1" && (counter > 1)) { currentXPosition = _nextRoom.position.x + 5.03f; } else { currentXPosition = _nextRoom.position.x + 5.03f; } }
@96crossboss
@96crossboss Жыл бұрын
Bejamin, I figured it out. Now excuse my lack of terminology, but hopefully I will be able to explain it. The "door" trigger takes in the x value of the previous and next room. The way you have your sprite objects scaled, it is most likely that they are float type values(15.7, 17.7, etc), so because you start off on a value of 0, when you trigger the nextRoom event, the camera movement centers on the x pozition of that said gameObject which you have assigned it(presumably Room2), but since the value of said gameObject is not even with the previous one, the result is an uncentered camera. To fix this, simply create a gameObject within the hierarchy of the room and centralize its position within the specific Room you have issues with. Hopefully this helps, even though I came quite late with the solution.
@Panopticon207
@Panopticon207 Жыл бұрын
@@96crossboss thx :D
@sansanici296
@sansanici296 2 жыл бұрын
help, after I wrote the same I took the door out of the trigger is put in kinematic mode, the player can't go through it, thx
@sansanici296
@sansanici296 2 жыл бұрын
my problem is trigger ))) thx
@dioxity143
@dioxity143 2 жыл бұрын
After I finished with the room cam, my character started glitching out. I dont know how to fix it.
@jean-yvesyoussef1992
@jean-yvesyoussef1992 2 жыл бұрын
Have you tried to change the order in Layer field in the Sprite Render
@MazeMazeGaming
@MazeMazeGaming Жыл бұрын
Not sure where my mistake is... Each time my Player touches the Door (or later the Saw), the Player falls downwards continuously. The camera movement works, but the player cannot get past the doors collision box. Please help!
@lians1553
@lians1553 5 ай бұрын
i have same problem , did you solve it ?
@MazeMazeGaming
@MazeMazeGaming 5 ай бұрын
Its been a while, but I don't think I managed to find the error...@@lians1553
@jothelol6496
@jothelol6496 2 жыл бұрын
Why does my character get stuck by the door even tho I already click the Is Trigger
@troisot1107
@troisot1107 2 жыл бұрын
Could you make a tutorial for a game like Fabled Lands?
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Hey, first of all thanks for helping me find an awesome game! That being said the game is very complex, making a tutorial on it would take ages, any particular aspect of it you're interested in? Map movement? Battles? Inventory?
@troisot1107
@troisot1107 2 жыл бұрын
@@PandemoniumGameDev Map movement, books and quests. cdn.cloudflare.steamstatic.com/steam/apps/1299620/ss_3e0bb0412b193e642e72085c6d4a7d64746d7faa.1920x1080.jpg cdn.cloudflare.steamstatic.com/steam/apps/1299620/ss_3453c3b131433ae60e0bb3db73e74e8048e5fb9a.1920x1080.jpg
@karolinamoller7235
@karolinamoller7235 Ай бұрын
It's a pretty old video, so I don't expect any answer, but still gonna type it. For some reason, in the 2nd method something seems to be off about rendering, and all I see after running the game is a blank background. If anyone would scroll through this comment, I'd gladly use of help
@mraxle9028
@mraxle9028 2 жыл бұрын
hi so i skipped the intire video to the camera follow player did i miss anything big or nothing major?
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
You skipped everything in this video until the player follow implementation? No I don't think you missed anything vital but you might as well speedwatch it, it's only 8 minutes.
@harley_randelo
@harley_randelo Жыл бұрын
i can't figure out why i have an error. near the start on the - transform.position = Vector2.SmoothDamp( - line, it says that: Assets\camera_controller.cs(14,130): error CS1503: Argument 3: cannot convert from 'ref UnityEngine.Vector3' to 'ref UnityEngine.Vector2' i don't know what is wrong with it apart from that it is the ref velocity part. here is my lines of code: [SerializeField] private float speed; private float posX; private Vector3 velocity = Vector3.zero; private void Update() { transform.position = Vector2.SmoothDamp(transform.position, new Vector3(posX, transform.position.y, transform.position.z), ref velocity, speed * Time.deltaTime); } would really appreciate some help. Thanks in advance!
@iliketoeatchicken468
@iliketoeatchicken468 7 күн бұрын
It's vector3 not vector2 hope this helps
@Alan-ko6jn
@Alan-ko6jn Жыл бұрын
Is there a way to check the box Is Trigger through c#?
@PandemoniumGameDev
@PandemoniumGameDev Жыл бұрын
Yeah, you can get access to the collider component and modify the Collider.isTrigger property.
@Alan-ko6jn
@Alan-ko6jn Жыл бұрын
@@PandemoniumGameDev thanks
@ldmdesign5610
@ldmdesign5610 Жыл бұрын
[SOLVED] I've been going through the tutorials without issues, now when i opened my game, all the animations are suddenly flickering. when I check through the keyframes, some of the frames are just blank. in the inspector for example idle_02 is selected for frame 2, but on the screen that frame just makes the sprite disappear. It's happening with the player and the fireball animations. I try reselecting the correct sprite frame in the renderer, and even though the actual image file is fine, it just does the same thing. If anyone else gets this just set the player and fireball 'order in layer' to 1. I guess the issues is some frames decided to show behind the background
@PandemoniumGameDev
@PandemoniumGameDev Жыл бұрын
The background sprites are supposed to be on a different layer altogether, which should solve this issue.
@xtaylor7142
@xtaylor7142 3 жыл бұрын
Hey i am loving these tutorials the github completed link i downloaded and replaced mine with it and its actually the old world. please can you update the link with the current world thats in the video thanks.
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
Thanks for the support! There are two links in the description: the starting project and the complete project. Are you sure you got the complete project?
@xtaylor7142
@xtaylor7142 3 жыл бұрын
@@PandemoniumGameDev i just double checked and the link for the complete one is just a basic world with the black floor and walls no background and no wall jumping
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
@@xtaylor7142 you're right, just updated it. Thanks for letting me know.
@xtaylor7142
@xtaylor7142 3 жыл бұрын
@@PandemoniumGameDev thankyou so much, when is the next video coming out
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
@@xtaylor7142 working on it currently, should be out by the end of the week
@Cleevor
@Cleevor 2 жыл бұрын
sheesh
@darshbg6638
@darshbg6638 2 жыл бұрын
When i add CameraController Script to main camera it shows Cant add the script The Script Doesnt Inherit Native Class
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Is it a new script or did you delete something inside it?
@darshbg6638
@darshbg6638 2 жыл бұрын
@@PandemoniumGameDev New
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
@@darshbg6638 Then I'm not sure, send me a screen on discord
@bruh3279
@bruh3279 2 жыл бұрын
It doesn't work. I copied your code on both 'Door' and 'CameraController' but it still doesn't work. I duplicated the room like you did in the video. The camera doesn't go fully to the second room. It actually barely even moves. I checked other comments and none of them worked for me. I thought it might be better for the camera to follow the player, but when I tried to do "transform.position.y' and change it to "player.position.y" it says that "player" doesn't work in that context. I need help.
@extraordinaire6011
@extraordinaire6011 2 жыл бұрын
Man, if you found a solution could you fill me in. I've been stuck for awhile trying to figure it out. Thanks.
@brainy3429
@brainy3429 2 жыл бұрын
Could anyone pls explain why we need to add rigid body 2d to the Door...
@brainy3429
@brainy3429 2 жыл бұрын
I think everything works without Rigid body 2d on Door component..
@darshbg6638
@darshbg6638 2 жыл бұрын
4:49 Mine MainCamera Doesnt move.
@akutame
@akutame Жыл бұрын
wouldnt it be better if u used cinemachine?
@PandemoniumGameDev
@PandemoniumGameDev Жыл бұрын
In some cases. I wanted to teach the basics of using camera in this tutorial and not rely on external tools.
@akutame
@akutame Жыл бұрын
sure. that is better for learning
@thatonerusski
@thatonerusski 2 жыл бұрын
Something happened, basically A: I cant jump in the first room B: I cant go through the door Are there any fixes for this??
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
A: Check if the ground object in the first floor has the Ground tag and layer assigned. B: You probably forgot to make the door collider a trigger, that should do the trick.
@thatonerusski
@thatonerusski 2 жыл бұрын
@@PandemoniumGameDev Thanks, the jumping mechanic now works, but the doors boxcollider2d is set as a trigger, but it still doesnt let me through, the camera switching works though
@ToastysTaken
@ToastysTaken Жыл бұрын
i figured it out, it's not the door that's blocking it, it's the left wall boxcollider, you have to edit it and drag it into the correct position
@ilkinali8793
@ilkinali8793 2 жыл бұрын
programers - i will make camera follow player - no pls no god no pls no programmers - Hahahaha
@icon8391
@icon8391 3 жыл бұрын
Okay
@alfahadtonmoy152
@alfahadtonmoy152 Жыл бұрын
My camera isn’t moving please help.
@DEMOmp4
@DEMOmp4 2 жыл бұрын
Hey man, I obsolutely love your tutorials, but I think u are going a little to fast for complete beginners like me.
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
Too fast you mean the pacing of the video or is there something I didn't explain well enough? I'm here if you have questions
@DEMOmp4
@DEMOmp4 2 жыл бұрын
@@PandemoniumGameDev i mean u are speaking a little bit to fast... i dont have de time to write and understanding without pausing the vid every 30 sec...
@PandemoniumGameDev
@PandemoniumGameDev 2 жыл бұрын
@@DEMOmp4 Ah, got it. Well I'll try be a bit slower and put in more pauses, but I also don't want to make this overly long and boring, so some pausing will be necessary either way. Thanks for the feedback though and let me know if you feel the same way about future episodes.
@DEMOmp4
@DEMOmp4 2 жыл бұрын
@@PandemoniumGameDev it would be perfect🤤👌
@hazratmakhmalipeers.status3427
@hazratmakhmalipeers.status3427 3 жыл бұрын
This game contain levels plzz tell
@PandemoniumGameDev
@PandemoniumGameDev 3 жыл бұрын
It will when we finish the series
@denzeljolliff4578
@denzeljolliff4578 Жыл бұрын
am I the only one where the camera would not move.
Unity 2D Platformer for Complete Beginners - #7 HEALTH SYSTEM
23:17
Celeste's Camera Follow - Unity Cinemachine Tutorial
8:26
BenBonk
Рет қаралды 45 М.
Эта Мама Испортила Гендер-Пати 😂
00:40
Глеб Рандалайнен
Рет қаралды 10 МЛН
Мы играли всей семьей
00:27
Даша Боровик
Рет қаралды 4,2 МЛН
Pan, Zoom and limit camera movement - Unity 2D Tutorial
14:53
Shack Man
Рет қаралды 60 М.
Uhhhhh... Hmmmmmm...
8:09
Phoenix SC
Рет қаралды 508 М.
Improve Your Platformer with Forces | Examples in Unity
7:01
Dawnosaur
Рет қаралды 162 М.
1 Year of Learning Game Development In 6 Minutes
6:01
Giedzilla
Рет қаралды 2,3 МЛН
127 Ways to Make Your Friends Laugh in Minecraft
54:27
Skip the Tutorial
Рет қаралды 368 М.
7 DEVS Make a GAME without COMMUNICATING!
17:18
Blackthornprod
Рет қаралды 636 М.
How To Make A Better 2D Platformer Camera in Unity
15:13
gamesplusjames
Рет қаралды 1,5 М.
Who's taller? (Poppy Playtime 3 Animation)
0:18
FASH
Рет қаралды 13 МЛН
ВЕРИТ ЛИ ТИГРА БУЛЛИ?
0:32
Pimpochka Games
Рет қаралды 2,3 МЛН
Big Construction New Challenge Smiling Critters
0:12
5G Vision
Рет қаралды 11 МЛН
I Just Wanna Do Some Push Ups 👍🏻 / #minecraft
0:14
NoneSteve
Рет қаралды 13 МЛН