How To Make A 2.5D Game - Unity

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I still remember the first time I seen it I was an absolute awe Judy Sprites coexisting in a 3D environment it just seems so groundbreaking what's up developers I'm that one Unity Dev and today I'll be showing you guys how to implement your 2D Sprites into a 3D environment to create something similar to what you're looking at on screen before we jump into today's video if you're new around here and want to learn more about Unity or game creation as a whole please consider subscribing I typically post about topics that don't have a lot of resources online and even one suggested by you guys I usually start my tutorial videos by talking about what we're going to do first and maybe even some relevant background information but I mean it's pretty self-explanatory we just hit this button in unity and now we have 2D Sprites in a 3D environment well the deal is over see you guys next time I'm just kidding there's actually quite a bit of work that needs to be done before you have something that actually looks good so without further Ado let's just jump straight into it starting from scratch in an empty 3D urp project I import the Sprite package from the package manager I then import my character sprites some ground tiles and set up a simple Terrain I could have just used a plane but I opted for using the terrain for an extra Dimension height after giving the train a quick makeover I create an empty game object name it to player and do the unthinkable I drag my spray into the 3D environment [Applause] [Music] after making a child of the empty and centering it you can see we are already halfway to our goal if you were a beginner and tried to continue on your own the biggest roadblock you will run into at this point would probably be the player movement typically through my tutorial videos I kind of just shrug off player controllers with the not my problem attitude but this time is a little bit different since we're doing something outside the norm I will show you how I tackle this problem so usually an in 2D environment your player has a 2d rigid body with 2D colliders gravity Etc well we can't really do that in this case because we need our player to interact with the 3D world around them to solve this we'll add a sphere collider to our main parent object a normal rigid body and a new player controller script that we're about to make then open up the player controller script before we get into the actual code let's take a break and explain what we're trying to achieve first so obviously we want to move our player around in the game environment in a left right maybe even forwards and backwards into our scene if we want to get fancy but because we have height in our game and no physics when we move our player on this hill for instance he will simply just clip into it and ignore any surface he should otherwise be standing on to fix this we're going to do something called a raycast and snap him to the ground so now that we know what we're doing let's see what that looks like in actual code [Music] [Applause] in visual Studios as you can see I went ahead and I created the player controller in this script we have a few public variables one for movement speed one for the snapping distance to the ground one for the terrain layer and one for the Sprite renderer of the player's right in start we get a rigid body of the player in an update we use our raycast to shoot a line from the player downwards that only detects the terrain layer then if that line hits the terrain we simply move the player a set height above the point it hit below that we're using the rushed body to move the player honestly it's not that much different from what you might normally do just getting input setting velocity I also flip my sprite's ax in the Sprite renderer depending on what way you're moving back in entity we can create a new layer called terrain an assign our terrain that layer on our player script I set my speed to 2 set my terrain layer to the one we just created and drag and drop the Sprite render of my player Sprite into its variable slot if we hit play you can see the player has now snap to the terrain although it doesn't quite look right during runtime we can adjust the Y distance to the snapping point once you get something that looks good make a note of the number exit runtime and write it in the field now we can hit play and walk around our environment awesome next we can focus a bit more on the visuals and better sell the 2D 3d effect I went ahead and imported a 3D model I created earlier all I did to create this model was go into blender slot my image on a plane cut it up with the knife tool and give it some thickness this is a very cool effect and as you can see by using the same art style on the 3D model Unity is doing all the heavy lifting and essentially closing the gap between the 2D and 3D World after importing this other character sprite and putting him in the scene we can see he looks a bit flat compared to the house model to give her some extra depth we can create a new child sphere object disable the collider make it not render and instead only cache Shadows this looks so much better and in fact we can repeat the same process for the player character tidy animations is the exact same process as if you're working in a 2d environment no difference there although if you want to move the Shadows to better match your animation make sure you set your curves to constant in the curve editor to make the camera follow the player I import the cinemachine package create a 2d camera set the follow-up Target to the player change the X rotation and play with the Z position on fov to get something I'm happy with after importing more Sprites adding animations and a touch of post-processing you can see the scene really has come together the hardest part of creating the scene was actually the aftermath because now I want to create an entire game in this style but that's pretty much it for this tutorial if you enjoyed today's video consider showing the like And subscribe button some love or even leaving a comment it really goes a long way to help YouTube recommend this video and gets me one step closer to being monetized if you get stuck we've also built a wonderful community on Discord for real help each other out and if you have some video suggestions or feedback I'd love to hear it but that's all the time we have for this video thanks for watching and staying until the end bye foreign
Info
Channel: ThatOneUnityDev
Views: 72,464
Rating: undefined out of 5
Keywords: ThatOneUnityDev, unity, unity3d, unity2d, tutorial, madewithunity, that one unity dev, 2d, game, visuals, indiedev, lights, lights2d, how, to, make, day, day/night, night, cycle, how to make a 2d day/night cycle, how to make a 2d day night cycle, pixel art, pixel, that, one, dev, UI, Tab, Based, System, Tab System, Event, Triggers, Event Triggers, Sliders, Slider, Health, Bar, HealthBar, Healthbar, wave, system, Bestiary, 2.5D, 2.5d
Id: cqNBA9Pslg8
Channel Id: undefined
Length: 6min 47sec (407 seconds)
Published: Sun Mar 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.