How to create a 2. D platformer for Android in Unity. My wife playing the simple platformer. She immediately worked out how to break it. Unity is a 2. D and 3. D game engine as well as an IDE and builder tool that makes it possible to make professional caliber games with very little in the way of programming knowledge. Many of the most popular games on the Play Store were made in Unity, including Tomb Raider: GO, Angry Birds and more. So it may come as a surprise just how easy it is to get started with. Often it’s as simple as dragging and dropping various elements around the screen. This guide will show you how to make a 2. D platformer and you should be able to create something basic in a couple of hours. To learn more about why Unity is great, check out my introduction to Unity post. This will also help you to get set up, but to recap: you need to download Unity 5 itself, Visual Studio for your coding and the Android SDK which will come in handy at the end. You also need to sign up for a free account. Getting started. Once you’ve downloaded and installed Unity and Visual Studio, you’ll be able to launch the software and select . You’ll also be able to decide here if you want your project to be 3. D or 2. D. For the purposes of this particular guide, you’ll select . The first thing you’re going to need is the . There was an old, unused test Drupal instance that was sitting on the server unpatched, with a couple of PHP scripts sitting in the files directory, including one that was meant to send outgoing mail. I've removed the test. Free Platformer Game Sprites For SaleThis is where you can see all the folders containing your various files. Now right click in that folder and select . You’re going to call this new folder . Can you guess what it’s going to contain? For this first version of the game, I’ve created two sprites: . You can use mine by right clicking and saving, or you can create your own (I won’t be offended. Once you’ve created your . It’s then a matter of dragging them into your . This is where you can arrange all your individual elements in a level. Free 2D ninja character sprites for side-scrolling adventure & platformer game. Sally.EXE - The Game is finally here! Following the success of it's spiritual predecessor, the fanmade follow-up to the legendary Sonic.EXE creepypasta is now brought to life. Browse hundreds of royalty free game art packages, made specifically for apps. Find character art, level art, platform art and more. Free Platformer Game Sprites PhotoshopKenney produces games and game assets, based in Europe (Netherlands). We have ranked the best sites for free sprites and game graphics to help you get your game art ready for your next project. This course shows you step by step process of building an attractive yet simple menu for your 2d mobile game using Unity - Free Course. This is a stylistically general, complete collection of platformer characters, enemies and vehicles on OGA. I've been through the entire archive and I keep it up to date day to day, but if you see anything I've missed please. A complete tutorial explaining how to create a very basic 2D platform game for Android with touch-screen controls in Unity. You can also drag things around the screen or scroll the page by holding . Pinch or use your scroll wheel to zoom in and out. You can also use the . It’s not terribly fun at this point. This will present you with some information in another window called the . This tells you the attributes pertaining to that particular game object (like the size and angle) and lets us tweak them to our heart’s desire. First, you need to choose . This should create a thin green highlight around your ground tile. This will set where the collision detection will begin and end for that object. If you had a more detailed object then you could select . My player sprite is essentially a rectangle, which is going to make life nice and easy for me. I also chose a sprite that faces forward so I can get away without animating him. At this point, our two objects are now . To change that, select your main character and choose . Click play and you’ll see the character drop out of the air and land on the ground. It’s still not that fun but it’s starting to resemble a game. To do this we’re going to try our first bit of code. Don’t worry, it’s pretty easy at this point. First, create a new folder in Assets and call it . Now in this directory, right click and select . You will be presented with a screen like this one: Coding in C# isn’t worlds apart from coding in Java for those who are familiar with it. You will still need to end every line with a semi colon and you still use curly brackets for your . Anything that happens inside Start will deploy as soon as the related object gets created (for our purposes, this will be when the level/game starts). The Update function meanwhile runs continuously and anything you put in here will happen continuously each time the scene refreshes. See also: Java tutorial for beginners. If you’re willing to learn some basic C# then you can start doing all manner of fancy things with your game. But otherwise, you can get by just as easily by borrowing code from other people – either by looking online or by using the . Some of this is free, some of it you will have to pay for. A surprising number of things don’t require any scripting at all either. In this case, you can use the code I’ve created to add very simple controls to your character: public class Controls : Mono. Behaviour . We’re also creating a reference to the Rigid. Body. 2D that we added to our character and calling that rb. You’ll be able to set the value for your public variables using the inspector for the game object to which the script is attached. In the . Basically, we’re telling the physics attached to our player that it now has some momentum heading either left or right. Now all you need to do is to head back to Unity and drag the . This is something you’ll need to do a lot – and you’ll find its very easy to forget! Don’t forget to change movespeed to . Now when you hit play, you’ll be able to control the character left and right with the arrow keys. We’ll be adding touch input later on. A little polish. Now I’m going to make a few more small changes. First, I’m going to drag my platform from the left corner to the right to make it much wider. I purposefully designed a sprite here that wouldn’t look . You can also do this by selecting the resize tool along the top left of the interface, or by changing the scale in the Inspector. Choices. Next, I’m going to take my camera in the left . Essentially, this means that the camera will now move when the character moves. I’ve also dropped my camera right into the center of the player by clicking on it in the scene view and then selecting the move tool in the top left. This now allows us to walk past the right of the screen without losing sight of the character. When you create a real game, you’ll want to give your camera more complex controls to enhance the gameplay. For now though, this will suffice. Right now, if you walk off the edge of the platform the character will spin out of control and the camera will spin with them! This makes for a rather nauseous experience, so click on your player character and then tick . Now Rushdy will fall without spinning around – like a normal platform character. Rushdy is a weird enough thing to begin with; he doesn’t need any more quirks for the other game characters to tease him about. The only difference is that I’ve set the scale (in the Inspector) to 1. This means that it will be drawn behind the other elements on the screen. I’ve also set the . This means that the background will now appear further away than the foreground and thus move more slowly as we scroll. Thus we have depth. Adding touch controls. This hardly qualifies as a game at this point, but we now have a little character that can move around the screen, which is more than enough to impress our Mums. The next step then is to install this on our Android devices – but before we can do that we need to add some touch- screen controls.(For those wondering. When you do this, you’ll create a new image and at the same time you’ll create a . Anything that you want to act as a UI element needs to be a child of your canvas. Select your new image and use the button in the top left of the inspector to anchor it to the bottom right of the screen. Now copy and paste that image and anchor the new one to the bottom left. I’ve created an arrow sprite too which I dragged and dropped into the . I used the same arrow image for both but set the scale to . You can check this by clicking play to see how it looks. We’re also going to add both of these arrows to an additional . Anchor this object to the bottom and click . Now drag your two arrows into here. I called my container . Don’t worry if it takes a little fiddling around to get everything right. By the end, it should all look something like this: Next we’re going to add two new public booleans (true or false variables) to our Controls script called moveright and moveleft. Then add this snippet of code to the Update function: if (moveright). Now, every time the scene refreshes our character will move left or right accordingly so long as the relevant boolean is . We have to do it this way because we can only detect the buttons going down or being released – we can’t check if they’re currently being held. Your code should look like this: Next up, we’re creating another new script in our scripts folder and calling it . Don’t worry, we’re nearly there! Unity. Engine. using System. Collections. public class Touch : Mono. Behaviour. . We have created functions to set these as true/false and now we just have to map them to our controls. Drag the . Now select your right button and in the inspector go to . Create two event triggers by selecting . These represent the images being clicked and released respectively. Next drag and drop the Touch. Controller container (not the script) into the box that says . You can now choose a function by select . This will then run the code you added to that function and edit your moveright and moveleft booleans accordingly. Do the same thing for the left arrow. Now if everything works correctly, then you can run the game and you should be able to control the character by either clicking on the on- screen controls or using the keyboard! Whew! Now all that is left is for us to create an APK. This will automatically save the scene in your Assets folder but for the sake of organization you may want to also create a . When you have multiple scenes, the one at the top will be the one that shows first when you load your app (so this will eventually be a menu or a title screen). You’ll also need to select your platform here, which will be . This is where you can create your private key sign and package name (. You’ll also need to show Unity where your Android SDK is located, which you do by going to . Make sure when choosing the API Level that you have the correct Android Platform installed. Click . And you can also find the APK there if you don’t want to make it yourself. Then you can have hours of fun moving left and right against a star- filled sky. We could always claim this is an artistic indie game? It’s not hard though to imagine the few extra elements this would need to become a fun experience.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |