My first unity game tutorial




















Calling all creators! Show us your latest Microgames in our December Showcase. Submit Now. I agree to the Rules and Conditions. Calling all beginners in Unity! Create, mod and submit your game to our "My First Game" Showcase to show your fellow creators your creativity in Unity.

My First Game: December Showcase. Flex your creative muscles and have fun with either creating your own WebGL game for the world to see or a Microgame our special tutorials available in the Unity Hub. Check out some previous entries and winners from our November Showcase if you need some inspiration. How to participate.

To join, either go to your game page and click the "Submit your game" button from the banner on the top, or click "Start submission" on this page to submit your WebGL game.

You can also choose a game you have already uploaded to your profile to enter. Make sure to follow these instructions to share your game directly from the Unity Editor to your game's page. Remember to name your game, include a cover image, and provide a short and fun description of your game. The deadline for submissions is December 31st, Mods are fun! How to improve your game. If you are using a Unity Microgame you can add additional Mods that are available in each of the Microgame tutorials.

Here are some examples of what you can use:. Add as many original and fun elements as you can to make your game stand out. Join us on Twitch. Join us after the end of the Showcase for a special stream on the Unity Twitch channel. Microsoft and Unity work closely together to ensure great platform support across the Microsoft stack.

Download the latest version of Unity and get yourself a two-button mouse with a clickable scroll wheel. You can see the differences between the versions at unity3d. Your code, not the Unity engine code, runs on Mono or the Microsoft. Unity lets you test your game in the IDE without having to perform any kind of export or build.

NET Framework 3. If you prefer, you can configure Visual Studio as your editor. To debug, you launch MonoDevelop from Unity. MonoDevelop has a plug-in that opens a connection back to the Unity debugger and issues commands to it after you Debug Attach to Process in MonoDevelop.

When you open Unity for the first time, you see the project dialog shown in Figure 2. Figure 2 The Unity Project Wizard. In the project dialog, you specify the name and location for your project 1. You can also import a package later. A package is a. Finally, you can choose either 2D or 3D 3. This list is populated from.

Anything you download from the Unity asset store also comes as a. As such, it will show up in this list once it exists on your system. You could just double-click on any. The default Unity window layout is shown in Figure 3. Figure 3 The Default Unity Window. Of important mention is the Game tab next to the Scene tab.

This tab activates when you click play and your game starts to run in this window. This is called play mode and it gives you a playground for testing your game, and even allows you to make live changes to the game by switching back to the Scene tab.

Be very careful here, though. Everything that runs in your game exists in a scene. You can have as many scenes as you want in a project. When you download third-party packages or even sample games from the asset store, you typically must look for the scene files in your project to open. A scene file is a single file that contains all sorts of metadata about the resources used in the project for the current scene and its properties. You can search for all the scenes in your project by clicking the icon indicated in Figure 4 and filtering on Scene.

Figure 4 Filtering Scenes in the Project. Notice, however, that in any new scene, Unity always creates a camera that has an Audio Listener component already on it. You point Unity to a folder structure and it opens the folder as a project. Projects contain Assets, Library, ProjectSettings, and Temp folders, but the only one that shows up in the interface is the Assets folder, which you can see in Figure 4. The Assets folder contains all your assets—art, code, audio; every single file you bring into your project goes here.

This is always the top-level folder in the Unity Editor. But make changes only in the Unity interface, never through the file system. The Library folder is the local cache for imported assets; it holds all metadata for assets. The Temp folder is used for temporary files from Mono and Unity during the build process. I want to stress the importance of making changes only through the Unity interface and not the file system directly.

This includes even simple copy and paste. Unity tracks metadata for your objects through the editor, so use the editor to make changes outside of a few fringe cases.

You can drag and drop from your file system into Unity, though; that works just fine. Virtually everything in your scene is a GameObject.

Think of System. Object in the. NET Framework. Almost all types derive from it. The same concept goes for GameObject. All of the objects shown in Figure 5 and many more derive from a GameObject. Figure 5 GameObjects in Unity. A GameObject is pretty simple as it pertains to the Inspector window. You can see in Figure 6 that an empty GameObject was added to the scene; note its properties in the Inspector. GameObjects by default have no visual properties except the widget Unity shows when you highlight the object.

Figure 6 A Simple GameObject. The Transform property is simply the position, rotation and scale of any GameObject. Unity uses the left-hand coordinate system, in which you think of the coordinates of your computer screen as X horizontal , Y vertical and Z depth, that is, coming in or going out of the screen. Position and Transform. Scale are both Vector3 objects.

You add functionality to GameObjects by adding Components. Everything you add is a Component and they all show up in the Inspector window. There are MeshRender and SpriteRender Components; Components for audio and camera functionality; physics-related Components colliders and rigidbodies , particle systems, path-finding systems, third-party custom Components, and more.

You use a script Component to assign code to an object. Components are what bring your GameObjects to life by adding functionality, akin to thedecorator pattern in software development, only much cooler. I renamed the cube Enemy and then created another to have two cubes.

You can see in Figure 7 I moved one cube about units away from the other, which you can do by using the move tool on the toolbar or the W key once an object is highlighted. Figure 7 Current Project with Two Cubes. The code is a simple class that finds a player and moves its owner toward it. You typically do movement operations via one of two approaches: Either you move an object to a new position every frame by changing its Transform. Position properties, or you apply a physics force to it and let Unity take care of the rest.

To assign this script to an object, I simply drag the script file from the project view to the object in the Scene view or the Hierarchy and the code is assigned to the object. Unity takes care of the rest.



0コメント

  • 1000 / 1000