I know I'm five years too late but if you still check this channel thank you so much! You make everything so much less complicated than any other tutorial type video I've seen, and this series is literally a godsend.
Thank you from Norway, I've learned more from your videos the last week than I have with 100's of random Unity tutorials the last year. Have a great day!
@@itotallyagreewithyou3451 well hello from Denmark and you shouldn't get too much help from this legend either ^^ (btw it's a joke =) have a nice day stranger)
For non-square rooms I instead of using += I just used =. This way I just set my bounds for each room. Another thing I was thinking of doing is having another object that surrounds the room, then making the camera bounds only equal to that. Either way this video is great for introducing uses for scripts within box colliders.
I know you probably hear this a lot, but these tutorials are the best I have found yet. Using these tutorials, I am able to recreate an old game from my childhood but with the improvements that I always imagined it needed. The way you describe what you are doing makes this seem so easy to understand.
I've been programming computers for 20 years. This series of videos is by far the best tutorial of any programming task I've ever seen. Well done, and thank you so much for making this.
I've been binch-watching your videos for the past few days. Already learned more than I have from the past 3 months of (what feels like) endless of Unity and C# tutorials. I'm making my first game for my fiancé to play and finally, I feel like I've gone from turning slightly insane to actually understand what I'm doing. Thanks, tack, from Sweden
Btw an alternative is something like: minPosition = new Vector2(Mathf.Floor(target.position.x / 25) * 25 + 6.666f, Mathf.Ceil(target.position.y / 25)*25 - 20); maxPosition = new Vector2(Mathf.Floor(target.position.x / 25)*25+18.335f, Mathf.Ceil(target.position.y / 25) * 25 - 5); I personally like this method more because the player doesn't teleport. The only downside is that every room has to be the same size
You could create a new variable to assign the new maximum and minimum position of the camera, worked pretty well for me, and worked well for non square rooms. All i did was: cam.MinPos.x = newMinpos.x; cam.MinPos.y = newMinpos.y; cam.MaxPos.x = newMaxPos.x; cam.MaxPos.y = newMaxPos.y;
Sorry if its already been mentioned but to reduce the amount of objects you need for room transitions, you can add a bool that flips when you go in and just have the code do the opposite when you hit the same trigger. like this: if (other.CompareTag("Player") && TriggeredOnce == false) { cam.MinPosition += MincameraChange; cam.MaxPosition += MaxcameraChange; other.transform.position += playerChange; TriggeredOnce = true; }else if (other.CompareTag("Player") && TriggeredOnce == true) { cam.MinPosition -= MincameraChange; cam.MaxPosition -= MaxcameraChange; other.transform.position -= playerChange; TriggeredOnce = false; }
This tutorial is really easy to follow and covers so much content! Thanks so much. It has really got me interested in unity development, this is the perfect place to start! Honestly have no idea why this isn't more popular
Hello there Mister Taft Creates! I gotta show you support and love for making this series and keeping it up until this day! from all the tutorials out there including very big famous unity youtubers you are by far the one i got hooked to, seriously this is the first thing i do after i get back home from work! i intend to finish your tutorial i am really expecting to reach the upcoming parts! I have a slight suggestion for this camera movement part here, it is more of a "taste and feel" kinda suggestion and i would very much appreciate if you could responde to it and give your thought! i found that for my eye it felt kinda weird that when the camera travels up to the new room it stills shows some part of the lower room, (again, for my taste) so i changed the parameters on the "Room Move" script from "Camera Change" to be 2 parameters: cameraMinChange and cameraMaxChange. The cameraMaxChange still holds the same value 25 on Y axis but the cameraMinChange holds a higher value 27 on Y axis which results in the camera moving even more up aligning itself so that the lower part of it fits exactly with the lower border of the room. i would very much appreciate your thoughts on that! Again thank you so much for taking the time and patience in making this videos! already subscribed liked and shared your videos and channel, keep up the good work and the calming and humble attitude! Cheers
Thanks! I end up doing this another way later in the series that is even simpler. If you want to jump ahead to the videos titled Observer Objects and Cinemachine Cameras, you can see how to do that.
i made my stuff pretty nice the transitions look pretty good too but my camera stopped following my player? is there anything wrong that i have done.pls help
Amazing playlist! Thanks a lot for the video. I am currently developing a pixel art game in Unity that takes place in a house. So I need transtions between rooms. In addition, some rooms are going to have top-down view and others side-scroller. Do you think the best approach for this case is each room be a scene? Or to have many rooms inside only one scene?
So I've made another tilemap. All done on Unity. I don't know how to select all of the grids and call it a new Tilemap, I just have the one "Grid". I want the tile maps to be "Cross Roads" and "Beach" where yours a room 2 and overworld.
Hey Mr.Taft I'm having a scale issue - well, several issues actually 1st, since I continued my tilemaps (collision & ground) both in unity, I'm not sure how, or even if I should, separate the rooms to different objects. I'm sure this has a benefit, in terms of keeping things ordered. How would you suggest this be done? 2nd - and this is not an issue right now - but I have a strong gut feeling this is gonna come up definitely in the near future: I noticed, when I created the RoomTransfer object, that my scales are way different than yours, for some reason unknown to me I used 16 PPU when importing sprites, just as you did but the scale of my objects - all objects in fact - is 1, 1, 1 camera, player, grid, tilemaps, everyhing in my project is 1,1,1 and the gameobject "roomtransfer" appears huge in my project for some reason - whereas yours appears very small so I check out the scale in your project and noticed that your grid and other object are at 0.065 or something like that my question is: what *should* the scales be? how do I make sure, in the beginning, when it's still easy to control, that the scales are set right, and don't bite me back sometime in the future?
@@MisterTaftCreates I'm learning so much from just following these videos. One of the notes I jotted down is to make certain in future projects to know my scale and positioning in advance. I'm not 100% certain I caught your scale numbers right when rewinding the videos. However more differences rose as I was implementing the place name - mine, in spite of being setup just like yours, ended up much more square'ish for some reason. Maybe my mac's resolution and screen aspect ratio played a part here. Not sure yet.
8:45 i don't understand what you mean by i'll need 2 different vectors idk what to put for them, my other rooms aren't the same shape I'm trying to get the camera to move past the screen transition and continue following the player, but it stops too soon
instead of making the one Room Transfer into a Prefab i made an empty game object a parent of both Room transfer triggers. Then making that empty game object with the 2 Transfer triggers a child of it into a Prefab. that way when you grab the Prefab you are grabbing both Transfers in one object and can rotate it and scale it as you need it and will edit the orientation of both triggers at same time by scaling and rotating the parent object.
When I add the script the public variables Camera Change and Player Change aren't visible in the inspector and I get the compiler error CS0034: Operator '+=' is ambiguous on operands of type 'Vector3' and 'Vector2' I followed the code exactly so any insight here? First hangup so far the tuts have been incredible!
Hey loving the videos but have a question how can i setup the camara bonding for other size maps/rooms or is this not possable IE.. first map max is x25, y5 - min x-25 y-5 then switch to a new room with smaller bonding hope that makes some sence
Hey I know I'm a bit late but I'm following all your videos up to this point and it's been super helpful !!! But I'm having a problem , when I go through the room transfer and brings my character to the next area and if I making my character go back through room transfer 2 it brings me back to the starting area , so all that is working The problem I have is when I go into the second area the camera doesnt so the same thing as yours, I'm able to see the starting area in the second area . And it also doesn't go all the way up to the top there's like the border we had in the starting area. Sorry if that was long and confusing but it's a bit of a weird problem :/
Hi everyone, I've started to implement some of the elements from your videos into my project and I was wondering if doing this specific room transition is possible without using tiled? Can I do it by just having different sections of my tilemap and have separate boundaries? Thanks and great job on your videos!
That's totally doable. Later in the series I show an even easier way to do this. The videos are Observer Objects, and Cinemachine Cameras. Those videos go over a very simple way to do this with any object
hi. what did you put to the script for camera? i dont know how to make it change for a room to another. i'm french sow i try to laern what you do sow if you can give my explicity details that cool. Thx
Edited: Had some trouble with the trigger freaking out when slowly stepping in to it. It turns out it was caused by having multiple colliders on my player. This also made the triggers push me twice as far as it did once I deactivated one. Now it works fine
Question, I sticked with the Unitity Tilemap since in video 10 you are going to show a fix for the ugly seems. Thing is that when I select my Room 1 > Collision layer (which I made 30x30) shows a rectangle square with a white outline and blue dots on every corner with a different size (47x30)? It looks to me that my Collision is now overlapping the collision of Room 2? Were can I change the size of my Collison layer because if I take the blue dot and squise my rectangle, it is going to Scale it, not resize the Collision layer?
Would it be a viable option to add a "switch" bool variable to the Room Transfer class, so that on enter you add the changes and toggle the switch, on enter again you subtract changes and toggle? I tried this, and it works, and it removes the need to move the player forward at all.
Could I get that added code? Having a problem with the camera collider with the end of the map not working, everytime i walk near the edge it doesnt stop, just shows grey
For some reason I am stuck in the beginning of the video. Someone help? I made everything via the ground tilemap and the collision tilemap, so how would I create a "Room 2" Tilemap but still use the properties of the ground and collision maps? Isn't it a separate asset in the tilemap? Does that mean I would have to create this new room with its' own ground and collision maps and repeat the process every time there I creat a new room? I was making it more tiles and rooms all with the same "Ground" and "Collision" units I have in the Hierarchy. Halp.
Hey, I have almost no idea what I'm doing, but I think if you create a new tilemap for room 2, you can just copy and paste the collision and ground objects from your hierarchy list and paste them under the new one. I just did that, and the collision one has the colliders and such we added the first time on it. Although I suppose you can just rename the tilemap it imports under the grid to Ground, since as i recall we didn't do anything special to it. I hope this helps you until someone smarter comes around. I can't test if placing things on the new collision grid makes it have collision or not, because I still havent figured out room transfers and moving the damn camera there. So...Take that for what you will.
I got it working, the new room does get the collision we made when you just copy paste the collision object we made in the previous lesson. So you don't have to manually set it up everytime. You can even make it a prefab for later. So that is a solution, I think.
i am using unity build in tilemapping stuff, and i have one mega level sofar where i have basicly multiple rooms, but different sizes, all are on the same grid though, how would i have to change the script so that it works like it does for you? i am asking because i only started this unity journey end of january and i dont know much yet, would be realy nice of you to let me know :)
Error CS1061: ‘Vector2’ does not contain a definition for ‘main’ and no accepting a first argument of the ‘Vector2’ could be found (are you missing a using directive or an assembly reference?)
Im having an issue with my camera jumping back to the player start position when I start walking forward but the camera follows when i go left and right. please help me lol
So how would you create the forest maze in Zelda 1 with this method? Rather than coding coordinates and locking them to those numbers, could you use the room name and its boundaries to define the camera? This way you could change the room later, or it’s position?
You can do that, or you can dynamically load different rooms when you exit one. For example, put a trigger on the left side, and when you enter that zone, it recreates a specific room, but a different one on the right side of that room. If that makes sense.
How would you divorce the screen transition from the camera smoothing? Like if for example you wanted the transition to be half the speed it currently is without changing the smoothing to avoid stuttering? Or is this covered in a later episode?
Hmm? Operator '+=' is ambiguous of type Vector3 and Vector2... I'm not getting the Change Camera and Change Player bit on the added component even though the script is exactly the same (I'm running Unity 2020 and Visual Studio 1.58).
I followed exactly and my character transitions to the next room as soon as the camera itself touches the box collider instead of the character having to touch it. How do I fix that?
I know your comment is 2 years old but I'm currently following this tutorial and am having the same issue. My script is exactly the same but when I add the Room Transfer script as a component it doesn't show Camera Change or Player Change.
The camera shakes because the player is stepping on both "room transfers" at the same time. Try to increase the player position (if it's 2, make it 4).
Oye amigo yo quiero que cuando cambie a la otra escena cambie tambien el minimo y maximo de la camara ya que la otra escena es mas pequeña o grande,depende, tienes alguna solucion para eso Gracias
man im struggling here bro not anything to do with you or the script i think but my first roomtransfer works perfectly and so does the transition back, but when i used the prefab to transfer to another room the camera jumps like double the distance then when i try to walk the player to the camera like 8 units away the camera jumps back to the other room??? super strange
also bro I realized that in the unity tile map editor yes it does end up makign the player jerk forward but that was before I put the tilemap above the camera in the scene, and the jerkiness stopped. are there any unwanted consequences from doing that or should i really just stick to Tiled Editor to avoid the jerkiness, I ask because I had a bit of an issue importing the tile map from tiled2unity, because it had 3 layers, game object, collision, and ground, and when i dragged the prefab into the scene it allowed me to drag it but nothing appeared, I had to drag in the individual meshes of the layers from the mesh folder, and fiddle around with the sequence in the scene heirarchy for it to even render the collision layer, and half the time it just wouldnt work and would make the play test button inaccesible for some reason. thanks man from nyc this has been my dream since i was 7 years old and you, you!!!! are making it possible god bless
My room is the exact same size as last one, only difference was I went to the right. Now I'm running into a problem where the camera only wants to go half way to the right of the room instead of its full width do you have any suggestions for what I do?
So I try to import a second tiled map to follow this transition tutorial but it gives me an error in unity when I try to import it. 'The object you are trying to replace does not exist or is not a Prefab'. How do I combat this?
previously there is no Tiled Map (script) for the room 1..is it necessary and how did you add it??plus how did you manage to name the room i mean do separate section of rooms (overworld and room 2) okay i totally lost lol..someone help me please i want to continue but im stuck here
Can someone explain the move of "Room Transfer" for the prefab folder, at 12:30 ? And why only "Room Transfer" and not the both "Room Transfer" was transfered to prefab folder ?
Once you make it a prefab you can reuse it and make many instances of it. You can also edit all of the instances of that object at once (what if we want to add a component later? Now instead of however many room transfers you have, you only need to do it once and apply to the rest). So while he could have duplicated it, since he turned it into a prefab he can drag it in a new scene without creating it from scratch (not there to duplicate from).
When you move the camera, you move it by 25 units in the Y direction, which happens to be 25 tiles. Each tile is 16x16 pixels. Where in Unity is it set that 1 unit is 16px?
Sooo... if we were to do this part but in the unity tilemap maker, how would we do this? Because i made 2 separate tilemaps but the trigger just isn't working. It seems like nobody has talked about this in the comments so far and I just want to know because I don't feel like switching to tiled just to switch back. :)
Hey there - I am following along with just the unity tilemap maker and was able to get the trigger working so just as a heads up it is possible. Things I would check in your game: - On the Room Transfer Object, on the Box Collider 2D section - "Is Trigger" should be true - On the Player Object, can you confirm the player tag is set to "Player" - Make sure you named the method exactly this : OnTriggerEnter2D. Capitalization is important! If you have a lower case e for example - the code will compile but it will not fire. - Make sure the box collider 2D is large enough to collide with and its where you expect it to be. - If none of the above, try putting: Debug.Log("Transferred to new room"); in the OnTriggerEnter2D and see if that text pops up when you step on it. Let me know if you get it working!
Where I'm struggling is with the stuff he said he did off camera. Creating 2 separate tilemaps. I've created 2 small maps but now I don't know how to call them 2 different tilemaps. Is there a way to select all of my grids and drag it to a new Tilemap?
@@LiamR90 So my understanding is that when he says "Create two separate tile maps" its repeating the step from the tutorial in Part 4 where he says to right click the hierarchy -> Select 2D Object and then select Tilemap. You should then have two grid items in your scene with a tilemap under each. When I look at his tutorial here thats what I'm seeing. He also states that you can continue using a single tilemap and all the code in this video doesn't really care if you have one or two maps - but if you want to match him exactly I'd follow the steps above. If both your maps are under a single tilemap and you want it separated - you can always follow the steps above, duplicate your tilemap where you drew 2 small maps and then erase so that each grid/tilemap has one room. Its a bit hard to type out but hopefully this makes some sense. Best of luck.
@@aaron58107 Ye, I did go back to when he made the original but it doesn't seem to highlight a specific area. It only gives traits to Ground or Collision. I was hoping to be able to highlight all my grids and somehow have that as the tilemap. Now if have to just keep it all on a single tilemap and have my camera move X amound of squares into the other area.
How exactly could we set up different camera bounds for rooms without changing the bounds for the other rooms? Like having the cmaera automatically change it's bounds depending on the room it's in.
Hey there. That's the best way to do this. In that case, I'd add a function to the camera to split the world up into grids, 25 by 25 in my example, you can have this work entirely in code. Then when the camera finds the target, have the camera decide which part of the grid it needs to stay in. If the player moves out of that part of the grid, then the camera needs to snap to its new boundaries This way would be much more "clean" but much more programming intensive. I decided to go the way I did because I wanted this series to be beginner friendly, but by doing it the other way, you allow for those big fields that you see in ALttP
sorry but I can't deal with the problem of rooms of different sizes ... the point is that I can't adjust the camera so that it adapts to them, can you please help nicely please;)?
if i put my smoothing to a decimal below 1, my player gets all jerky but walks smoothly when i set the smoothing to 1. but when its at 1, the camera transition is instant, because the smoothing is too high. is there any way i can lower my smoothing down to .1 or .5 without it awkwardly keeping up with my character?
Hey so i know this video is nearly a year old but i'm getting an error where it says "Assets\Scripts\RoomMove.cs(25,19): error CS1061: 'Collider2D' does not contain a definition for 'ComparerTag' and no accessible extension method 'ComparerTag' accepting a first argument of type 'Collider2D' could be found" which stops me from having the camera/player change variables showing up in unity, any help would be much appreciated.
Hello! awesome tutorials! congratz! I have a problem with my project, the camera only moves if my player is also a trigger... is that normal? what if i Have to define a new minumum and maximum to the camera? Thanks once again e keep up the good work!
No that's not normal. I revisit the camera and transitions in a later video using Cinemachine. If you can, jump ahead to the video on observer objects and the video on a cinemachine camera and this should fix most of the issues.
My rooms are 35 long by 20 made in unity. I'm having trouble with go halfway up into the next room and it puts me back in the 1st room and can't see my character? I've set my 1st room at y being 11 and 2, the top room at - 11 and - 2. Thanks
assuming the camera sees the whole room and the rooms are all the same size you would still do the same code since all this code does is move the camera and relock it which should work for something like that
It's an old video but i need your help...i've followed step for step all your passeges but in the code, when i write cam = cameraChange.main.GetComponent(); appear the error CS1061 ‘Vector2’ does not contain a definition for ‘main’ and no accepting a first argument of the ‘Vector2’ could be found (are you missing a using directive or an assembly reference?).....please help me, i don't know how to fix it.
Hey there. I re-did the camera system later in the series, and it's safe for you to jump forward to that if you want. It's the two parts called Observer objects and Cinemachine. This will make the room transition work much better.
We have the room transition but it only works one way, when we try to go the other way it simply turns us back as if we were travelling from the first room. How do we fix this?
So I wrote the RoomMove.cs script exactly like you did, and it compiled correctly and everything, but when I play it, there is an error that says: NullReferenceException: Object reference not set to an instance of an object RoomMove.Start () (at Assets/Scripts/RoomMove.cs:13) The line where the error is occurring says: cam = Camera.main.GetComponent(); And the global variable for cam is set at the top and says: private CameraMovement cam; I'm not exactly sure why I'm getting this error and I can't seem to find the solution, especially since all of the scripts I've made so far are exactly like you showed. Do you have any idea what might be causing this?
my room is smaller than the other room that you enter from. I am extremely frusterated at this point. I literally have no idea what to do. So basically, I have my y and x set up so that you can't see past the barriers. But the barriers on the right side. The camera can see over. But on the left they cannot. Also, when I enter the room. It goes in so far that I cannot see the exit anymore. i just have to blindy walk backwards. Please helpp.
// Hello, I was following this tutorial and had the same problem // ROOM MOVE SCRIPT private void OnTriggerEnter2D(Collider2D other1) { if (other1.CompareTag("Player")) { cam.minPosition += cameraChange_MIN; cam.maxPosition += cameraChange_MAX; other1.transform.position += playerChange; } } // For me, there were small errors i had in my script, such as the min and max position switched around // You should also check your other scripts // CAMERA MOVEMENT SCRIPT void LateUpdate() { if (transform.position != target.position) { Vector3 targetPosition = new Vector3(target.position.x, target.position.y, transform.position.z); targetPosition.x = Mathf.Clamp(targetPosition.x, minPosition.x, maxPosition.x); targetPosition.y = Mathf.Clamp(targetPosition.y, minPosition.y, maxPosition.y); transform.position = Vector3.Lerp(transform.position, targetPosition, smoothing); } } // For some reason, i had switched the end maxPosition.y with maxPosition.x // I'm sorry, that's all the advice I can give // I think as long as your room is not smaller than the camera, it should be fine
when i go into the 2nd room it will only allow me to go up so far then it snaps back into the last room but i can walk left and right no problem i can still transition between both rooms just if i walk too high into the 2nd room it pings back
Hey I had same problem even when I had "IsTrigger" checked on my 2D collider and I had everything right. I am not sure what is the main reason it started working, but mainly instead of just cameraChange I assigned cameraChangeMax and Min to cam.minPosition and maxPosition. This also gives me advantage that my rooms doesn't have to be same size and I just adjust min and max values to match room size. I also installed Unity Tools, because intellisence didn't suggest me OnTriggerEnter method and everything worked just fine without Unity tools until this point. If you still have this problem, just write here and I'll help :)
@@scrolllock4583 Instead of one cameraChange on the top you declare two like: public Vector2 cameraChangeMax; ... and also same for "cameraChangeMin". Then in onTrigger method, you just assign it like: cam.minPosition += cameraChangeMin;
cam.maxPosition += cameraChangeMax; ... Funny thing is that I made Debug.Log before if statement and even when it got working, my Debug.Log still don't notice that it's working :D :D
@@scrolllock4583 I kinda messed up with everything like removing collider2D and making a new one, changing size of players collider, because problem really can't be in that script. Maybe just try bigger minimal value in editor. You can send me pictures or videos of what is happening to you on FB with same name as this account and surely I can help.
Hi! This tutorial is very nice, it has been extremely helpful to do a step forward and start with Unity at last. Thank you very much! I'm having some issues with warping the camera during the transition; when I play the game, this message appears: NullReferenceException: Object reference not set to an instance of an object RoomMove.OnTriggerEnter2D (UnityEngine.Collider2D other) If I've understood correctly, the problem is in the following line : "cam = Camera.main.GetComponent();" Can someone help me with this? Thanks!
Hey there. That error comes when the script is trying to access an object, but the object was never referenced completely, so the reference is null or empty. Check to make sure you've completed connecting the objects outside of the script in the inspector.
Hi, I've run into the same problem and I can't really figure it out. Could someone please help me? It just still showing the same message and nothing really is fixing it. I've been trying writting code once again, but it didn't help.
Nevermind I fixed it. If someone also have this problem, just tag your camera "MainCamera". It's a deafult tag in unity and it should help. Btw great videos dude :D
I remember back in the last camera video you said that in this video you'd set min and max programmatically rather than empirically, but I'm not seeing any of that. So how do you do that?
I am new to C# and unity in general, I was wondering what to do if the transition is from one room size to a bigger size, how would I set some the cameras bound min/max x and y. Also just wanted to say your tutorials are amazing to learn how unity works, I know this comment is after the video has been out, but was hoping I could still get help for this issue (sorry if it's hard to read/understand)
Hey there. Jump forward to part 48 for a quick minute and institute Cinemachine. It will work much more nicely for rooms of different sizes. Then you can jump back to where you are now.
Hey there. You would just set the min and max x and y accordingly. For example, if the new room is 40 tiles by 25 tiles, then adjust min and max x by the change on those axes, and the min and max y by 25. Let me know if that doesn't help.
@@MisterTaftCreates This works for the bigger room but now the camera is not bounded for the previous smaller room enabling the player to see into the next room before they hit the transition.
I know I'm five years too late but if you still check this channel thank you so much! You make everything so much less complicated than any other tutorial type video I've seen, and this series is literally a godsend.
Did the CameraMovement part work for you? it keeps giving me an error
nvm I fixed my mistake
@@SuperTacoDude27 glad to hear it, I think this series is somewhat out of date now some of the stuff isn't perfect
wat a legend recording on 8% battery
i was checking the battery level constantly while watching this video lol
Ok so no one is talking about that epic unedited "Hey there I'm almost done" *slam* at 13:07
"Are you winning son?"
@@thecuchikiller xD!!!
First time i heard it i tought ??? what was it??
He's taking a shit haha
Thank you from Norway, I've learned more from your videos the last week than I have with 100's of random Unity tutorials the last year. Have a great day!
Ha, you're too kind! Thank you very much for your compliment!
jeg elsker deg
@@MisterTaftCreates Thank you from Sweden! But it's important that you don't help the Norwegians though^^
@@itotallyagreewithyou3451 well hello from Denmark and you shouldn't get too much help from this legend either ^^
(btw it's a joke =) have a nice day stranger)
@@itotallyagreewithyou3451 Don't underestimate us norwegians!
For non-square rooms I instead of using += I just used =. This way I just set my bounds for each room. Another thing I was thinking of doing is having another object that surrounds the room, then making the camera bounds only equal to that. Either way this video is great for introducing uses for scripts within box colliders.
I know you probably hear this a lot, but these tutorials are the best I have found yet. Using these tutorials, I am able to recreate an old game from my childhood but with the improvements that I always imagined it needed. The way you describe what you are doing makes this seem so easy to understand.
That's awesome, I'm glad to hear it!
Out of curiosity, what's the game?
I've been programming computers for 20 years. This series of videos is by far the best tutorial of any programming task I've ever seen. Well done, and thank you so much for making this.
I was wondering, will you be making a quest system?
I've been binch-watching your videos for the past few days. Already learned more than I have from the past 3 months of (what feels like) endless of Unity and C# tutorials. I'm making my first game for my fiancé to play and finally, I feel like I've gone from turning slightly insane to actually understand what I'm doing. Thanks, tack, from Sweden
Btw an alternative is something like:
minPosition = new Vector2(Mathf.Floor(target.position.x / 25) * 25 + 6.666f, Mathf.Ceil(target.position.y / 25)*25 - 20);
maxPosition = new Vector2(Mathf.Floor(target.position.x / 25)*25+18.335f, Mathf.Ceil(target.position.y / 25) * 25 - 5);
I personally like this method more because the player doesn't teleport. The only downside is that every room has to be the same size
You could create a new variable to assign the new maximum and minimum position of the camera, worked pretty well for me, and worked well for non square rooms. All i did was:
cam.MinPos.x = newMinpos.x;
cam.MinPos.y = newMinpos.y;
cam.MaxPos.x = newMaxPos.x;
cam.MaxPos.y = newMaxPos.y;
Sorry if its already been mentioned but to reduce the amount of objects you need for room transitions, you can add a bool that flips when you go in and just have the code do the opposite when you hit the same trigger. like this:
if (other.CompareTag("Player") && TriggeredOnce == false)
{
cam.MinPosition += MincameraChange;
cam.MaxPosition += MaxcameraChange;
other.transform.position += playerChange;
TriggeredOnce = true;
}else if (other.CompareTag("Player") && TriggeredOnce == true)
{
cam.MinPosition -= MincameraChange;
cam.MaxPosition -= MaxcameraChange;
other.transform.position -= playerChange;
TriggeredOnce = false;
}
Just use tilemap 2d and tilemap collider as a trigger and do the same thing as he did
This tutorial is really easy to follow and covers so much content! Thanks so much. It has really got me interested in unity development, this is the perfect place to start! Honestly have no idea why this isn't more popular
Thanks so much! This tutorial series is definitely a work in progress so forgive any bumps along the way :)
It works like a charm. I'm still learning so much from each video. Thanks again for creating these!
Thanks!
I cant tell how good you're tutorials are, thank you so much, maybe one day I will publish my own game :D
thanks!
*your
You are a legend! I miss school, this is great!
Ha, thanks!
Hello there
Mister Taft Creates!
I gotta show you support and love for making this series and keeping it up until this day! from all the tutorials out there including very big famous unity youtubers you are by far the one i got hooked to, seriously this is the first thing i do after i get back home from work!
i intend to finish your tutorial i am really expecting to reach the upcoming parts!
I have a slight suggestion for this camera movement part here, it is more of a "taste and feel" kinda suggestion and i would very much appreciate if you could responde to it and give your thought!
i found that for my eye it felt kinda weird that when the camera travels up to the new room it stills shows some part of the lower room, (again, for my taste) so i changed the parameters on the "Room Move" script from "Camera Change" to be 2 parameters: cameraMinChange and cameraMaxChange.
The cameraMaxChange still holds the same value 25 on Y axis but the cameraMinChange holds a higher value 27 on Y axis which results in the camera moving even more up aligning itself so that the lower part of it fits exactly with the lower border of the room.
i would very much appreciate your thoughts on that!
Again thank you so much for taking the time and patience in making this videos! already subscribed liked and shared your videos and channel, keep up the good work and the calming and humble attitude!
Cheers
Wow just when I thought this was going to be the hardest thing yet, it was very simple and you made it very easy to understhand. Thanks!
Thanks! I end up doing this another way later in the series that is even simpler. If you want to jump ahead to the videos titled Observer Objects and Cinemachine Cameras, you can see how to do that.
my bounding boxes on my camera are broken when going to the next room can you help me?
i made my stuff pretty nice the transitions look pretty good too but my camera stopped following my player? is there anything wrong that i have done.pls help
Amazing playlist! Thanks a lot for the video.
I am currently developing a pixel art game in Unity that takes place in a house. So I need transtions between rooms. In addition, some rooms are going to have top-down view and others side-scroller.
Do you think the best approach for this case is each room be a scene? Or to have many rooms inside only one scene?
Thanks for making this serie.
So I've made another tilemap. All done on Unity.
I don't know how to select all of the grids and call it a new Tilemap, I just have the one "Grid".
I want the tile maps to be "Cross Roads" and "Beach" where yours a room 2 and overworld.
How do I separate rooms when I'm using Unity's tilemap editor? It's just one big ground. How do I define the second room as a second room?
Go to 2D and select Create Tilemap
have you found the solutions yet? :(( i also encounter the same problem...
Hey Mr.Taft
I'm having a scale issue - well, several issues actually
1st, since I continued my tilemaps (collision & ground) both in unity, I'm not sure how, or even if I should, separate the rooms to different objects. I'm sure this has a benefit, in terms of keeping things ordered. How would you suggest this be done?
2nd - and this is not an issue right now - but I have a strong gut feeling this is gonna come up definitely in the near future: I noticed, when I created the RoomTransfer object, that my scales are way different than yours, for some reason unknown to me
I used 16 PPU when importing sprites, just as you did
but the scale of my objects - all objects in fact - is 1, 1, 1
camera, player, grid, tilemaps, everyhing in my project is 1,1,1
and the gameobject "roomtransfer" appears huge in my project for some reason - whereas yours appears very small
so I check out the scale in your project and noticed that your grid and other object are at 0.065 or something like that
my question is:
what *should* the scales be?
how do I make sure, in the beginning, when it's still easy to control, that the scales are set right, and don't bite me back sometime in the future?
Your scale should be 1, 1, 1 - in case you want to manipulate that later. I didn't think that happened to my scales. I'll have to look later today.
@@MisterTaftCreates I'm learning so much from just following these videos. One of the notes I jotted down is to make certain in future projects to know my scale and positioning in advance. I'm not 100% certain I caught your scale numbers right when rewinding the videos. However more differences rose as I was implementing the place name - mine, in spite of being setup just like yours, ended up much more square'ish for some reason. Maybe my mac's resolution and screen aspect ratio played a part here. Not sure yet.
Thank you for asking this.
So my rooms are not square and equal shape and I am awfully stuck, would appreciate much if u could help
so my camera is fine but when i transition into a new map it doesnt have boundaries. help :(
same and my room is taller on y and longer on x than my original
@@breaker19ist Did you fix it?
@@ozonichi kinda if you scroll through the playlists there is a FAQ video where he addresses questions that get asked quite a bit
@@breaker19ist thanks I got it.
I changed y values for x values when clamping
8:45 i don't understand what you mean by i'll need 2 different vectors
idk what to put for them, my other rooms aren't the same shape
I'm trying to get the camera to move past the screen transition and continue following the player, but it stops too soon
instead of making the one Room Transfer into a Prefab i made an empty game object a parent of both Room transfer triggers.
Then making that empty game object with the 2 Transfer triggers a child of it into a Prefab. that way when you grab the Prefab you are grabbing both Transfers in one object and can rotate it and scale it as you need it and will edit the orientation of both triggers at same time by scaling and rotating the parent object.
Could you make a simple version of the Unity project available for download?
How do we do that withouts using a tiled map? Cuase i cant seem to make the map i made with unity an object like the tile map you made with tiled
When I add the script the public variables Camera Change and Player Change aren't visible in the inspector and I get the compiler error CS0034: Operator '+=' is ambiguous on operands of type 'Vector3' and 'Vector2'
I followed the code exactly so any insight here? First hangup so far the tuts have been incredible!
Hey loving the videos but have a question how can i setup the camara bonding for other size maps/rooms or is this not possable IE.. first map max is x25, y5 - min x-25 y-5 then switch to a new room with smaller bonding hope that makes some sence
Hey I know I'm a bit late but I'm following all your videos up to this point and it's been super helpful !!! But I'm having a problem , when I go through the room transfer and brings my character to the next area and if I making my character go back through room transfer 2 it brings me back to the starting area , so all that is working
The problem I have is when I go into the second area the camera doesnt so the same thing as yours, I'm able to see the starting area in the second area . And it also doesn't go all the way up to the top there's like the border we had in the starting area. Sorry if that was long and confusing but it's a bit of a weird problem :/
Me too if u resolved that problem can u help me please?
Amazing! Love it! Works beautifully.
I'm glad it works!
Hi everyone, I've started to implement some of the elements from your videos into my project and I was wondering if doing this specific room transition is possible without using tiled? Can I do it by just having different sections of my tilemap and have separate boundaries? Thanks and great job on your videos!
That's totally doable. Later in the series I show an even easier way to do this. The videos are Observer Objects, and Cinemachine Cameras. Those videos go over a very simple way to do this with any object
hi. what did you put to the script for camera? i dont know how to make it change for a room to another. i'm french sow i try to laern what you do sow if you can give my explicity details that cool. Thx
Edited: Had some trouble with the trigger freaking out when slowly stepping in to it. It turns out it was caused by having multiple colliders on my player. This also made the triggers push me twice as far as it did once I deactivated one. Now it works fine
Thank you for lessons again!can you help me,i have got trouble,I see the borders of objects,what can i do?,i think i missed some info in videos.
This is sick.
You are so underrated ❤❤nice videos
Question, I sticked with the Unitity Tilemap since in video 10 you are going to show a fix for the ugly seems. Thing is that when I select my Room 1 > Collision layer (which I made 30x30) shows a rectangle square with a white outline and blue dots on every corner with a different size (47x30)? It looks to me that my Collision is now overlapping the collision of Room 2? Were can I change the size of my Collison layer because if I take the blue dot and squise my rectangle, it is going to Scale it, not resize the Collision layer?
Awesome, another feature you make so easy
what is the code for the not square room to change the camera angle
Would it be a viable option to add a "switch" bool variable to the Room Transfer class, so that on enter you add the changes and toggle the switch, on enter again you subtract changes and toggle? I tried this, and it works, and it removes the need to move the player forward at all.
Could I get that added code?
Having a problem with the camera collider with the end of the map not working, everytime i walk near the edge it doesnt stop, just shows grey
For some reason I am stuck in the beginning of the video. Someone help? I made everything via the ground tilemap and the collision tilemap, so how would I create a "Room 2" Tilemap but still use the properties of the ground and collision maps? Isn't it a separate asset in the tilemap? Does that mean I would have to create this new room with its' own ground and collision maps and repeat the process every time there I creat a new room? I was making it more tiles and rooms all with the same "Ground" and "Collision" units I have in the Hierarchy. Halp.
Hey, I have almost no idea what I'm doing, but I think if you create a new tilemap for room 2, you can just copy and paste the collision and ground objects from your hierarchy list and paste them under the new one. I just did that, and the collision one has the colliders and such we added the first time on it. Although I suppose you can just rename the tilemap it imports under the grid to Ground, since as i recall we didn't do anything special to it. I hope this helps you until someone smarter comes around. I can't test if placing things on the new collision grid makes it have collision or not, because I still havent figured out room transfers and moving the damn camera there. So...Take that for what you will.
How I did t think of this is beyond me. You’re killer. ♥️ thank you.
I got it working, the new room does get the collision we made when you just copy paste the collision object we made in the previous lesson. So you don't have to manually set it up everytime. You can even make it a prefab for later. So that is a solution, I think.
Amanda Sampson you’reeeeee the best.
i am using unity build in tilemapping stuff, and i have one mega level sofar where i have basicly multiple rooms, but different sizes, all are on the same grid though, how would i have to change the script so that it works like it does for you? i am asking because i only started this unity journey end of january and i dont know much yet, would be realy nice of you to let me know :)
idk why but its not working at all
it compiled fine and there were no errors but it doesnt work
if anyone knows why please help me
Error CS1061: ‘Vector2’ does not contain a definition for ‘main’ and no accepting a first argument of the ‘Vector2’ could be found (are you missing a using directive or an assembly reference?)
same problem
@@Blazelegend same, any fix?
Im having an issue with my camera jumping back to the player start position when I start walking forward but the camera follows when i go left and right. please help me lol
So how would you create the forest maze in Zelda 1 with this method? Rather than coding coordinates and locking them to those numbers, could you use the room name and its boundaries to define the camera? This way you could change the room later, or it’s position?
You can do that, or you can dynamically load different rooms when you exit one. For example, put a trigger on the left side, and when you enter that zone, it recreates a specific room, but a different one on the right side of that room. If that makes sense.
How would you divorce the screen transition from the camera smoothing? Like if for example you wanted the transition to be half the speed it currently is without changing the smoothing to avoid stuttering? Or is this covered in a later episode?
Hmm? Operator '+=' is ambiguous of type Vector3 and Vector2... I'm not getting the Change Camera and Change Player bit on the added component even though the script is exactly the same (I'm running Unity 2020 and Visual Studio 1.58).
I followed exactly and my character transitions to the next room as soon as the camera itself touches the box collider instead of the character having to touch it. How do I fix that?
i don't know why after putting the script in Room Transfer , it doesn't show me the two objects Camera Change and Player Change
are they private or public?
I know your comment is 2 years old but I'm currently following this tutorial and am having the same issue. My script is exactly the same but when I add the Room Transfer script as a component it doesn't show Camera Change or Player Change.
It's okay to skip this if I want something more open world-y right? I wouldn't be using room transitions so I just want to be sure.
When i change the smoothing my camera starts shaking, so how can i change the smoothing without getting a shaking camera?
The camera shakes because the player is stepping on both "room transfers" at the same time. Try to increase the player position (if it's 2, make it 4).
Oye amigo yo quiero que cuando cambie a la otra escena cambie tambien el minimo y maximo de la camara ya que la otra escena es mas pequeña o grande,depende, tienes alguna solucion para eso Gracias
man im struggling here bro not anything to do with you or the script i think but my first roomtransfer works perfectly and so does the transition back, but when i used the prefab to transfer to another room the camera jumps like double the distance then when i try to walk the player to the camera like 8 units away the camera jumps back to the other room??? super strange
also bro I realized that in the unity tile map editor yes it does end up makign the player jerk forward but that was before I put the tilemap above the camera in the scene, and the jerkiness stopped. are there any unwanted consequences from doing that or should i really just stick to Tiled Editor to avoid the jerkiness, I ask because I had a bit of an issue importing the tile map from tiled2unity, because it had 3 layers, game object, collision, and ground, and when i dragged the prefab into the scene it allowed me to drag it but nothing appeared, I had to drag in the individual meshes of the layers from the mesh folder, and fiddle around with the sequence in the scene heirarchy for it to even render the collision layer, and half the time it just wouldnt work and would make the play test button inaccesible for some reason. thanks man from nyc this has been my dream since i was 7 years old and you, you!!!! are making it possible god bless
My room is the exact same size as last one, only difference was I went to the right. Now I'm running into a problem where the camera only wants to go half way to the right of the room instead of its full width do you have any suggestions for what I do?
So I try to import a second tiled map to follow this transition tutorial but it gives me an error in unity when I try to import it. 'The object you are trying to replace does not exist or is not a Prefab'. How do I combat this?
previously there is no Tiled Map (script) for the room 1..is it necessary and how did you add it??plus how did you manage to name the room i mean do separate section of rooms (overworld and room 2) okay i totally lost lol..someone help me please i want to continue but im stuck here
Can someone explain the move of "Room Transfer" for the prefab folder, at 12:30 ? And why only "Room Transfer" and not the both "Room Transfer" was transfered to prefab folder ?
Once you make it a prefab you can reuse it and make many instances of it.
You can also edit all of the instances of that object at once (what if we want to add a component later? Now instead of however many room transfers you have, you only need to do it once and apply to the rest).
So while he could have duplicated it, since he turned it into a prefab he can drag it in a new scene without creating it from scratch (not there to duplicate from).
Mister Taft Creates please HELP! When I check the " Is trigger" in the Player collider box, then all borders from both maps disappear. How to fix it?
I'm a bit lost, how did you made a separate room?
operator += is ambiguous on operands of type vector2 vector3.
this is my error. how can i solve this. pls help
When you move the camera, you move it by 25 units in the Y direction, which happens to be 25 tiles. Each tile is 16x16 pixels. Where in Unity is it set that 1 unit is 16px?
Assets/roommove.cs(21,9): error CS0106: The modifier 'private' is not valid for this item
go to line 21 and change it
I don't think I'm going to use tide to create my tile maps.. will that affect anything in this video using the unity tile map?
How did you separate the rooms?
Is it possible to download more assets such as Like trees?
(Same style)
When I go to the middle of my next room, the camera jumps to an empty background. How can I fix this?
Try tweaking your x and y numbers. For y I predicted 21, but it kept on jumping too far. I ended up only putting 6 by the end of it. Hope this helps
@@artsy196 witch x and y numbers. I'm having the same issue
@@thethirdeyesociety oh man its been a phat minute since i've touched unity i literally have no idea im sorry
@@artsy196 Its all good man
Sooo... if we were to do this part but in the unity tilemap maker, how would we do this? Because i made 2 separate tilemaps but the trigger just isn't working. It seems like nobody has talked about this in the comments so far and I just want to know because I don't feel like switching to tiled just to switch back. :)
Hey there - I am following along with just the unity tilemap maker and was able to get the trigger working so just as a heads up it is possible.
Things I would check in your game:
- On the Room Transfer Object, on the Box Collider 2D section - "Is Trigger" should be true
- On the Player Object, can you confirm the player tag is set to "Player"
- Make sure you named the method exactly this : OnTriggerEnter2D. Capitalization is important! If you have a lower case e for example - the code will compile but it will not fire.
- Make sure the box collider 2D is large enough to collide with and its where you expect it to be.
- If none of the above, try putting: Debug.Log("Transferred to new room"); in the OnTriggerEnter2D and see if that text pops up when you step on it.
Let me know if you get it working!
@@aaron58107 Thank you! I think I didn't change the players tag to Player.
Where I'm struggling is with the stuff he said he did off camera. Creating 2 separate tilemaps.
I've created 2 small maps but now I don't know how to call them 2 different tilemaps. Is there a way to select all of my grids and drag it to a new Tilemap?
@@LiamR90 So my understanding is that when he says "Create two separate tile maps" its repeating the step from the tutorial in Part 4 where he says to right click the hierarchy -> Select 2D Object and then select Tilemap. You should then have two grid items in your scene with a tilemap under each. When I look at his tutorial here thats what I'm seeing.
He also states that you can continue using a single tilemap and all the code in this video doesn't really care if you have one or two maps - but if you want to match him exactly I'd follow the steps above.
If both your maps are under a single tilemap and you want it separated - you can always follow the steps above, duplicate your tilemap where you drew 2 small maps and then erase so that each grid/tilemap has one room.
Its a bit hard to type out but hopefully this makes some sense. Best of luck.
@@aaron58107 Ye, I did go back to when he made the original but it doesn't seem to highlight a specific area. It only gives traits to Ground or Collision.
I was hoping to be able to highlight all my grids and somehow have that as the tilemap.
Now if have to just keep it all on a single tilemap and have my camera move X amound of squares into the other area.
How exactly could we set up different camera bounds for rooms without changing the bounds for the other rooms? Like having the cmaera automatically change it's bounds depending on the room it's in.
Hey there. That's the best way to do this. In that case, I'd add a function to the camera to split the world up into grids, 25 by 25 in my example, you can have this work entirely in code. Then when the camera finds the target, have the camera decide which part of the grid it needs to stay in. If the player moves out of that part of the grid, then the camera needs to snap to its new boundaries
This way would be much more "clean" but much more programming intensive. I decided to go the way I did because I wanted this series to be beginner friendly, but by doing it the other way, you allow for those big fields that you see in ALttP
@@MisterTaftCreates ohh alright. I'll try and resize the rooms in that case! Thanks ^^
Is it necessary to watch this video and/or implement this feature for the continuity of the rest of this series.
Another great tutorial. Thanks!
Thanks so much!
Awesome!!!! I was wondering how this was done, why you make it look so easy?
sorry but I can't deal with the problem of rooms of different sizes ... the point is that I can't adjust the camera so that it adapts to them, can you please help nicely please;)?
if i put my smoothing to a decimal below 1, my player gets all jerky but walks smoothly when i set the smoothing to 1. but when its at 1, the camera transition is instant, because the smoothing is too high. is there any way i can lower my smoothing down to .1 or .5 without it awkwardly keeping up with my character?
make sure the camera is not still parented to the player i had that issue
Hey so i know this video is nearly a year old but i'm getting an error where it says "Assets\Scripts\RoomMove.cs(25,19): error CS1061: 'Collider2D' does not contain a definition for 'ComparerTag' and no accessible extension method 'ComparerTag' accepting a first argument of type 'Collider2D' could be found" which stops me from having the camera/player change variables showing up in unity, any help would be much appreciated.
Hey there. You wrote comparertag instead of comparetag. :)
Hello! awesome tutorials! congratz!
I have a problem with my project, the camera only moves if my player is also a trigger... is that normal? what if i Have to define a new minumum and maximum to the camera?
Thanks once again e keep up the good work!
No that's not normal. I revisit the camera and transitions in a later video using Cinemachine. If you can, jump ahead to the video on observer objects and the video on a cinemachine camera and this should fix most of the issues.
My rooms are 35 long by 20 made in unity. I'm having trouble with go halfway up into the next room and it puts me back in the 1st room and can't see my character? I've set my 1st room at y being 11 and 2, the top room at - 11 and - 2. Thanks
Hey there. Skip ahead to I think part 36 and part 40, where I add a cinemachine camera. This will fix your issues.
My trigger isn't working. I followed the directions but I can walk right through it. Thoughts?
nevermind. I deleted the empty object and tried again and it works.
Thank you for the videos.
Howdy! I was wondering what the code would be without any reference to the camera following the player, like Binding Of Isaac.
assuming the camera sees the whole room and the rooms are all the same size you would still do the same code since all this code does is move the camera and relock it which should work for something like that
It's an old video but i need your help...i've followed step for step all your passeges but in the code, when i write cam = cameraChange.main.GetComponent(); appear the error CS1061 ‘Vector2’ does not contain a definition for ‘main’ and no accepting a first argument of the ‘Vector2’ could be found (are you missing a using directive or an assembly reference?).....please help me, i don't know how to fix it.
Hey there. I re-did the camera system later in the series, and it's safe for you to jump forward to that if you want. It's the two parts called Observer objects and Cinemachine. This will make the room transition work much better.
@@MisterTaftCreates thx you :)
How do you turn a room you make in Unity into an object? I am not using Tiled.
I cover this much later. I think it's video 46 - Observer objects.
@@MisterTaftCreates thank you!!
We have the room transition but it only works one way, when we try to go the other way it simply turns us back as if we were travelling from the first room. How do we fix this?
Hey there. It sounds like your collider for the transition might be so big that it's triggering in both directions. Try to resize it, and let me know.
So I wrote the RoomMove.cs script exactly like you did, and it compiled correctly and everything, but when I play it, there is an error that says:
NullReferenceException: Object reference not set to an instance of an object
RoomMove.Start () (at Assets/Scripts/RoomMove.cs:13)
The line where the error is occurring says:
cam = Camera.main.GetComponent();
And the global variable for cam is set at the top and says:
private CameraMovement cam;
I'm not exactly sure why I'm getting this error and I can't seem to find the solution, especially since all of the scripts I've made so far are exactly like you showed. Do you have any idea what might be causing this?
try tagiing the main camera with main camera hope it fix yours ty
@@BurgerParty it solved mine! thanks man
@@BurgerParty Thanks you are the best!
my room is smaller than the other room that you enter from. I am extremely frusterated at this point. I literally have no idea what to do. So basically, I have my y and x set up so that you can't see past the barriers. But the barriers on the right side. The camera can see over. But on the left they cannot. Also, when I enter the room. It goes in so far that I cannot see the exit anymore. i just have to blindy walk backwards. Please helpp.
// Hello, I was following this tutorial and had the same problem
// ROOM MOVE SCRIPT
private void OnTriggerEnter2D(Collider2D other1)
{
if (other1.CompareTag("Player"))
{
cam.minPosition += cameraChange_MIN;
cam.maxPosition += cameraChange_MAX;
other1.transform.position += playerChange;
}
}
// For me, there were small errors i had in my script, such as the min and max position switched around
// You should also check your other scripts
// CAMERA MOVEMENT SCRIPT
void LateUpdate()
{
if (transform.position != target.position)
{
Vector3 targetPosition = new Vector3(target.position.x, target.position.y, transform.position.z);
targetPosition.x = Mathf.Clamp(targetPosition.x, minPosition.x, maxPosition.x);
targetPosition.y = Mathf.Clamp(targetPosition.y, minPosition.y, maxPosition.y);
transform.position = Vector3.Lerp(transform.position, targetPosition, smoothing);
}
}
// For some reason, i had switched the end maxPosition.y with maxPosition.x
// I'm sorry, that's all the advice I can give
// I think as long as your room is not smaller than the camera, it should be fine
my room is smaller than the other one. i can't figure ouyt what x to put
what did he mean by two different vectors, one for the min and one for the max?
How would we create those two separate rooms like that? Any help on this would be greatly appreciated :P
You need to make another 2d Tilemap to create separate rooms. 'Grid' essentially becomes Room 1
when i go into the 2nd room it will only allow me to go up so far then it snaps back into the last room but i can walk left and right no problem i can still transition between both rooms just if i walk too high into the 2nd room it pings back
thank you so much!!!
Help! I never get the OnTriggerEnter2D to happen, I set as trigger in the Room Transfer game object.
Hey I had same problem even when I had "IsTrigger" checked on my 2D collider and I had everything right. I am not sure what is the main reason it started working, but mainly instead of just cameraChange I assigned cameraChangeMax and Min to cam.minPosition and maxPosition. This also gives me advantage that my rooms doesn't have to be same size and I just adjust min and max values to match room size. I also installed Unity Tools, because intellisence didn't suggest me OnTriggerEnter method and everything worked just fine without Unity tools until this point.
If you still have this problem, just write here and I'll help :)
@@lukasvolcik5109 how did you assigned the cameraChangeMax and min to cam.minPosition and maxPosition ?
@@scrolllock4583 Instead of one cameraChange on the top you declare two like: public Vector2 cameraChangeMax; ... and also same for "cameraChangeMin".
Then in onTrigger method, you just assign it like:
cam.minPosition += cameraChangeMin;
cam.maxPosition += cameraChangeMax;
... Funny thing is that I made Debug.Log before if statement and even when it got working, my Debug.Log still don't notice that it's working :D :D
@@scrolllock4583 I kinda messed up with everything like removing collider2D and making a new one, changing size of players collider, because problem really can't be in that script. Maybe just try bigger minimal value in editor. You can send me pictures or videos of what is happening to you on FB with same name as this account and surely I can help.
@@lukasvolcik5109 i think i added you ?
Hi! This tutorial is very nice, it has been extremely helpful to do a step forward and start with Unity at last. Thank you very much!
I'm having some issues with warping the camera during the transition; when I play the game, this message appears:
NullReferenceException: Object reference not set to an instance of an object
RoomMove.OnTriggerEnter2D (UnityEngine.Collider2D other)
If I've understood correctly, the problem is in the following line :
"cam = Camera.main.GetComponent();"
Can someone help me with this? Thanks!
Hey there. That error comes when the script is trying to access an object, but the object was never referenced completely, so the reference is null or empty. Check to make sure you've completed connecting the objects outside of the script in the inspector.
@@MisterTaftCreates Thank you very much! :D There was indeed a problem in the minPosition and the maxPosition in the inspector.
Hi, I've run into the same problem and I can't really figure it out. Could someone please help me? It just still showing the same message and nothing really is fixing it. I've been trying writting code once again, but it didn't help.
Nevermind I fixed it. If someone also have this problem, just tag your camera "MainCamera". It's a deafult tag in unity and it should help.
Btw great videos dude :D
@@tez1000 aaaaaaaaaaaaaah THANK YOU! :)
I remember back in the last camera video you said that in this video you'd set min and max programmatically rather than empirically, but I'm not seeing any of that. So how do you do that?
did you find out how to do it
@@nevoak7481 No
Do you think that you can put the source code on a GitHub?
I am new to C# and unity in general, I was wondering what to do if the transition is from one room size to a bigger size, how would I set some the cameras bound min/max x and y. Also just wanted to say your tutorials are amazing to learn how unity works, I know this comment is after the video has been out, but was hoping I could still get help for this issue (sorry if it's hard to read/understand)
Hey there. Jump forward to part 48 for a quick minute and institute Cinemachine. It will work much more nicely for rooms of different sizes. Then you can jump back to where you are now.
@@MisterTaftCreates Thank you! your tutorials have been a great help in learning. Have a good day
Hello, how do change the bounds of your room if one room is bigger horizontally and vertically?
Hey there. You would just set the min and max x and y accordingly. For example, if the new room is 40 tiles by 25 tiles, then adjust min and max x by the change on those axes, and the min and max y by 25. Let me know if that doesn't help.
@@MisterTaftCreates This works for the bigger room but now the camera is not bounded for the previous smaller room enabling the player to see into the next room before they hit the transition.
You are amazing