Project Description

Title:Unity 5 Tutorial : Making an RPG Game
Type: Unity rpg tutorial
Platform: Unity 5 Tutorial
Length: 25:54
Difficulty: Beginner (3/10)
Community Name: GameGrind

Learn how to create a very simple RPG in Unity 5.

In this unity tutorial we cover the concept, outlining the desired features for our game. We’ll be creating an ARPG-style movement system, a world full of intractable objects, NPCs with dialogue, enemies and attacking, an inventory system, portals, and maybe even a questing system.

More Video Tutorials on this RPG available in the series.

Download the low poly asset pack here: (coming soon)

Check out all the tutorials here on http://bigrookgames.com

If you would like to see any additional features in this series, please leave a comment below!

Unity rpg tutorial Transcript:

0:00hey guys welcome back this is part 2 in party we’re gonna work on the world interactions a bit more so that can click on objects and be able to differentiate between say NPCs and signposts and crates and things like that and the system we’re going to be using is pretty cool so I hope you enjoy how we’re approaching this here the first thing i want to do those on a create want to create a 3d on jags make a cube just want to call it npc is the placeholder something to play around with and test with right into place in what about here that’s fine that’s fine and then I also want to create duplicate npc and i’ll place it over here and I’ll scale it a bit differently something like this say it’s like a sword or something and just for testing purposes we’ll call it item like an item you can pick up and putting inventory we don’t have an immature yet so we can do that with it but we can try to tell the difference between these based on just what they are and not something like a switch statement or something silly like that we want something more modular remember so we’re going to work on something that we can extend very easily so what I want to do is I want to go to my scripts to create a new script can be subscript C subscript call it interactable interactable to class at all of our interactive classes and objects in the game will derive from so MPC that’s interactable object it will be interactable sword sword a sword it out in the world he can pick up is an interactive objects OB interactable hs2 signpost a crate to get the idea right there all interactable in the same way so they’re all going to derive from the same class and they all have their own actions their own implementation of interactable but they’ll all start with interactable and that’s what we need to set up first so it’s open up interactable yes you don’t break everything and with interactable we’re going to a couple of things first of all i get rid of this like starting blank and the methods that we’re going to use interactable at least the most of them that i can think of at the moment are going to be virtual methods which means a subclass a class that extends interactable methods within that can be override methods which means it will override the virtual methods and interactable just a solid way to make sure that it’s working the way we intended to work so i want to set up the public virtual voted not returning anything i’m gonna call it move to interaction and what this is going to do the kind of what the name says right it’s going to take our player agent it’s going to take the place it’s not interact with which will be the item that this interactable class is attached to in this case is going to move the player to the interactive object and then interact with an object because we can’t just interact with the object before we get there because we’ll be talking to the person across the map and that’ll feel weird kind of break the whole experience and make sure that our player gets there first and then he initiates the interaction then we are talking to and then pick up the sword so let’s do it that way so moved interaction first of all we’ll need a reference to the player agent right and we want this whole intractable class time reference of that so I want to set up a public nav mesh agent i’ll call it player agent like we did before and this move interaction will be passed a nav mesh agent from our world interaction class and I’ll show you that in a second when we do that so because player agent as well then i would say this dot player agent now that means this one that is on this instance of interactable so say interactable is on an npc well this means this version of player agent this instance of player agent on that MPC or on that item it’s not referring to this player agent referring to the player agent on this instance I wanted to be a player agent is to avoid the confusion here so that he knows all your setting the one that’s on this item the one that’s on this instance to the one we just passed it to move to interaction i get it makes sense so you notice that in World interaction when we click on an interactive object we’re not moving to the object around doing anything but if we don’t click on intractable object moving to the point that we clicked on but we also want to move to the intractable object if we click on an object so what i will do is inside of this inside of this condition i want to grab the interactive object that we clicked on and I want to grab a component from that and that component is going to be a component that is derived from interactable inner act interactable so we have npc right the class npc will derive from interactable which means it is it there’s an npc component on a pc it is still an interactive also i can still grab interactive interactable component which is a nice way to handle this whole 00 p thing in a component-based design because I can grab a component based on a base class which Oliver interactive objects will have it makes us really clean easy way to do this so interactable and they go through interactable and you’ll notice interactable has move to interaction i won’t do that and it’s going to say oh you need to pass it the player agents i’m going to grab player agent and pass it player agent so now when we click on an object is going to move to this is the idea is going to move to the interaction because in here we’re going to move our player agent to the object’s location on the ground player agent grab the destination once again and set it to be this jaunt transformed opposition which this is not necessary because it knows this instance I just want to clarify that at least in the code for me reading it that are referring to this position of this interactable alright that looks pretty good so it’s going to set that up in the game world i have my NPC but i want to create an npc class for quick that as I said derives from interactable someone go you see sharp script will call npc and what’s cool about this is if we have enemies that say they could derive from npc as they are npcs or they could derive Griffin Interactive’s but we probably derived them from pc and build on the npc class with our enemies like health and attacks attached to an npc be the same way to handle it so NP see what all of our derived classes will have that this doesn’t quite have it but it will is an interactive method right if I got interactable i’m going to set it up so you can see i’ll make a public virtual once again just gonna be overwritten avoid something called interact and then we’re going to say debug that long that is a cat trying to get in here to bother me at the moment hey hey now now i’m busy i don’t care go back in that if you’re going to be loud go back in there hey now ok so i want to write something to the console and this is going to be interacting with base class that way I know if this method is called that I’m not interacting with the npc I can tell them interacting with the base classes will be useful for debugging here in a second because NBC is going to have a public override which is going to say this method overrides the base class method by the same name to avoid make sure has the same name and the same return type very important do you want out now what are you doing go out oh ok and it was called interact and that’s all we need someone to debug log organs come on visual studio don’t do this to debug is doing to debug log and logout interacting with in pc just like that cool cool so now we can tell we’re not going to this one or this one  so when I moved to interaction once i  get there  what I would like to do is interact with  it right and this is not going to allow  us to  detective Lee if we’ve reached the  destination first this was interact when  i click on it but it’s the way we can  test it for now and the second will set  up the distance check and all that but  no i didn’t try this jerky here is we’re  not inheriting from on behavior when  hearing from interactable that was kind  of the whole point of all that and I  just completely missed it and this isn’t  working right  I don’t have telephones working to  restart can’t do this right now buddy  hey what do you want to go outside  he likes being in the side and we’ll  take him outside real quick let’s go  ahead and click Play and with play  clicked some areas not having to do that  I want to drag in pc onto my NPC so now  has NBC component which says looking for  a player agent it’s not need to hide  that in the inspector but this is also  keep in mind this is also interactable  rights as an interactive all type as  well the component does because you’re  inheriting from the inevitable class  which means the fact that I pass this  type right there is gonna grab that npc  component for us least that’s the idea  let’s test it and see what happens  nothing’s gonna happen as it doesn’t  have a tag on add tag was called  interactable rack double object just  like that might pc and Michael object  click Play and I can move it there  click right there and interactive npc  but doesn’t do that anywhere else i  click right it’s just the npc because  the MPC has an NBC component attached to  it  pretty cool and the same thing what  happened for item we would just create  the same system all we have to do now  though since we can inherit from  interactable a new folder is a discrete  a so-called pick up  I’m attached to item open this up is  going to hear from an intractable as  well and of course i’m going to reload  visual studio real quick but i’m going  to go into the stuff like I had it  before it can be a public over-ride  avoid interact and debug log keep  forgetting that no sense is jacked  interacting with item and just notice  the simple pattern that we have here  right  any item that we create it needs to be  interactive all it’s very easy to do by  just going from interactable interact  will be called whenever it’s clicked you  can handle it however you want to each  item can be different each object in  your world can be interacted with  differently cause different action to  happen and that’s why I wanted to create  this the series to know we’ve got some  stuff in a passive seem kind of complex  but this is this isn’t so much complex  as it is the proper way to handle things  and I wanted to kind of get a bit more  serious about the stuff we’re doing  right and i think this is a good place  to start with that because this is a  great pattern to follow when you’re  creating a game is going to have items  and objects in the world that you can  interact with and going to different  things and and monsters and other NPCs  that you can interact with a native  different things and it’s all important  that it’s organized in a way that you  can add more very easily and remove  stuff without everything breaking like I  could move pickup item and all that will  happen is I don’t have pick up items  anymore  nothing else breaks right that’s the  whole idea and it’s kind of exciting on  this so that i was sharing something  that you can build something good upon  pickup item i’ll have a two-item just  like that  click Play and just that easily click on  the item coupon is a tag so just not  that easily add the tag now just that  easily just that easily I can click on  this and they’ll say interacting with  the item and I can pc and I can still  walk just fine and nothing happens  everything is fine  item npc cool stuff you’ll notice though  if I’m in a game and I click on NBC  I want him to stop before he gets inside  the npc alright single to the item so we  can handle that is if we’re interacting  with an item we can change the stopping  distance if you’re not interacting with  say the ground we want to walk to where  we click we always start before we get  to be clicked but if you’re interacting  with an object in that way then we can  stop a bit before we get to where we’re  going and we can handle that I guess we  could do it in interactable and moved  interaction what i would do before the  destination is out a player agent  destiny starting position not stopping  distance is equal to let’s say like to F  let’s try that and that changes it for  all the interactive objects right it’s  not something that we have to go in and  change about things it’s just all of  them are now change so i click on the  item and I well let’s see about a player  you can see the stopping distance change  two doesn’t mean to enough though try  three  I figured that would be unity units but  maybe I want to do with the breaking  honestly it’s breaking and not be like  not breaking in half like the auto  breaking thing it’s not breaking before  it gets towards going  yes see how it slides as storms and I  could change that a bit already go to  like it moves anyway it’s only player i  won’t increase the angular speed to like  550 acceleration to like 35 and try that  out I could snap movement you know is it  now when i click on it it stops quiet  before it gets there  that’s fine like that  it depends on the acceleration has up to  the point where is actually more so the  M momentum has that work for now looks  pretty good and then because it does  have to work with other interactive  objects like the sign of the crates and  the way i would do that is a probably  create an actionable item write  something like crazy shark script and I  call action item we have pick up items  an action item an action item is going  to be something that other classes  derived from that want to say walk into  a portal and you click on the portal and  until that’s going to teleport you  somewhere else right it’s going to be an  action that the item performs or you  pull a lever that’s going to do  something open a door slide at I’ll  somewhere or you don’t know  click on something and break something  rights and it’s an action that is  performing want to make sure that a bit  it all works the same right and this  would be interactable and I do the  public virtual boy interact  and now the way i’m setting these all  these up right now you may be thinking  this seems kind of convoluted for what  you’re what you’re achieving but you  have to understand that this is pretty  much a foundation for you to build  things on so this is what you did you  would put your default action code right  this is the one you can override right  you can override the interact what  happens then  but you can also make every action and  in the game do something similar so if  every action of the game displays the  dialogue saying what it’s doing and you  could put that in here so every action  item in the game does that so if you  derive a leaver from this and then also  teleport system of some kind of portal  they will both have a dialogue that  tells and was doing even though you  didn’t put that in the portal code or in  the liver code and that’s the whole  point right this way every pick up adam  can have something that’s shared and  also something custom if you wanted to  make an object or a class for each  pickup by them  same goes for npc it’s pretty cool way  to handle it so this is going to just  going to debug log out something  interacting with base action item  and then on top of that what i would do  and i would probably have these  organized out the folders right I’m  gonna have a folder for action items in  a folder for nbc’s for pickup bottoms  whatever we’ll get to that point we have  that many but then inside this I would  create let’s say an action item of  signpost right open up signpost this  would extend action item and signposts  what it would do their act and this  would call the way it filled in for me  but it’s pretty nice example to show you  how you can handle this if you want to  do something differently  you can set it this way so your override  also cause the base interaction and the  way of saying you can add functionality  on top of something you don’t want to  rewrite what already happened alright so  this adds on top of this right here is  going to call this and then also call  whatever else you put it right so you  don’t have to just replace everything  you can use that and then add some stuff  on top of it and that’s pretty cool so  what I want to do though is I just want  to log out there interacting with a sign  pose interacting with signpost and each  signpost will have this attached to it  but we don’t have a good dialogue system  in place yet  that’s gonna be the next tutorial and a  signpost to show your dialogue and you  talked to a pc or sugar dialogue or you  pick up an item exaggerated dialogue  whatever you want it’s all as a selling  point you can do whatever you want  so now take signpost i will go into my  environment sign wouldn’t blank and I’d  probably think these something different  but this is fine just attach weight was  the that’s the base I’ll just attach it  to that one for now and these are using  mesh colliders which you could just  change you could make your own obviously  like a box Collider that encompasses the  whole thing but we’re just looking for  this is work fine and now if all is well  all is not well  oh it’s not a not tagged interactable  object like all is not well what’s going  on and i click on the signpost in  document base class  okay so mm interactive base class  oh it’s easy to override sorry he’s  override the interactable business in  order to override can override it with  my other class will be a bunch of what’s  going on  moments in the series because a bunch of  stuff happening but now this is  interacting signpost because we have the  chain of overrides right we have the  signpost overriding the action item  override which is how it works  override override virtual but if you  have a chain of override override can  override override and that’s fine but  override action item overrides the  interact and the virtual here and that’s  the base is the very first interact and  overriding it like i said if i wanted to  have stopped wanted to have this happen  as well as this happen I would just do  base dot  interact just like that and have both of  them will happen but if I interacting  with signpost groups and also  interacting with base action item so  it’s cool everything is working fine  we have the item interactions in place  now i have to do is make a few different  ones and make the actions for them like  what they do like a signpost set up a  dialogue the treasure chest would give  us items those all come whenever we have  those systems in place like the next  part we’re going to work on the dialogue  system so once you get that in place  then we can set up the npc to talk to us  said that the signpost to tell us some  stuff and someone will get the inventory  in place then we can have we can have oh  one thing i just noticed let us all this  is we’re not resetting our stopping  distance from african-american item so  we’re stopping way before we should so  to change that i’m going to world  interaction and if we’re just walking  i’m going to set stopping distance to be  0 which means it’ll stop on top of the  point where we go everything is working  fine so in the next part that we’re  going to want to set up the dialogue  system and will also set up the system  where it doesn’t do anything until we  get to the destination because at the  moment if I clear my log here and i  click the signpost interacts the  signpost from across the map and we  don’t want that we wanted to wait to get  there so do that in the next part as  well as a dialogue system guys thank you  for watching if you’re enjoying this  series  let me know in the comments below if you  have any questions from this video feel  free to ask me in the comments below my  name is austin and i will see you next  time

 

 

__________________________________________________________________________________________________________

Tags: Unity 3d tutorial, unity 3D tutorial, unity 5 engine, unity tutorial, unity rpg tutorial, unity 5 lighting, unity 5 basics, beginner, unity beginner tutorial, unity tutorial beginner, unity 5 beginner tutorial, unity tutorial 2016