Transcript for:
Adventure Creator: Building a 2.5D Adventure Game in Unity

hi I'm Chris and in this tutorial we're going to be making a 2.5 D point-and-click adventure game using adventure creator and unity this is going to be a remake of an earlier tutorial so that we are using more recent versions I'm going to be using unity 20 18.3 and adventure creator version 1.6 6.4 2.5 D refers to the use of 3d characters on top of 2d backgrounds and so we're going to be making a simple scene that we can navigate around relying on photographs for our backgrounds I have open here a fresh project with unity 20 18.3 and I've got my asset store window open here where I can import the latest release of adventure creator then be given this installation window just asking us if we're happy for it to create a couple of inputs and layers that's all fine so I'll check okay and once it's finished importing we'll have this new adventure crater folder in our project window this tutorial is also going to make use of a few other assets and we can find these on the adventure crater downloads page if I go up to the top toolbar and choose adventure crater online resources and then downloads you'll be taken to this page on the website and if I scroll down to tutorial assets evil lair and Wharf I can click to download a dot unity package if I then navigate to where it's been saved and double click on it unity will then ask me which files I want to import I'm going to report all of them and once it's finished we'll then get this other folder tutorial files also in our assets directory if we open it up we'll find two subfolders within it I'm going to go to Wharf and then open up the wharf seam that is inside just to show you we have to begin with this this grid floor here that is going to act as the area that the player can move as well as a few reference cameras that we'll be making use of later on but for now I'm going to start with a new scene and make use of the new game wizard to set up our project each game that is made using AC relies on its own set of managers and each manager controls a different aspects of your games development we can create a new set of managers by going to the top toolbar and choosing getting started new game wizard and it's in just a case of filling in the fields as we go so I'll choose next and we'll be asked to enter in a game name I'll type in my 2.5 the game she's next perspective is going to be 2.5 D and we're going to be having multiple backgrounds in a single scene so I'll leave this checkbox unchecked our interface or how do we want to interact with hotspots I'm going to leave it as context sensitive because that's not the focus of this tutorial and this option is the most simple for other modes check out the 3d tutorial choosing next again our GUI system I'll leave it as default ac and what this will do is just provide us with a default set of menus that we can use to open up the pause menu save load our game access inventory and so on choosing next one more time we'll just be asked to confirm our choices our movement method is set to point-and-click which is what we want so I'll choose finish and our managers will then be created will then be asked if we want to organize the scene I'm going to choose no because we're going to work with an existing scene we're then also given the AC game editor window and I'm going to pop this in a vertical space here because it tends to be quite deep if we go to save the settings manager you can see it's very vertical let's now go back to the wharf scene I'll choose don't save and with the scene manager open we have this basic structure panel and we get two options to organize our scene objects and I'm going to choose with folders there is no wrong answer here it's really just a case of preference but this option just gives us a selection of folder game objects that we can use to keep our hierarchy uncluttered I'll place the directional light in the lights folder the wharf which is the floor into my set geometry folder and my main camera into my camera's folder I'll then just save the scene as a new scene I'll go to file save as and inside my 2.5 D game I'll call this my my wolf 2.5 D games typically work by having either pre-rendered or photographic backgrounds underlaid underneath 3d characters where the perspective matches so that you don't really see that part of the scene is in 2d and part of it is in 3d we're going to be using photographic backgrounds and we can find some texture files in tutorial files Worf set and then photos and we have four texture files here waterfront steps Plaza and office and the area that these photos were taken in has been recreated in this this model here this is the floor of the area that the photos show and it's the area that the character in our scene will be able to walk around in the waterfront in this picture is this rectangle down here the steps is this ramp and we have the plaza and office around the top here we also have these four cameras in our scene if I expand the reference cameras folder we've got cameras already set up in the corresponding positions that each of these photos were taken what we're going to be GC using those for reference I'm going to be making new cameras from scratch and I can do that from the AC game editor in the scene manager and if I scroll down I get this scene prefabs section and I want to make a new game camera 2.5 D so I'll click on it and rename it to water front camera if I then look at its inspector you can see its component just has a single background field and I'll click on create because it's empty at the moment and it'll automatically create and assign this water front cam background object I'll drag that into my set drama chief folder and looking at the inspector for this you can see we've got again just a single field this time a background texture and I'm going to assign the waterfront texture now that that's assigned I can go back to waterfront cam and you can see we now have a set as active button and if I click on it well we'll actually have to see the effects of the game window so I'm going to have the game window and the scene window open at the same time so now that this is active I can move this camera around the scene and it'll show both the floor and the background texture underneath it so what I'm going to do is position it at the same place as this waterfront reference camera go to the transform component of that reference camera and choose copy component and I'll paste that back in to the transform of this waterfront cam I'll also make sure that the field of view matches up on the reference camera it's 35 so I'll enter in 35 to my new game camera and you can see now that the floor matches up with the background I'll remove the waterfront reference camera just so I don't get them mixed up and because this is going to be the first camera in our scene I'm going to make it the default so I'll go back to the scene manager and underneath our scene settings we have a field for a default player start which is necessary for where the play will begin I'll click on create and I'll also choose from the list that now appears we've got our default camera and I'll choose waterfront cam our default player start is if I double click on it already in the correct place in our scene maybe I'll just move it a little bit forward and you can see it's represented by this blue arrow here in the game window I'm going to now create the other three cameras that will lead in our scene so I'll click again gain camera 2.5 D this one I'll call steps cam I'll just duplicate these now Plaza cam and office cam and going to each of their inspectors I'll create a new background image I'll place these in the set geometry folder and selecting each in turn I'll assign the relevant texture into their background texture field so Plaza Campbell get plaza steps cam will get steps and let's go sort out steps cam so this is going to be at the position that this camera is in so selecting inside of reference cameras steps I'm going to copy the transform component select my steps cam and paste in those values I'll also make a note that the field of view is going to be 33 and then let's test that out by choosing set as active and you can see we have our the ramp matches up with the steps so I'll remove the steps reference camera next we'll do Plaza cam so Plaza I'll choose a copy component our field of view is going to be 23 selecting Plaza cam I'll paste the component values and give it a field of view of 23 sitting as active you see our floor matches up with the camera better I'll remove the Plaza cam and finally office camp I'll copy the component from office paste it into office cam and give it a field of view of 35 setting as active you can see the the floor once again matches up so I can now just remove my reference cameras folder and that's it we now have a set of 4 cameras with the default player start and camera so I can run the scene and although we can't really do anything we do have be the floor showing although we'll get rid of this later along with the the background showing underneath an important consideration to make early on when making a 2.5 degang is that of the aspect ratio you can see down here in the game window we have an aspect ratio set of 16 by 9 but because it's possible for the player to change what resolution their game plays out we need to ensure that the game runs properly at all resolutions now the backgrounds are 1920 pixels by 1080 which gives us an aspect ratio of 16 by 9 which matches up what we currently have the game window said to but if we run the game you'll see that the background actually gets squashed and we get these two vertical bars either side and the reason for that is AC is setting its own aspect ratio it's just that it's not configured to match the backgrounds yet going to our AC game editor and then the settings manager we can scroll down to camera settings and here we have force aspect ratio checked by default for 2.5 D games and then our aspect ratio as a decimal is entered in as 1.5 so an aspect ratio of 16 by 9 in decimal form is 1.7 7 8 so that's what I'll type in to the field here and if we now play the game you'll see that those borders are now removed but if we changed the aspect ratio here in the game window we have these black borders appearing to ensure that the game appears correct no matter what the ratio actually is now I admit I did actually get a bit confused by the fact that if you open up tutorial files warf set photos and then select any of the photos the resolution actually comes up wrong in unity it comes up as 2048 by 1024 and I think what unity is doing is rounding it to the nearest power of 2 so don't be confused by that and actually in the videos that follow I'm actually using the incorrect aspect ratio of 2 to 1 so just leave it as 16 by 9 or 1.7 7/8 as a decimal we're now ready to start configuring the navigation of our scene this is going to be a point and click game and that is set again in the settings manager underneath interface settings you can see we have our movement method set to point-and-click and if it was set to something else we can set it there from this field just above it we have this player field which is currently empty and if we assigned a player prefab here then that player would be spawned in at runtime while we're making a player of our own later on but for now I'm just going to use the demo games player just so that we can get up and running quickly we can find the demo games player inside adventure creator demo and then resources and I'll just drop tin pot directly into the scene if we run the scene he's placed correctly at the player start but clicking it around the scene on the floor doesn't really do anything and that's because we need to set up the navmesh we can choose our path finding method by going to the scene manager and up at the top underneath scene settings we have path finding method I'll set this to unity navigation so that we can rely on unity zone navigation tools we can open up the navigation window by going to window AI and then navigation and if I click on fake will then get the option to bake our nav mesh so what I'm going to do is I'm going to select this floor Wharf object go to its inspector and make sure that navigation static is checked I can then go to the navigation window click on bake and we now get this blue nav mesh baked for us I think I'll increase the agent radius to about 0.35 re bake it and that will just help to prevent the player falling off the edge if he's maybe moving a bit too quickly the final step is just to place this Wharf floor object on the nav mesh layer and that's just so that it can be picked up with mouse cursor clicks so that when we click on the floor the player is able to move there so running the game again I can now point and click I can double click to make the player run now we want to be able to test out the other cameras and later on we'll be making triggers to do that but right now we don't have any so I want to be able to test out the different cameras manually and I can do that by going up to the cameras folder and then game cameras let's try out the steps can if I go to the game camera 2.5 D component I can choose make active from the side menu and that will automatically cut the camera to the steps cam this is a new feature in AC version one point six six point five so I can move up the steps let's try out plaza count by choosing make active and finally office cam now we have this pillar in front of these doors here and we want the player to have to move around it because right now he can just move straight through it so what I'm going to do is I'm going to cut out that part of the navmesh I'll start by going to the office cam and choosing set as active outside of play mode so that we can work on it I'll go over to roughly where this pillar is going to be it's going to be about here and in the hierarchy window I'll choose create 3d objects cube I'll put it down into the floor try to position it just by eyeballing it stretch it out that's about roughly about right and then what I'll do is again I'll go to the top of the inspector check on navigation static and rebake the navmesh with that bait I'll just place it into my set geometry folder uncheck the mesh renderer component so that we don't actually see it and that will stop the player walking through the pillar now that we have our navigation set up let's work on automating the switching of cameras as the player moves around the scene we can do that using triggers and we can find triggers in the scene manager going down to the scene prefabs section and underneath logic we have trigger and a trigger is essentially a boundary that will run certain game logic when the player or any object enters or leaves it and what we're going to do is make this trigger cut the camera when the player enters this region where the stairs are so I'll move it over raise it up a little bit and stretch it out that it so that it covers the whole portion like so then go into its inspector I'll rename the trigger enter steps and underneath its list of trigger properties I'm going to set it when running field to running background so that it doesn't create a cutscene and everything else is as it should be the trigger is going to detect the player and it'll only react cheering game play so underneath is where we place our actions that are basically commands that will run when the trigger is run and I'm going to change the default one to a camera switch action and we get fields for a new camera and I'm going to set this new camera to be steps cam we can test this out by running the game and I want to be able to enter in the steps by clicking at the volume here but you can see the trigger doesn't quite reach it now I can just move the trigger in move the trigger so with these over the player and the camera cuts as normal but we want to be able to have the player then enter this space here and cut the camera back to the waterfront so I'm going to leave the trigger around here in fact what I'll do is I'll just tweak it a little bit now that I've got the player in the correct spot and copy its component values exit play mode and then paste those values back in so we're going to need a way of making the player move towards this trigger when we click at the bottom of the screen with the waterfront camera active if we go to the waterfront cam and choose set as active so that we can see it while editing I'm going to do this by creating a hotspot back in our game editor I'm going to click on hotspot and are reeling this Waterfront two steps and a hotspot is an area of the screen that will run commands or actions when we click on it and I can get a better idea of where this is going to be by checking gizmos in the game window and then if I stretch it out move it back maybe a bit you can see that it's then taking up this yellow region of space at the bottom of the game window so we want to make it so that when the player clicks on this he walks over to say maybe around this area here so that he's in view of the steps can and because he's been in the region of the trigger the camera will then cut as well selecting the hotspot and going to its inspector we were able to create a number of in for action types that will run actions when we click on it I don't actually want to run any actions all I want to do is have the player walk towards it so I'm going to create a new user interaction but I'm going to leave the interaction field which actually dictates what actions are run blank but I will be setting the player action to walk to marker this warning message then appears saying we need a walk to marker defined and we can see our walk to marker field further up it's currently set to nothing so we get this handy create button I'll click on this and we now get marker Waterfront two steps and it's symbolized by this little green arrow here so I'll move this arrow say just a the bottom of this ramp and if I open up the steps cam and choose set as active you can see that it's now appearing in the view here so I'll move it maybe a little to the left like so and if I select the inter steps trigger you can see that the player is now going to walk into this trigger let's now run the scene I'll uncheck gizmos again and if I hover over the mouse you'll get this waterfront two steps label appear and if I click on it the player then walks over will want to make a few tweaks to this which we'll be covering next so we a portion of the screen that is defined by a hot spot and you can see the label waterfront two steps coming up and we're going to make this a little bit more user-friendly the waterfront two steps name is really an internal name that we use when building the scene and I could just rename the game object but I can also enter in a label if not named field so I'll just type in steps now I'll leave this as lowercase because I'm going to have a verb appear dynamically in front of this if I play the game again you can see the label now changes to steps but I want to have exit two steps appear instead I can make a verb appear by going up to our cursor manager and underneath interaction icons we have a list of three default verbs that we can make use of we have used talk to and look at and a little bit further up underneath hotspot cursor we have this check box prefix cursor labels and if I check that will then get use steps up here and it's set to use because that is what is set in our hotspot inspector the user interaction that we made has a cursor or icon field set to use and what we're going to do is create a new type of icon so coming out of play mode I'll go back to the cursor manager and you can see prefix cursor labels is still checked because any of the fields will be changing the managers survived play mode so I'm going to go down to interaction icons click on create new icon and I'll enter in the label as exit to we're not going to be changing the cursors graphic so I'll just leave the texture is empty but going back to the hotspot inspector I can now change the cursor icon field to exit too and now when we hover over the hot spot it correctly says exit two steps and let's also make it so that we can't click on this exit two steps hot spot from this screen and we can do that quite easily just by going to V the hot spot itself and setting the limit to camera field as water front cam so we're now able to have the player move from the waterfront to the steps and what we're going to do is complete the scene and have it so that the player can move all around now last time what we did is we had a hot spot to move us to this marker and then we used a trigger a to actually cut the camera and that's a more sort of best practice way because this allows us to cut the camera no matter what our movement method is so if for example I run the scene I go into my settings manager I can change my movement method to direct and using the cursor keys without clicking on the hotspot I'm still able to move over to the steps and the trigger is going to activate so by having both the hotspot and a trigger it just means that we can always ensure that the camera will change no matter how we actually entered that region but to keep things simple and because this is only going to be a point-and-click adventure game what I'm going to do is first of all set this back to point and click and then I'll remove this trigger now that we've demonstrated it and I'll make it so that the hotspot itself cuts the camera so selecting the Waterfront two steps hotspot we already have this use interaction and I'm going to complete it by now defining an interaction action list so I'll click on create and you can see it's made this steps exits too and if I select that field you'll see it then appears up in my hierarchy and we have a node icon next to it so let's click on it and that'll bring up the action list a window for it so just like the trigger we had it starts with a default engine weight action and what we're going to do is we're going to change it to a camera switch action in which the new camera again is steps so let's test that out and see how we're doing running the scene I can now click on exit two steps and he moves over and the camera changes but there was a little bit of a glitch in that the menu button that appears down here did flicker off and on while that happened and the reason that that happened is because if I select the steps exits to interaction and have a look at its inspector you can see that it's when running field is set to pause gameplay so even though this action runs instantaneously it still momentarily pauses gameplay it places the game in a cutscene mode so I'm going to change this to run in background and that'll just mean that the whole thing is seamless it doesn't come out of gameplay if I click on exit two steps that little UI element in the bottom corner doesn't flicker so let's now do the return journeys so that when we buy the steps we can go back to the waterfront now if I click on gizmos in my game window you can see that the hotspot that we already have is already pretty much the right shape that we need it to be for steps maybe I'll just stretch it out a little bit more so that it covers the whole screen and we're going to be using a different hotspot but we're going to have it occupied this same space so I'll just right-click and choose duplicate and rename this new hotspot steps to waterfront and in its hotspot inspector I'll change the label to waterfront the limit to camera I'll assign as step scan I'll unset this walk to marker and then create a new one and then selecting that I move it to around here just in front of ve the hot spot near the default player start now we've duplicated the hot spot but not the interaction so this use interaction is still step two steps exit two so I'll select it clear it with the Delete key choose create to make a new one and this time it's going to be another camera switch in which we switch to waterfront cam and again go into its properties I'll change the when running to run in background you can also access the properties of an action list from the bottom of the Action List editor let's just test this to see how we're doing disable gizmos and I click down here to go to the steps and I could do the same for the return journey how can I use the same principles to create hot spots for the other areas next I'll be doing from these steps up to the plaza so with my steps cam in the game window I'm going to go to my scene manager create a new hotspot this time I'll call it steps to plaza and putting gizmos back on our position and stretch out this new hotspot so that it covers the top of the steps I'll go to this inspector the label is going to be plaza because we wanted to say exit to Plaza I'm going to limit the camera to the steps I'll create a new walk to marker that by default will be placed in the center of the hotspot I'll just put it down in front of it like this going back to the hotspot I'll create a new use interaction the cursor icon is going to be exit to I'll make a new interaction and before I go and edit that interaction I'll set the player action to walk to marker and a quick shortcut to edit this interaction it's just to click on the node icon to the right of it so I can click on that again this will be cameras which cut into Plaza and I'll set it to running background let's do the return journey so I'll select my Plaza count choose set as active and you can see that this 2 is in the right space in fact I might just make it a little bit taller and then I'll duplicate this renaming it to Plaza 2 steps create a new marker position it limited to the plaza can change the label two steps unset the interaction and create a new one using a camera switch to cut back two steps running in the background and let's just test this next one because there is a little bit of a detail here so disabling gizmos once again we can go up to the plaza and back again but one thing to have a look at here is that aside from the floor which will be changing soon you can see that we could not also access this exit two steps hot spot while we're hovering over this corner of the wall here and we could just reduce the scale of the hot spots so that it doesn't overlap if I can enable gizmos it's a bit more clear but what we can also do is place down a Collider to basically block the mouse's ability to hover over that hotspot so what I'm going to do is create a new 3d object and then choose cube and I'm looking at the game window here as I'm positioning it I'm going to make it so that it lines up with the the corner here at the corner of the wall that is not the corner of the navmesh so this is going to block the mouse being able to hover over that hot spot and that's because it's also on the default layer which is what hotspots are also placed on I don't want to be able to see this so I'll disable the mesh renderer component and I also want to make sure it doesn't interfere with any physics or anything like that so I'll check is trigger then running the scene again I can I'll Exeter the steps come up here to the plaza and you can see when we hover over this portion of the screen we can exit the steps but when I hover over this wall here we can't that's a bit of housekeeping I'll rename this cube to say corner hot spot blocker and just move it to my set drama Chee folder maybe collapsing some of these as our hierarchy gets a bit bigger let's now move on to the last couple of camera transitions and that's to switch between the plaza and the office behind this view I'll make a new hotspot in my scene manager clicking on hotspot and I mean this Plaza to office we've gives Mo's enabled in my game window this might not be too physically accurate but I'll just do what looks nice according to the game window maybe something like this so it's right in the lower corner of the screen go to its inspector I'll change the label to office I'll walk to marker I'll create and just so that I can see where this marker exactly will take us to I'm going to go to my office Cal and then choose set as active and I can see it's coming a little bit too close to this pillar here so I'll just move it a little bit over here going back to this Plaza to office hotspot I'll limit this to the plaza can create an you use interaction exits to player action will be walk to marker create a new interaction edit it and this will be a camera switch setting the new camera to office cam and the winning will be running background I'll duplicate this hotspot for the return journey I'll rename it office to Plaza and I'll actually lower it a little bit it looks a bit better sort of put lower down in the corner from this view I'll rename this label to Plaza create a new walk to marker unset the interaction to make a new one having it switched back to Plaza cam in the background well I also do need to change the limits to camera to office cam so let's test this out this full journey I'll disable gizmos and run the scene and you see I can exit to the steps here come up to the plaza I can either go back all round the corner go all the way to the office back to the plaza down the steps and finally back to the waterfront up until now we've been working with this grid based floor material that we can actually see while we're running the game and it's quite a bit distracting because it's basically overlaying on top of these photographs and what we can do is assign a new material to this floor here and I've already got a material if I go to my set drama tree folder first of all and find this Wharf I'll go to the mesh renderer and where it says grid and select the grid material and then change it to matte shadow and you can see now we now get the nice shadow but nothing else so it's a lot nicer to look at I didn't write this shader this is coming from the unity forums and there's a link to it in the license text file in the root tutorial files folder now what we could do is change this change this material in our edit mode and then it's always made for us but it doesn't make it a little bit more difficult to work with because obviously if I deselect it you now can't see the floor in our scene so what I'm going to do instead is have this change made automatically when we begin the game so I'll change back to the grid material and then I'll create an on start cutscene which is going to be a cutscene that will run when this scene begins I can make one in my AC game editor and underneath scene cutscenes in the scene manager we've got a list of cutscenes that we can make and we have this one start field that is currently empty so next to it we have a create field I'll click on it and so we now have assigned this on start cutscene if I click on the mode icon for that you can see we're presented yet again with the default action and what I'm going to do this time is change it to an object change material action and the mesh renderer we're going to be effecting is going to be Wharf from our set drama she folder and the new material is going to be matte shadow and so this will kick in when we play the scene so but this all looks a bit nicer but when we come out of play mode we can still see our floor let's continue our little visual polishes by moving on to scene masks and I can demonstrate the need for this if I go up to say the plaza here and if we have the player walk behind this corner you can see they're still visible behind that section of the wall and that's because the background is just a single static photograph with no depth to it there are a couple of other instances of this namely this pillar here in the office background and also the the top of the steps when you get over this lip coming up from the steps camera if I go into the masks folder inside tutorial files Wharf set and then masks you can see we've got a few sprites that are basically these elements cut out for us the sprites are still the same size but we've just cropped out everything except the portion of the screen that we want to overlay on top of the player so for example with the corner here we have this corner mask sprite and what we're going to do is place it in 3d space so that it appears on top of the player when they're behind it if I go back to my scene manager under my list of scene prefabs inside the camera section we've got this scene sprite type so if I click on it and create a new one I'll name this one num corner mask and then going to its inspector we'll have a look at its components we've got a sprite renderer and alignment a camera component and a limited visibility component let's fill in these fields as we go so our sprite is going to be corner mask the align to camera field and the camera to align to is going to be the one we're viewing here which is plaza can and will also limit the visibility to that same camera Plaza cam if we have a look at it in the scene window and you can see it's now facing plaza count it's a bit far away but we'll change that later first I'm going to click on center to camera and what that does is it places the center of the sprite and again this whole sprite is the same size as the background it's going to Center the sprite in the center of the camera view and then we can increase the size so that it fits the game window properly about this kind of size looks right to me and what we're going to do is we're going to move it closer to the camera so that it sits within this corner here now we move it closer to the camera but we don't want it to appear any bigger in the game window so I'm going to check lock perceived scale and then reduce the distance from camera field and you can see it's not appearing any larger in our game window but we are now positioned correctly in 3d space and if we run the game we can test this out I can crop the steps and trying to move behind this corner here you can see the player is now correctly behind it but if we move down here he's then displayed above while the plaza cam is still active let's do the same with the steps mask two sprites which is a little bit harder to see but it's basically covering this area of the top of the steps here I'll do the same thing I'll make a new scene sprite this one called steps mask and I'll assign the sprite as steps mask to camera 2 line 2 is going to be plaza cam as well as the camera we're going to limit visibility to it's a bit far away it's all the way down by the waterfront now I'll click on Center to camera and then raise the scale it's about so check lock perceived scale and reduce the distance so that it appears just at the top of the lip of the stairs there is a steps mask to that you may or may not need depending on the placement of your hotspots but I think I've actually managed to do away with a need for that so I'll move on to pillar mask which is going to be viewed in the office cam so I'll select office cam and click set as active add a new seems flight I'll name this pillar mask and assigned pillar mask the sprite into my sprite field and office camp has both the camera to limit visibility to and the camera to align to now it's actually placed it in the center of the scene which is actually behind the camera so I'll quickly disable the align to camera component move it in front of the camera and then re-enable that component centered of the camera increase the scale lock the perceived scale and I want it to be positioned in the same space that we cut out from the navmesh so if I just open up the navigation window and keep it docked down here just so that we can see the navmesh at the same time I'm going to reduce the distance from the camera so that the pillar mask is inside that little hole bear now depending on your exact positioning you may find that the the corner mask that we placed down actually gets in the way of your camera here let me see if I can demonstrate yeah if it's just a little bit closer then it's going to be in peering in front of your camera but what you can do to combat that is actually just uncheck the sprite renderer in fact I'll do that for all three masks I'll just disable their renderers and that is because they already have the limit visibility component which means they will be enabled automatically when they're supposed to be so I can actually see in the scene window p.m. when we come up to the plaza this corner mask is enabled and it becomes disabled again once we leave to the office up to this point we've been making use of tin-pot who's the the 3d demo games player character but now it's time to make our own player character that suits the zoom a little bit better we can find a model for our player inside tutorial files Worf and then characters and then go and you can see we have this girl model file but I'll just drag into the scene if i zoom in on her you can see she doesn't have a material assigned but I can go into the materials folder and just drag the girl material onto her let's get rid of tin-pot now and we'll convert this model into a player character if I go up to adventure crater editors and then character wizard will then be presented with this pop-up window that allows us to quickly configure a model or a sprite in our scene into a character just like the new game wizard this is a case of choosing next and going through each field that we're given we'll choose that this is going to be a player and then assign the default graphic so this is going to be the girls model file choosing next how is our player going to be animated and we're going to be relying on Beckenham or unities animator system and I'll finish that and you can see that this model has been updated with an audio source component and a player and a paths component as well as some rigid body and Collider components some of these need a little bit of tweaking it's really just laying down the components they may not be final so I'll click on the Edit field for the collider and raise it up maybe make it a little bit thinner like so we have animations for this character inside the animations folder and all of these are taken from unities standard assets package so for example humanoid walk for a look at that and play that this is a root motion animation which means the animation is not just playing on the spot it's physically moving the character so we're going to want to make sure that apply root motion is checked in the animating component let's create a new animated controller so inside my my 2.5 D game folder I'll right click and choose create new animator controller and I'll name this human because I'm going to apply it to some other character later on going back to the girl I'll assign human as the controller and if I double click on it I'll open up the animator window this is going to be a fairly simple controller which is going to have three animations for now we're going to have idle walk and a run but we'll make use of a blend tree so that the three of those can blend more nicely together I'll right click in the window and choose create state from new blend tree and I'll name this blend tree locomotion double-click to open I'll select the splintery and I'll add three new motion fields now this is all using unities animator system so if you're not familiar with this do go and check the unity documentation I'll set the first motion field to humanoid idle which I can get by expanding this model file here the second has humanoid walk and the third as humanoid run if I play this I can then move this little red gizmo here to test it out but to drive it at run time we're going to need use of a float parameter so I'll go to the parameters tab and you can see it's automatically created a parameter for me but I'll rename this to move speed and the thresholds are automated so when move speed is equal to about 0.5 she's going to be playing humanoid walk and when it's all the way up to 1 she'll be playing humanoid run going back to the player component we'll go through our Meccan and parameters and these are basically parameters that we will allow AC to control and so this move speed float is going to be a parameter that AC will update as she walks around the scene by default it's just named speed but to match the parameter in our animator component I'll rename it move speed we don't have a talking animation so I'll remove is talking and the same for jump underneath movement settings we have fields for our walk and a run speed scales and so these are going to be the values of our move speed when walking and running now because we're using route motion as set in the animating opponent the actual motion speed of the character is going to be driven through animation so all we want to do is set the walk speed scale to 0.5 and the run speed scale to 1 which matches up to the threshold values in the blend tree running the scene now you can find that we are now controlling this girl instead of the robot and if I single click shall walk if I double click short run there is a little bit of a teething problem though if I say double click to go up to the plaza she does a little hop as she comes up the steps there and that's because we're using route motion so we're using motion to control the physics and not the rigidbody now we could do things like try to configure the animations y-value settings or increase the mass and so on but a quick and easy way is to simply remove the rigidbody and the capsule Collider and instead go to add component and add a character controller and this will mean that she's still is subject to gravity but she's not going to have jerky motion so much I set the height to about 2.8 and the y-value of the center to 1.4 and let's just test again and if I double click yeah she's got a bit smoother motion now finally we'll make her the default player which we can assign in the settings manager we have this player field that this player field accepts only a prefab so I'll drag the whole object into there my 2.5 D game folder Harlock to create an original prefab and then I'll drag this prefab into the player field and we can demonstrate the use of this by now removing the girl from the scene and when I play the game she's automatically spawned in at runtime let's move on to audio I'm going to be having my game on mute while I do this because I don't want it to interfere with my voice but if you have this unchecked then you should be able to hear the sounds as we make them the audio we're going to use is in tutorial files Worf and then audio and you can see we have a number of footstep sounds and a couple of ambient sounds we're going to start with adding some footstep sounds to the player there's a number of ways we can add sounds to a character's footsteps and I'm going to start with the most simple way inside the my 2.5 D game folder I'm going to edit the girl player prefab in 2018 point 3 you do this just by double-clicking otherwise you will have to drag her into the scene and apply changes afterwards so I have my girl prefab viewed and I'll go to the root game object and underneath my player you can see that we have an audio clip field for the walk sound as well as a run sound and also a sound child now the sign child was created automatically using the character wizard but if you don't have one it's basically just a child object of the route that has both an audio source and a sound component so the most simple way to assign a footstep sound to the player is to simply drag the sound click into the walk sound component and that'll just cause the player to play this sound whenever they're walking but there isn't going to be any variety to the sound it's just got to be the same sound looping over and over again and it's not going to synchronize with the animation so I'll undo this change and come out of prefab edit mode and one thing I do want to highlight at this point is that if I go back to my settings manager the player field has become unset and so far as I can tell this is actually an issue with unity itself so I'm just going to have to read dragged the girl prefab back into this player field now a slightly more involved way to add footstep sounds is to make use of the dedicated footstep sounds component and I'm going to add the footstep sounds component to the route objects so I'm editing the prefab again I'll scroll down to the bottom choose add component and add footstep sounds and you should be placing this on the same component as the animator for reasons we'll see in a moment but looking at its inspector you'll see we have a number of footstep sounds field and this is for walking sounds we have seven footstep sounds so I'll enter this value is seven and then we get fields for each sound so we then just need to drag each audio clip into the inspector and you can see from the message below that sounds will be chosen at random so the more sounds you add the more natural and further more variety you'll get as you walk around we don't have any running sounds so I'll just leave this as zero but we then need to assign both the character and the sound to play from the character is going to be this girl so I'll assign the same game object into the field and the sound to play from I'll set to the sound child and again this sound child is just a audio source and sound component as a child object of my route now we have this play sounds field that at the moment is set to via animation events and we could set this to automatically and that would just cause the footstep sounds to play whenever the character is walking you can set the separation time between these sounds but it wouldn't really sync up correctly with the footsteps themselves surprise the animation goes so what I'm going to do is I'm going to choose via animation events and then modify the animation to fire off those events you can see another message down here it says a sound will be played whenever this components play foot step function is run so let's go to the animation folder and I'll select humanoid walk and going to the animation tab we only have this humanoid walk animation to choose from I'll scroll two events pause it and then scrub through the timeline to get the right position I'm going to choose about about here frame two to four which is where the left foot just touches the ground I'll click on this little add event button and I'll set the function name to play footstep I'll scrub through to find the right foot roundabout here I'll add a new animation event play footstep again and neither of these functions take parameters so I'll just leave the rest of blank and click on apply I'll come out of prefab edit mode and again because we've made changes to our player prefab I'm going to have to reassign the girl prefab so if we now play the game if you were listening to this without mute on you'll be hearing audio clips as she walks around the scene the other two sounds we have in our audio folder our office and water and these are both ambient sounds so have them playing in the scene and we'll position them in 3d space so that they they change volume according to where we are in my scene manager I'll go down to logic and click on sound okay I make two of them and I'll name the first of them office and the second one water go into their inspectors I'll expand the audio source component and I'll set the spatial blend to 3d so there these are fully 3d sounds I'll make them effect a slightly wider distance and with the water this is going to come from the that the canal that you see in the waterfront so I'll place it and kind of around here and with the office there's going to be it further up the steps so I'll move it over to around here so the office is going to have the office audio clip and with the water object we'll assign the water clip I'll select both of these and I'll check play on a week and a loop for both and I'll just tweak the relative volumes between them because if we have a look at safe water we have quite a quiet volume whereas for office the amplitude is much bigger so what I'm going to do is I'm going to select the office sound object and just reduce the relative volume so that the two sounds have similar amplitudes in this sound component you can see we have a sound type and these are both already set to SFX which is what we want and these relate to the volume levels of our game so if I just run the game and I press escape or click on this menu button because we're using the default menu interface we get this options menu and here we can change the volume levels of speech music and sound effects so by using this sound component were able to automatically connect the volume levels now if I wanted to add some effects or anything like that to some of our sounds we'd want to make use of unities audio mixer system so while the sounds will play at the moment we might want to do some effects to them in the future so what I'm going to do is have these sounds playing via audio mixer groups if I go to the game editor and then the settings manager scrolling down to audio settings we have this volume controlled by field set to audio sources if I change this to audio mixer groups we now have quite a few new fields appear and we basically need mixers and attenuation parameters for each of the three sound types I'll go back to the my 2.5 D game folder right click and choose create audio mixer I'll name this master because all of our groups are going to be children of this double-clicking brings up the audio mixer window and then I'll create three new groups by clicking the plus icon next to groups I'll rename the first music the second speech and the third one SFX but I don't want these to be parented to one another so I'll just to make these all shared children of the master I can then drag these into the audio settings fields so speech music and SFX and then going on to these attenuation parameters this is basically how adventure creator controls the volume of each so we have this music volume parameter we need to define so with my music group selected I'm going to go to its inspector and right click on volume and choose expose volume of music to script I'll do the same for each of these and I can then rename these in the audio mixer window so my exposed paramah I'll change to music volume I changed the volume of SFX to sfx volume and the last two speech volume if I then play the scene move the audio mixer up to maybe over here you can see that we're now playing sound effects via that audio mixer group let's do something a little bit different now and go and add a stealth mechanic to our game now this is still going to be a traditional point-and-click adventure game we're only going to be able to make a very rudimentary system but inside the Worf characters and an animation folder you can see we have a humanoid Crouch model file and if we expand that we've got a number of crouching animations so let's make use of some of these I'll double click on my human animator controller to bring up the window and we still have our locomotion blinked reopen I'll go back to the base layer and I'll create a new blend tree I'll rename this blend tree crouching and in fact I'll go back to our original locomotion blend tree and rename that standing double clicking on this new blend tree and selecting the blend tree in the middle here I'll create another couple of motion fields the first of these are assign humanoid crouch idle and the second humanoid Crouch walk and again this is all tied to the move speed parameter but the move speed when walking is going to be about 0.5 which is a little bit slow here so what I'll do is uncheck automate thresholds and change the threshold for the walking animation 2.5 going back to the base layer I'm going to create a boolean parameter that determines which of these two blend trees are playing so I'll click on the plus icon create a new ball name this in stealth mode and then right-click choose make transition from standing to crouching and do the same thing for crouching to standing I'll select each of these in turn and change the condition to in stealth mode and for standing to transition to crouching we're going to have in stealth mode be true I'll uncheck exit time and for the crouching to standing transition again I'll uncheck has exit time and I'll create a new condition in which in stealth mode is now false and we can test this out so far by just running the game I'll select the girl again to bring up the animator window that's live I can just click on the in stealth mode checkbox and you can see she's now crowding around if I uncheck she'll go back to walking so let's add a means of toggling of the stealth mode by pressing a button on the keyboard we can have adventure creator respond to key presses by creating active inputs if I got to the top toolbar and choose adventure creator editors active inputs editor will then get the active inputs window I'll click on create new active input and I'll give this the name stealth the input button will be stealth mode and will have to define this and this button doesn't exist yet so let's make it now I can go up to edit project settings I'll dock the project settings window over here and then select on input if you are using unity 20 18.2 or earlier you can do the same thing by going to edit project settings and then input I'll expand the axes and create a new axis by increasing the size by one I'll not name this new input stealth mode which matches up with the input button in our active input list I'll set the button to tab and then close we have some more properties for our active input this is going to be a button it's enabled by default and it will be available when the game is normal and this refers to normal gameplay so it's not going to work during a cutscene we can define an action list when this is triggered by clicking on create and you can see we have active input stealth assigned in the field that's placed here in my project window I'll just drag it into the my 2.5 D game folder and if I double click on it we can get the Action List editor for this action list so this is going to run whenever we press the tab key now we can use the character animate action with his player checked to change the values of our parameters so we can use this to change the in stealth mode parameter but we need a way of determining what mode we're in so we're going to do that with a variable and if I go to the AC game editor and click on the variables tab you can see we have a section for global and for local I'll click on create new global variable and I'll name this is in stealth mode the type is going to match the parameter in the animator it's going to be a boolean and it's going to be false or unchecked by default go back to the action list editor let's change this action to a variable check action and you can see because we only have one variable to find this is already set up for us so it's going to be comparing is in stealth mode to the entered value we're going to be checking if it's true so if it is we're first of all going to set it to false so from this output socket and I'm choosing the top of these two because if it's true the condition will be met and then what we're going to do is set it to false and we can set it to false by changing the action type to variable set and you can see it's already done for us is in stealth mode is going to be set to false on the other hand if this variable check checks that the variable is set to false we're going to want to set it to true so I'm going to make another variable set action this time coming out of the is condition is not met socket and this time I'm going to set the statement to true and after both of these will then run a character animate action to update the animators parameter so starting with this chain here on the left I'm going to make a new action choose character animate we'll be animating the player and changing the parameter value of let's just make sure we get the name right in stealth mode so I'll type in stealth mode as the name of my parameter to affect the parameter type is a bull and the setters value will check so it will set the value to true we're going to do the opposite here so I'll just in fact copy this right click and choose paste copied action this time I'll uncheck setters value and connect that with the previous variable set we can now run the game and if I press the tab key she toggles between crouching and standing again you can see that the menu button is flickering on and off so I'll just go back to this action lists properties and set the wind running field to run in background a stealth mechanic isn't really complete until we actually have someone to hide from it's all gonna be hiding from an NPC we've got some graphics for him in tutorial files Worf characters and then guy I'll drop him into the scene and he also has his own material that I get from his materials folder and then just drag onto his model going to his inspector and finding his animator we're going to recycle the human animator controller we made so I'll click on controller and select human and that'll mean that he has access to the standing and crouching animation blend trees we already made as well as the parameters we defined again we can use the character wizard to convert him into an NPC so I'm going to go up to the top toolbar and choose editors character wizard choose next our base graphic is there's going to be a player or an NPC this is going to be an NPC the character's name is going to be this am Steve and we then just assign this model file from the hierarchy into the field it's guessing here that we're using mekin which is correct so I'll choose next again and finish and it's now been turned into an NPC again we need to tweak some of these components a little bit now he's got a capsule Collider that's a little bit wrong I could replace this with a character controller as we did the player but actually he's not going to be moving around so I'm not going to be too worried about that where we're going to put him is up along the plaza so I'm going to open the cameras game cameras folder select Plaza can and then click on set as active and on a place in around here so that he's not going to spot the player so long as they're crouching because of this wall in between them so I'm moving - around here a little bit lower down and then turn so he's facing the steps you can see that he's off the navmesh here we don't need him to be on the navmesh but because he has a rigid body I don't him to fall down to you to gravity so I'm just going to make a new plane by going to create 3d object plane I'll just move it so that it's underneath him maybe shrink it down a bit and there's a loss I mean that he gets a little bit of a shadow as well so maybe that's about right and then I'll set the mesh renderer of this plane I'll set the material to Matt shadow which is what we're also changing the the Worf floor here - I'll move his object into the NPC's folder and then throw his inspector we can see down at the bottom here he has a hotspot component which combined with his Collider makes him interactive now we're not going to add very much interactivity we'll just have it so that the player says something if we click on him so I'll create a new use interaction the cursor icon I'll set to look at the player action maybe just turn to face and then I'll click on create besides interaction to make a new one click on the node icon to edit it and this will just be a simple dialogue play speech action in which the player by checking player line is able to say I better keep out of his way let's test our progress and if I double-click to run up steps actually it seems he's a he's in the view of the steps here actually so let's come back into edit mode make the steps cam active and I'll select both him and his plane move it maybe just a little bit out of view how does that look from the view of the plaza again yeah we can still see him and I'll also just move this plane into the sector on which we folder and I'll just rename it to maybe NPC floor so again just running the scene to test it I can to the top of the steps here and I can hover over it says look at Steve and the girl says I'd better keep out of his way so let's do just that so we want the NPC to basically detect if the player is walking past him in his line of sight and we're going to cheat a little bit we're not going to actually physically check any kind of line of sight or anything like that we're just going to make use of a simple trigger in the AC game editor I'm going to go back to the scene manager once more and create a new trigger and I'll name this guard spotter and I'll place it up at the top of the steps here in fact I will enable gizmos just for a moment inside my game window stretch it out so that it covers the whole width of the walkable area and looks about right and then go into its inspector we want this to basically run all the time so I'm going to have the trigger type set to continuous and what it's going to be doing is checking the state of our variable but because it's going to be running all the time we don't want it to interrupt gameplay so I'm going to change the wind running field to run and background and let's say the player is around here at the bottom of the plaza and we click on the hot spot to go down the steps we want this to interrupt that so if the players walking over to the hot spot we're going to want the trigger to kick in so to do that whole check cancels interactions we can then start working on the actions themselves so opening up the action list editor I'm going to make this a variable check action in which again we're checking the state of the in stealth mode variable and if it's true which is what this condition is already set to we don't want anything to happen we only want something to happen if the condition is not met so if we are not in stealth mode and in this case we want game play to end we want to make a non interactive cutscene but this trigger itself is running in the background so we're going to run a new action list and we can do that by changing the if condition is not met field to run the cutscene it will then give us a cutscene to run field I'll click create to make a new one and I'll rename this cutscene guard sees player and you can see that this cutscene is set to pause gameplay so editing guard sees player I'm going to first of all stop the player from moving and that'll be with a character move a long path action in which the player has a move method of stop moving and will then have a character face objects action in which will get the player to face the NPC so I'll check effect player facing with her body and the object to face will be the guy NPC I'll check wait until finish and then it will have another dialogue play speech action and this time it's going to be the guard speaking so the speaker is going to be guard and his line text will be hold it right there and because we've sort of failed this little minigame we're going to place the player back down at the start so we're going to teleport the player and cut the camera so next we'll make a object teleport action will be teleporting the player and teleporting her back to the default player start so default player start copy the rotation of that player start and we'll also make another camera switch action in which the new camera is Waterfront can let's test this out now we can exit to the steps I'll run up to the plaza and before I do so I'll just press tab to go into stealth mode and here we are able to sneak around if I press tab again to come out of it the guard spots us and we're sent back to the beginning let's work on making a few improvements to our interface right now we're using the default adventure create interface which means that we have this menu button down the below left and if I hover over the top portion of the screen I can access the inventory since we're not using any inventory items in this tutorial I'll remove this and replace it with a button that allows us to toggle our stealth mode without having to press on the keyboard we can edit our interface by going to the menu manager in the AC game editor and at the bottom you can see we have a list of all of the menus that make up our interface and if I select for example inventory you can see it previewed in the game window further down we now have our properties for the inventory menu and you can see that its source is set to adventure creator alternatively we can render this with unity UI in which case we'll be relying on a UI canvas instead of this built-in rendering system I can prevent this inventory from showing by checking start game locked off now I'll create a new menu to house the toggle stealth button so I can click on create new menu I'll give it the name stealth mode I'll leave its source as adventure crater only for the moment going down I'll set its appear type to during gameplay and this will prevent it from showing whenever we're in a cutscene or the game is paused and you can see because we're previewing an adventure creator menu we've got this little yellow preview box here in the middle currently it's just an empty box because we don't have anything to display so from the list of elements I'm going to choose button and then add new and you can see this has now been updated to show our new button just like the menu we have a number of properties for this element I'm going to set the button text to toggle stealth mode and it's click type is set to run action list and what we're going to do is have it run the same action list the triggers whenever we press the tab key and that is active input underscore stealth I'm not worried too much about the design right now but let's just quickly test the scene and see what happens so we now have toggle stealth mode appearing and if I click on it then the player will do just that so let's make this look a little bit fancier and really this adventure creator source option is best used for prototyping and getting an interface up and running quickly for real fine-tuning over a menus display we're going to want to use unity UI so first of all I'm going to set this source option to unity UI prefab you can see the preview then disappears and we've replaced with linked canvas prefab and rect transform boundary fields here in the menus properties so we're going to create a new unity UI canvas and connect these up so that I don't interfere with anything else in my scene I'm going to do this from a new scene so I'll go to file new scene and then in my hierarchy I'm going to choose create UI button this has made a new canvas with a button inside I'll enable 2d viewing mode and if I double click on the button and come out of it we can see it's kind of below the camera so let me just place it up in the upper left corner now this isn't going to be a tutorial on working with the unity UI as such but I will make a few changes to make it fit in with the rest of the interface let's go to the buttons image component and make it say transparent black I'll go to the text component and make the text color white and change the font to chalk five and I'll enter the text as um toggle stealth finally I'll rename the canvas to stealth UI and because we're going to be spawning this in every scene we're going to make this a prefab so that adventure creator can do this automatically so I'll pick this and drag it into my mighty point-five decaying folder and then going back to the menu manager I can now assign this stealth UI prefab into my linked canvas prefab field we next have a rect transform boundary which is not really essential in this instance but it's important to set whenever we want to reposition the menu at runtime and this is essentially just a rect transform that spans the whole interactive area of the menu that is actually the button that takes up the same space and there's a couple of ways I can assign it now that we have unity 20 18.3 I can either assign it from a scene instance and you can see that this has updated with a recorded constant ID label here the number here is 6 6 to 8 but that'll be different for you but the important thing is that if we go back to the button you know I've seen it's been updated with a constant ID component with a value that matches the same thing and because we're working on a scene instance and not the prefab I just need to go back up to the root object and make sure that these changes are applied back to the prefab let's now assign the button and scrolling down to the button properties you can see that this has been changed also to provide a linked button field and to demonstrate a different way of doing this in unity 20 18 point 3 which has a new prefab system I can double click on the stealth UI prefab and assign the button from prefab mode coming out of that I'll load up my Worf scene and if we run it will now get our toggle stealth mode button up here and I can click on this to toggle crouching this tutorial by acting as though we were making a proper game here and at the ability to translate our game if we wanted to before can translate our game we need to ensure that all of the game's text is gathered up and record it and to do that we'll first have to include this scene in the build settings I can do this by going to file build settings and then clicking add open scenes to add this scene to the build I have a empty scene here so I'll just remove that and we can now gather up the text by going to the speech manager and scrolling down to the bottom we have a section for languages and we have original language here and we can create a new translation but we're getting this warning saying no text has been gathered for translations so that's exactly what I'm going to do underneath game text I'll click gather text will then be warned that we should probably back up our scene and so on beforehand I'm just going to assume that everything will be right I'll press ok and once the process has been completed we'll be told we've had some lines added and we can use these filter boxes to review them so right now we're looking at speech and the scene the filter if I just change it to any or no scene you can see that we've got the two lines of dialogue that we've already written we've got the text the scene and the speaker as well as information about any audio file that we'd have to create if we wanted to speech audio to be present in our game going back up to languages I could now click on create new translation for example I'll name this French and if I then go back down to this speech line you can see we now have a French translation box that we could either edit here or export this all into a CSV file and we can do that by going up to language number 1 French clicking on this cog icon to the right and choosing export that would then create a spreadsheet that we could then re-import back into this speech manager to update all of our French text at once another handy feature is that we can prevent the original language from showing at runtime so here we have the original language and I'll check don't use it run time and if I rename this French translation to say English this will still be a copy of our games original text but the actual text that we entered into for example our dialogue place speech actions will not be used so we can just edit all of our games text here in the speech manager so we're just about ready to wrap this up but one thing I want to just touch on is the save system and because we're using the default interface that means we can go to the pause menu here and we can use this to save and load our game so what I'll do is make this seem compatible with the save system and this basically comes down to flagging up different objects with the kind of data that need to be saved for example we want to save which of our cameras is active and we want to save the state of the players animator component because we're changing that when we toggle stealth mode now it is important to go through the manual and go through the saving chapter because there might be a few cases where you need to do it manually but for the most part we can automate this just by going up to the settings manager and underneath save game settings I can click on auto add save components to game objects and again will be asked to back up our project and make sure everything is saved I press ok and it will then go through and flag up all of the objects correctly or at least it should do so let's just test it out and maybe if I just move over here I'll open up the pause menu and save in slot 1 I get up halfway up the steps toggle stealth mode and save into slot 2 so if i load back into slot 1 you can see the player and the camera are correctly loading well that about wraps it up for this tutorial I hope people found it useful and thank you for watching