Unity Tutorial How To Make Simple Puzzle Game For Android | Educational Game For Kids

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video I will show you how to create a simple puzzle game for kids where a player has to drag and drop a picture into a correct slot so if direct picture goes to correct position then it stays at that place otherwise it returns to its initial position here is our new empty project let's begin first I add a background sprite and reset its transform next game object will be a bear I set its order and lair to 5 so it will be rendered in front of the background next game object is bear place which represents a place where our bear should be dropped order an layer for this game object will be 3 so it will be render it in front of the background and behind the bear now let's position our bear about at the left bottom center by a place will be at the top right corner like so to detect finger touch our animal game objects need a Collider so let's add a box Collider 2d component to the bear also to control our animals we will use C sharp scripts bear script will be used for bear let's take a look at this script first here we have a reference to bear place game object that will hold the position of that place next variable is initial position to which our bear will return if it isn't dropped at the right place next two variables are Delta X and Delta Y we need these variables to calculate and offset between the center of bear game object and touch position without this offset our bear game object will jump to words touch position if we touch this bear a bit far away from its center next variable is boolean locked that will become true when our bear is dropped at correct place in start method we mark bear's initial position and then the rest of the magic happens in update method so if input touch count is greater than 0 which means that we touch the screen with the finger and if our bear is not locked already then we initialize and design touch variable that will hold information about this particular touch event using this touch variable we get a position of our touch then in switch statement we go through some possible touch phases so if current touch phase equals to begin which means that we just touch the screen then we check if bear game objects box Collider or this position of our touch which means that we actually touched the bear then we calculate an offset between touch position and the center of bear game object to use this offset later on for more accurate and smooth dragging if touch face equals to moved which means that we are moving the finger by the screen then we set bear game object position to be equal to current - position depending on that offset finally if touch face equals to end it which means that finger is released then we check where it happens if it happens at the moment when center of the bear game object is located near enough within 0.5 units from the center of bear place position then we set bear position to be equal to bear place position and also we set locked to true so we will not be able to move our bear anymore because we found the correct place for it already and else if the center of the bear is not located within 0.5 units area then it goes back to its initial position to have a chance to find his correct place one more time that's the script drag and drop this grip to bear game object select bear and drag and drop bear place game object into corresponding slot of bear script component okay next game objects will be a koala and koala place order a layer for koala will be five order a layer for koala place will be three let's position our koala at the bottom center koala place will be positioned at the top left corner koala also will have a box Collider 2d and it will be controlled with the script named koala this grip is exactly the same as the bear script with the only difference that here we use koala place variable to determine correct position for our koala to drag and drop to the rest of the code is absolutely the same drag and drop koala script - koala game object select koala and drag and drop koala place game object into corresponding slot of koala script component there we go now let's add our last animal and its place it is a hair hair is behind the background changing its order on layer 2 5 will solve this issue and here is a hair place orang layer will be through position our hair at the bottom right corner hair place will be at the top center as well as our other animals the hair will have a box Collider 2d component and it will be controlled by the script named hair I'm sure that you've got already that this script has the similar code with the two other scripts the difference is in the hair place variable here and here drag and drop the script to hair select hair and drag and drop hair place game object into corresponding slot of hair script component okay almost done now let's create wind sign that will appear when the puzzle is completed create new UI text and once a canvas is created set its scale mode to scale with screen size now let's get back to our text game object double-click it to focus on it here it is I rename it as wind text and modify its text field so it will show you inside I like chunk 5 font family so I will use it in this project make font size bigger set alignment change font color make text container bigger so text becomes visible and position it about here there we go ok final step is to create new empty game object that will control our game a bit create new empty and rename it as game control this game object will have a script named game control which is pretty simple here we have wind text reference which will be assigned an inspector to turn wind text on and off in start method it's set to an active state and becomes invisible in update method which check if locked variables of bear koala and hare scripts are set to true as you remember we set them to true when an animal is dropped in correct slot for the reason to be accessible from game control script locked variable has public static properties so when all of these variables are set to true then it's obvious that the puzzle is completed and we can turn win sign on setting win text game object to active state that's the script drag and drop the script to game control select game control and drag and drop win text game object into corresponding slot of game control script component that's it game is ready now we can create an apk file and test our game on Android device this is how it works on mind hope this tutorial was useful for you thank you for watching see you next time you
Info
Channel: Alexander Zotov
Views: 84,344
Rating: undefined out of 5
Keywords: alexander zotov, unity tutorial, make unity game, Unity Tutorial How To Make Simple Puzzle Game, Unity Tutorial How To Make Simple Puzzle Game For Android, unity tutorial how to make educational game for kids, unity make game for kids, unity puzzle game, unity simple game, unity simple puzzle game, how to make simple puzzle game unity, unity simple game tutorial, unity simple tutorial, unity puzzle, unity puzzle tutorial, unity puzzle game tutorial, unity puzzle game project
Id: 7HEjCEncezs
Channel Id: undefined
Length: 7min 5sec (425 seconds)
Published: Wed Oct 17 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.