Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
19. April 2015

 

Today we are going to take a look at the PlayCanvas HTML5 3D Game engine.  While not strictly a tutorial, this guide should give you a pretty good idea of what the PlayCanvas Engine includes,if it is right for you and give you enough information to get you started.

 

There is also a video version of this tutorial available here.

 

First off, what exactly is the PlayCanvas Engine?  Well, let’s let them describe it in their own words:

 

PlayCanvas is the world’s easiest to use WebGL Game Engine. It’s free, it’s open source and it’s backed by amazing developer tools.



The amazing developer tools part isn’t hyperbole either, PlayCanvas ships with an impressive amount of polished and high quality tools.  Where it does get a bit confusing is where the open source part stops, and the pay to use it part starts.  

 

Getting Started

 

There are three ways to develop with PlayCanvas.  Download and run the tools locally, use the online tools and code using a Github or Bitbucket repository or, as I am going to do in this example, work entirely in their online hosted IDE.  It’s not a bad way to work but sadly is missing a few features, like code autocompletion. I would probably work in WebStorm using a Github repository if working on a production project instead of just playing around.

 

To get started with the online hosted tools, you need to create an account then log in to PlayCanvas.  You actually have to create two accounts, first is your over all account, the second is a developer account.  This is because PlayCanvas supports multiple concurrent developers working on and editing the same project.  It is however a premium feature.

 

Let’s talk about that for a second… what is premium and what is not?  PlayCanvas want to make money obviously, so let’s look at the tiers.  First off, the game engine is open source and available on Github.  However, not all of the tools like the content importer are.  I haven’t downloaded the engine locally, so I am unsure how much of an impact this has.  What is clear is the different tiers available.  As of today, the pricing looks like the following:

Pc2

 

There is a second tier entirely for organizations as well.

 

In a nutshell, the number one biggest drawback is going to be 0 private projects in the free version.  If you are developing a free and open source game, this is a non issue, but obviously if you are creating a private commercial game, you will need to create a private project.  Basically this means anyone can see your project, source, resources, etc with the free version.  The remaining differences boil down to disk space availability, number of team member accounts you can create and being able to export an iOS ready project.  Prices range from 15 - 60$ a month.

 

Everything you see today is from the free edition.  Other than iOS functionality, all versions contain the same feature set.

 

The Editor

 So once you’ve logged in and created a developer account, you should see a screen like this one:

Pc3

 

You can either create a new project from scratch, or start with one of the starter kits.  We are going to use a starter kit.  This is a pre-configured mini project to get you going. There are currently two starter projects available, a 3D model viewer and a platformer.  Let’s go with the later kit.  Since this is a free account, we have no options but to make the project Public.

 

Pc4

 

You will now be brought to the project management page.  

Pc5

 

Click the editor button and you will be brought to the guts of PlayCanvas, where you will be doing the majority of your work.  Click this button:

Pc5 5

 

The Editor

 

There are actually two editors currently available, the classic editor and a new beta editor.  You can toggle between them by selecting the Settings gear icon and choosing Use New Editor:

Pc6

 

Here are the two different editors.

 

New Beta Editor

Pc7

 

Classic Editor

Pc8

 

For this post I am going to stick with the standard production editor.

 

The layout has your scene graph/tree on the left hand side, your palette of assets across the bottom, and your properties/components across the right.  In the middle of course is your 3D Scene view.  If you prefer, you can switch to a traditional quad view mode:

Pc9

Obviously in the 3D view you can zoom, orbit and pan the camera, select and edit objects, etc.  You compose a scene by dragging it in from the Pack Explorer.   In addition to the Packs Explorer you see here, there is also an assets and a scripts one as well.

 

Press the Play icon and your game should start.  Below is an embed of the project ( after Publish from the Dashboard ):

 

 

Click the mouse to focus, used arrow keys to navigate and spacebar to jump.

 

So that’s creating an initial project… now let’s take a look at the developer experience.

 

Importing a 3D Model

 

This is always one of the most challenging aspects of working with a 3D engine… getting your content in it.  PlayCanvas makes it pretty simple, but I did run into some small hiccups.

 

First author your 3D object in your modelling app of choice.  Personally I am using Blender.  They supports FBX, COLLADA and 3DS formats, although FBX is highly recommended.  There are a few limits as well.  You need to embed textures in with your model ( or manually add them later, as we will see ), you have a 256 bone and 64K vertices limit per mesh.

 

I am going to create a very simple textured cube in Blender, like so:

Pc10

 

And then export as an FBX using the following settings, the important ones highlighted:

Pc11

 

Now the we have an FBX, we need to import it to PlayCanvas.  Next in the dashboard, go to the assets section and click New Asset:

Pc12

 

Then simply drag the FBX file from finder/explorer to the appropriate spot.

Pc13

 

Now if you look at the palette portion of the editor ( hit the refresh button top right corner of panel ) you should now see your object.  Simply drag one into the scene:

Pc14

 

And tada:

Pc15

 

In my case however, the texture is always missing.  I’ve tried different formatting options, going through FBX exporter and never had any luck.  It is however easily fixed.  Instead import your texture as an asset.  Then in 3D view, click your object so it is selected, click again so Material is selected in the Material Editor, select diffuse and assign your texture:

Pc16

 

I have to assume this is a bug, either in Blender’s FBX import, or the PlayCanvas Import, but it’s extremely simply fixed by manually assigning the material so no big deal.

 

Now you will see your object renders properly in the scene:

Pc17

 

Components

Like most modern popular engines, PlayCanvas is component based.  Basically you add functionality to game entities by attaching components.  Let’s take a look at the main character and how it’s composed.  This can be seen by selecting the Player in the Pack Explorer then looking at the Attribute editor:

Pc18

 

As you can see out Player is composed of a rigidbody, collision and script component.  Additionally you can see it’s got a child entity named model.  Model in turn has a animation and model component attached.  It is through this parenting and composition you make the objects that composed your game.

 

Adding a component to an entity is as simple as right clicking it and choosing Add Component:

Pc20a

 

You can similarly add a New Entity the same way, but instead choosing New Entity.

 

Pc20

 

You can of course create your own components and entities as well, but that goes way beyond what I intend to cover here.  You may have noticed the script component attached to the Player…  that segues nicely to...

 

Coding

As you probably expected, the coding language behind PlayCanvas is JavaScript.  Scripts are attached to entities as a component.  Here for example is code for input in the Player from the platform example:

// Player Input
// Handle input from a keyboard
// Requires:
// - The entity must also have the platform_character_controller script attached

pc.script.create('player_input', function (context) {
    var PlayerInput = function (entity) {
        this.entity = entity;
    };
    
    PlayerInput.LEFT = "left";
    PlayerInput.RIGHT = "right";
    PlayerInput.JUMP = "jump";
    
    PlayerInput.prototype = {
        initialize: function () {
            // Create a pc.input.Controller instance to handle input
            context.controller = new pc.input.Controller(document);
                    
            // Register all keyboard input
            context.controller.registerKeys(PlayerInput.LEFT, [pc.input.KEY_A, pc.input.KEY_Q, pc.input.KEY_LEFT])
            context.controller.registerKeys(PlayerInput.RIGHT, [pc.input.KEY_D, pc.input.KEY_RIGHT])
            context.controller.registerKeys(PlayerInput.JUMP, [pc.input.KEY_W, pc.input.KEY_SPACE, pc.input.KEY_UP])
    
            // Retrieve and store the script instance for the character controller
            this.playerScript = this.entity.script.platform_character_controller;
        },
        
        // Check for left, right or jump and send move commands to the controller script 
        update: function (dt) {
            if ( context.controller.isPressed(PlayerInput.LEFT) ) {
                this.playerScript.moveLeft();
            } else if ( context.controller.isPressed(PlayerInput.RIGHT) ) {
                this.playerScript.moveRight();
            }
            
            if (context.controller.wasPressed(PlayerInput.JUMP)) {
                this.playerScript.jump();
            }
        }
    };

   return PlayerInput;
});

 

As you can see, the code is also very modular in nature as well.  It’s clean and fairly well documented, we will get to that shortly.

 

As I mentioned earlier, there are a couple of approaches to code editing.  You can host your code in a Bitbucket or Github respiratory, edit using your editor of choice then sync it back.  Otherwise you can use the built-in code editor.  Let’s take a look at it:

Pc21

 

It has some of the features you would expect.  There is syntax highlighting, code folding and warning hints.  What however there is not is code completion… that’s a glaring missing feature IMHO.  It’s been requested and hopefully will be added soon.

 

The API is clean enough, the editor works, although for a large scale project you will most certainly want to use your own editor, I would certainly.  Although if they added intellisense/code competition, I would spend a lot more time in the web based editor instead of my own IDE.

 

Documentation

This is an area that can make or break a project.  I will say that PlayCanvas has very solid documentation.  As you saw above, there are two starter projects to get you going, a Platformer and 3D model viewer.

 

The documentation is entirely online including a User Manual, Reference and Tutorials:

Pc22

 

The documentation is clean, professional and for the most part as shown what I needed when I needed it.  The User Manual covers common concepts like importing models, etc…  but could certainly use a bit more depth.  There is a pretty solid collection of tutorials available:

Pc23

 

All told, documentation is a definite plus of this project.  Some quick links if you want to check it out:

User Guide

API Reference

Tutorials

 

The Video Version

 

 

Conclusion

 

PlayCanvas is an impressive 3D engine for those looking to work in HTML5.  The tools are comprehensive, the documentation is quite good, the pricing structure is reasonable and the code seems clean.  Let me know if this is an engine you want to see additional coverage of here on gamefromscratch.com.

Programming


17. April 2015

 

If you are visiting GameFromScratch.com from a mobile device, you may notice some massive changes.  Now when you visit the site, instead of the ugly GFS you know and love, you instead are getting an even uglier GFS!  Here is the site rendered on my HTC One for example:

 

Gfs

 

I personally hate Hate HATE mobile sites, especially for sites like this one.  Code samples simply don’t look good on phones, and the full site looked just fine on my iPad.

 

However, Google disagrees and there is an algorithm change coming next week and if you like Google traffic, you can’t simply ignore it.  Your ranking is going to be tied to your mobile friendly-ness, and frankly, I wasn’t mobile friendly, not even close.  Today however I did mange to get the score up:

Mobileranking

 

So the good news is, my Google index won’t get worse… in fact, it should improve.

 

The bad news is:

a) the mobile site is a quick smash-up.  Only about 5% of traffic is mobile as it is and if you are like me you just request the desktop site anyways.  I do need to spend some more time making this more functional and less ugly.

b) GFS is written with a fixed 900px working area assumed.  This was a requirement for formatting screen shots and code samples.  On mobile, neither of these are going to look ideal

c) bugs… there are certain to be bugs.

 

So, if you run into problems with the change, please let me know.  If you like me hate mobile sites, I’m sorry…  Google tied my hands on this one.

 

In time however I really need to sit down for a week or two and redo GFS from top to bottom.  Make things a bit less ugly and more importantly, better organize all of the content that is buried in this site.  When I do this I can hopefully merge the mobile and desktop experience into a more cohesive single theme.

General


15. April 2015

 

In the previous tutorial we created a new project but didn’t really go anywhere with it.  Instead we were focusing more on learning our way around the Unreal Engine interface.  By the way, with each tutorial I assume you are familiar with the subject matter of the tutorial that came before it.  This tutorial and the previous one combined contain basically the same content as this video tutorial version.  So if you are jumping right in and completely new to Unreal, I would suggest you start there.  If you are confused about something, try the video instead and you might find some clarity…

 

…alright, back to the subject at hand.  Our very first application.  At this point you should have a new “Blank” project created.  If you haven’t got one, head back to the Epic launcher and create one now. We are going to create a very simple application, basically a sprite backdrop, a camera, a blueprint and the text Hello World.  We will not go into much detail on using Sprites, as that is one of the next topics I will cover in much greater detail.

 

Getting Started

 

First, let’s clear up our scene, we want to start completely from scratch, and the “Blank” project isn’t completely blank.  If you look at the Outliner, you will see that a few default objects have been created in our scene.

image

 

We want to SHIFT + Click select them all and then hit the Delete key.  Now we’ve got a completely empty scene.  Let’s put something in it!

 

Adding a Sprite backdrop

 

Now we need to add an image to our scene.  I will cover this process in a bit more detail later on, so if you’ve got some questions, don’t worry, we will probably get to it later.  Just follow along for now.

The first thing we need to do is add a texture to our game.  A texture is simply an image file, although there are a few caveats.  First off, Unreal Engine really prefers textures with an alpha channel.  This means jpg and gif files are very poor format choices.  Additionally, Unreal Engine wants your images to be “power of 2” dimensions.  It’s not a strict requirement but its heavily encouraged.  This means your width or height are 2,4,8,16,32,64,128,256… 2048,4096, etc… pixels in size.

 

The image I used I simply got from Google Image search.  I searched for Game background, set size to 1024x512 like so:

image

 

This is the image I chose at random.  Obviously I am not the owner and you have zero redistribution rights to this image.  Pick or use whatever image you wish, it really doesn’t matter in the end.

 

Now that we have our texture, we need to add it to the game.  Let’s be a bit organized about this and create a folder for our textures.  In the Content Browser, right click Game and select New Folder and name it Textures:

image

 

Your end result should look like:

image

 

Now from Explorer/Finder, simply drag your image on top of the Textures folder in the Content Browser.

It should immediately appear on the right hand side if everything went well:

image

 

Now that we have a Texture, let’s create a Sprite from it.  Again I will cover this later, but think of the difference between a Texture and Sprite as follows.  A Texture is the image file itself, contains the pixel information, etc…  The Sprite is an instance of your texture, or even part of your texture.  It contains positional information, etc… but all the image information comes from the texture.  You can have one texture with many sprites instanced from it.  More importantly, a sprite can be dragged into our scene and a texture cannot!

 

Let’s create a Sprite, it’s super simple.  Simply right click the texture on the right hand side of the Content Browser and select “Create Sprite”.  As you can see, right click menus in the Content Browser are context sensitive, knowing what type of files they are dealing with and presenting different options accordingly.

image

 

This will create a new sprite in the same directory:

image

 

Let’s stay tidy here and create another folder off Game called Sprites.  Then simply drag our newly created sprite to that folder and select Move Here.  This of course is purely optional.  If you want all your stuff in one big mess of a folder, that’s your prerogative!

4

 

Now finally we can create our sprite.  This is as simple as dragging one into the scene!

First lets make sure we are in Front camera perspective:

image

 

Now let’s drag the sprite to the origin.  For the record, this is the origin… the point where the X and Y axis meet:

image

 

You may need to pan the camera around a bit to locate it.  Keep in mind, you hold down the right mouse button to pan the camera.  Now simply drag your sprite from the sprite folder so it’s centered about the origin:

5

 

Well… that doesn’t look very sprite like, does it?  That’s because we are in wireframe mode.  In your view drop down the view menu and instead select Unlit ( or press Alt + 3 ):

image

 

Now your texture should appear in the scene:

image

 

We could actually run our “game” right now.  To run your game, hit the play icon.

image

 

The result will probably look something like a black screen.  You can hold down the right mouse button to rotate the view, eventually you will probably see:

image

 

Yeah…. that’s not what we want.  By the way, hit ESC when you are done playing to return to the editor mode.

 

The problem here is we don’t have a camera defined so when we start we aren’t looking at our background.  There are a couple options here and I will show both.  There is a third option ( the best one ), a Character Controller… we will cover that later on!

 

Now first the easy option.

 

You can set the perspective view.  This is where the view points if there is no camera defined.  Switch instead from Front view to Perspective View:

image

 

Using the camera controls (Right click to orbit, scroll mouse to zoom, middle mouse to pan ) center your image in the view.  With the background sprite selected you can also press f or Right click and choose Focus Selected

image

 

With the image displayed in your 3D View:

image

 

The next time you hit play, you should see the same angle:

image

 

That said, this is useful only for development purposes… in reality what you want is a camera…

 

Creating a Camera

 

So, let’s create one, it’s stupidly easy!

 

First we need to find the Camera object.  In the Modes panel in Place mode, simply type Camera, then drag the resulting object on to the 3D view, somewhere near the origin.  ( I switched back to Front view before doing this, btw )

6

 

With the camera dragged onto the view, now position it somewhat around the origin like so:

image

 

Remember, you can move an object by selecting it, then hitting the W key.  You could also have modified it using the Transform settings in the Details panel:

image

 

Now switch to Top View ( Alt + J )

 

We now want to Rotate and Move our camera so its facing the X axis ( where our sprite is ) and out a little bit.  Remember you can move using W key and rotate using E.  We want it placed something like this:

image

 

You’ll notice as you move the camera, there is a preview window of what the camera currently sees.  Please note, as of right now, this preview only works when the camera is in perspective mode!  I assume this is a bug and will hopefully be fixed in the future.  For a 2D game you would generally switch it to Orthographic ( see below ), but until this bug is fixed, for development it’s often easier to work in perspective mode.


Different Camera Types
If you look at the Camera Settings in the Details panel you will notice there are two different settings for Projection, Perspective and Orthographic.  Which one you choose has a major impact on the options available and the way the camera performs.
image
 
Perspective Camera – the role of a camera is to project a 3D scene into 2D and there is a catch involved.  You see, as things get farther away from us they appear to get smaller.  Obviously though, this is an illusion, that BMW Z3 racing straight at you at 100mph is obviously not changing in size as it gets closer!  A perspective camera however models this behavior, as things get further way they are rendered smaller.  When creating a perspective camera you provide a field of view and an aspect ratio.  The field of view represents the number of degrees to the arc of what is visible to the camera.  The aspect ratio is the ratio of pixels of width to height.
Orthographic Camera – the orthographic camera renders things the same way regardless to their depth within the scene.  Instead of providing a field of view, you instead provide the width of the rectangle the camera should capture.  Generally an orthographic camera is used for 2D games, where you are mostly ignoring the depth component when rendering.

 

Now when we press play things must certainly work, right?  Well… no, not quite.  This is because our camera isn’t set as active.  For this we are going to create our first blueprint.

 

Creating a Blueprint

 

Now let’s create our first Blueprint, a very simple one that is going to set our camera as the active camera.


What is Blueprint?

It used to be that gameplay logic was scripted in UnrealScript while the engine was written and extended in C++.  Then in Unreal Engine 3 a new visual scripting language, Kismet was added.  In Unreal Engine 4, Kismet has been extended and renamed Blueprint while UnrealScript has been taken out to pasture and shot.  At the same time through much magic, C++ has been enabled as a scripting language.
So what exactly is Blueprint?  Well it’s a graph based scripting language where you program by connecting a variety of nodes together in a visual manner.   You drag events, functions, branches etc onto the canvas then connect them together to create programs. Impressively a Blueprint can inherit from a C++ class, and a C++ class can inherit from a Blueprint.  It’s a different way of programming, and certainly a boon for visual thinkers, but it can also be a bit messy for the more code focused developer. 

First we need to create a Blueprint for our level.  This fortunately is very simple, simply drop down the Blueprint menu in the menu bar and select Open Level Blueprint.  The level blueprint is a special blueprint that is available across the entire level.  Every level has a level blueprint, even if its empty.  Ok, let’s edit the level blueprint:

image

 

This will now open up the Blueprint code editor:

image

 

This is a free floating window used to create new blueprints.  As you can see, the over all look and feel is very similar to main Unreal Engine.  The Palette on the right contains a common list of node types that can be dragged onto the surface.  The My Blueprint window on the left has context sensetive information about your blueprint.  In many ways it is similar in functionality to the Details panel in the main interface.  The Event Graph is where you create your actual blueprint.

 

First thing we are going to need something to fire an event to get the ball rolling.  There are a number of events available, these are things that happen that can be responded to in your blueprint, like Tick ( called each frame ).  In our case however, we simply want to run our code when the game starts.  In this case we want to run our code just once when the level is loaded and ready.  The event we want is the Event Begin Play node.  You may notice its in the Palette on the right.  Simply locate the Event Begin Play node and drag it onto the the graph:

7

 

In addition to dragging the node from the Palette, you can also simply right quick and do a quick search for the node by typing it’s name like so:

8

 

In the long run, especially if you are a coder, you will probably find yourself using the second approach far more often…  both have the exact same result.

 

Ok, we now have an event to work with… let’s do something with it.  What we want to do is set the view to our active camera.  This is done with a function called “Set View Target with Blend”.  This is created the same way as shown above, with a small catch.  Simply right click the graph and type Set View and it should show in the list.  However, by default Blueprints try to guess the context you are working in to streamline the search results.  In this case however, we do not want it to do that!  Make sure the Context Sensitive checkbox is not checked, or it will not appear in the results:

image

 

Left click the Set View Target with Blend function and it will be added to the graph.

image

 

Looking at the left hand side of the function you can see that it takes a number of incoming connections, you can think of these like function parameters, although they are often completely optional.  If you hover over the connector you can see the type it expects:

 

image

 

Here you can see that it takes a parameter called Target of type object.  It also takes another parameter called New View Target, also of type object.  Basically these are the new target to use ( our camera ) and the object to update ( our view controller ).  So now we need both of them!

 

First off, lets bring in a reference to our camera.  Go back to the main Unreal Editor and make sure that your camera is selected in the Scene Outliner:

image

 

With the camera selected, right click the graph in the Blueprint editor and the option Add a Reference to CameraActor8 should be available.  This is a quick shortcut to add a reference to the selected scene object.

image

 

Now we want to get the Player Controller.  This is a special class within the game, there is always at least one.  We will actually cover this class in a bit more detail shortly when we create our own.  For now just realize it’s this class that controls the active camera.

image

 

Now our graph should look something like this:

image

 

It’s probably important to note at this point, you can arrange things however you wish on the graph.  Simply left click and drag a node to relocate it.  You can also use the scroll wheel to zoom in and out in the blueprint editor.

 

It’s also worth noting that Nodes are colour coded and these colours have a meaning.  A red node is a starting point for execution of an event.  A Green node is generally a function that “gets” something.  A blue node is a function or event ( if it’s a function there is an F in the top left corner ) that takes input and may or may not have output.

 

So at this stage we now have an event that is going to fire when the game starts playing, we have a function we want to call that sets the view of the selected object, and we have two object references, our camera and our player controller.  Everything we need, now we just have to wire them up!

 

You may notice that the Event Begin Play node has a white play icon on it’s left.  This means that this node executes something.  You may then notice that the Set View Target with Blend has the same icon on it’s left and right.  The left icon indicates that it can be executed, while the right one means it can execute something else.  Connecting these nodes together is how you make your program do something.

 

At the same time you may notice the Get Player Controller and CameraActor8 nodes both have a blue return value connector on their right hand side.  If you are a programmer, you can think of this as the return value from that node.  As mentioned earlier, the Set View Target with Blend function has a number of connectors down the left, these are the inputs it accepts.  As you can see, they are nicely colour coded, so you can see (by default) what works with what.  Now its simply a matter of wiring everything up.  Simple drag the click and drag between pins you wish to connect like so:

9

 

When you make a new Blueprint, or make changes to an existing one, you have to compile, you can tell by the ? mark over the compile button:

image

 

Assumiing everything went ok, you should now see:

image

 

If you want to test the program flow of your new Blueprint, you can hit the Simulate button and you can see how data will be changed as the program executes.

 

Hit the simulate button:

image

 

And you should see:

10

 

Obviously in much more complicated workflows, this simulation is much more useful.

 

Now when we run out game, our camera will be set active when the game starts.  Congratulations, you just created your first blueprint!

 

Click Play and you should see:

image

 

Adding the Hello to Hello World

 

We are almost to the end.  One final thing we need to finish our application is well… Hello World.

 

Adding text to Unreal is extremely easy.  In the Modes panel, enter “text” in the search field and select Text Render:

image

 

Drag one into your scene.  Then in the details, set the Text to Hello World, like so:

image

 

Your scene should now look something like this:

image

 

Now when you run it:

image

 

Congratulations!  We have now finished our first ever Unreal Engine application!

 

There is one last very important thing to discuss before we finish here.  When you added the Hello World text to your game, there is a very good possibility that it didn’t show up when you press play.  This is because of the drawing order in your 2D game.  While 2D games don’t have depth, they do have drawing order and this is important to determine what is drawn on top of what.  In this case the Hello World text needs to be closer to the camera than the background, or the background will be drawn over top of it.  It’s probably easiest to understand this if we look at the scene in 3D:

image

In practical terms, this means that things that need to be drawn over other things need to have a higher value on the Y axis.  In this case our background image is drawn at y=0, while the Hello World text is drawn at Y=70.

Which way is up?

This is an important and difficult to understand concept about Unreal engine, especially when working in 2D.  You are probably used to X being left/right and Y being up/down, but that isn’t the way it works in Unreal, and that is because Unreal is a 3D engine and chose a Z-up coordinate system.  This means that Z represents up and down on your screen, and Y represents depth or in/out if you could put your hand into the screen.  Different applications use different coordinate systems and converting between them is common place.  Often it’s simply a matter or rotating things 90 degrees.

 

Conclusion

 

We covered a fair bit there, I hope that was useful.  We however did not cover Character Controllers, and the reality is, you generally will create a character controller which controls the camera.  We also didn’t cover game modes, we will be covering both of these topics shortly!  So while we didn’t do anything “wrong” in this example, keep in mind you generally will do things slightly differently in the end.

 

Finally, if when you press play you are seeing a circle drawn in front of your scene, don’t worry, this is the default pawn being drawn, another topic we will discuss shortly, and something that is easily removed.

Programming


14. April 2015

 

If you look over at the side bar you may notice a “Become my patron on Patreon” banner.  In case you’ve never heard of it, Patreon is a service that enables people to fund the efforts of content producers, such as GameFromScratch.com.

 

Over the years I have had a number of requests from readers looking for ways to donate to help support GameFromScratch.com (which was awesome by the way!), however I never really had a mechanism to do so.  It was with the birth of my daughter that I started to try turning GameFromScratch into a full time job.  The response has been amazing, GFS currently receives over a 1/4 million views per month and after only a couple months creating videos for YouTube, we passed the 1k subscriber mark and are approaching the 100,000 minutes watched per month milestone and are growing rapidly.  The community response has been nothing short of amazing and for that I thank you all.  The sheer volume of positive comments and emails I receive from many of you are simply inspiring and incredibly appreciated.

 

From a financial point of view however, I would probably be better off flipping burgers at McDonalds.  I don’t really bemoan this fact.  I am doing something I love and have the flexibility to focus on being a father while doing it, the definition of win/win.  Earning money has never really been a major focus for me, perhaps to my wife’s chagrin! ;)  Obviously there are ads running on Gamefromscratch, something I hope the majority of you don’t find too offensive.  These certainly help and defer server and operating costs but are nowhere near enough to approach what I would receive as a salary “with a real job”.

 

I had intended to supplement my income writing books.  After completing and publishing my first book, the well received but poorly selling PlayStation Mobile Development Cookbook, this idea quickly went away.  I’ve talked to a number of technical book authors since and let me just say, nobody is making their living this way!  I have flirted with the idea of self publishing a book, and may still, but truth of the matter is any other project I work on like this takes directly away from time I spend developing content for GFS.  Of course, finally creating and publishing a game of my own is certainly another option, but truth of the matter is, I vastly prefer teaching others… I appear to have found my calling in life.

 

In the end I am essentially developing multiple books worth of content on GameFromScratch every year as it is.  For example, I once converted the Blender tutorial series to iBook format and it weighed in at over 300 pages and I only made it 80% of the way!  The LibGDX tutorial series already exceeds the contents of any book on the market, by a large margin.  On the other hand, a book cannot contain animations, properly formatted and colour highlighted code samples, downloadable files or video format versions.  There is no comment section to answer questions or for the community to discuss topics.  Taking time away from GameFromScratch to work on a book that is in an inferior format, not available to everyone, has less functionality and cannot be updated… this doesn’t seem like a very logical use of time, does it?

 

Enter Patreon and it might be the perfect fit.  Patreon enables you to pledge a monthly dollar amount (starting at 1$ USD I believe) to help support the work of artists and writers you want to support.  This pledge amount would greatly exceed average royalties I would earn from writing another book and of course far more people would benefit from the results.  I personally like to believe that as a whole GameFromScratch provides more value than most book purchases.

 

It is customary to offer sponsor rewards on Patreon and this is an area I am struggling with.  The single biggest reward I can offer is first off my thanks.  The most tangible reward is more of my time dedicated to create more and better content for GameFromScratch.  These rewards of course benefit everyone, not just backers.  There are other options, like removing ads or walling off exclusive content or source code access.  Removing ads isn’t generally that effective as the majority of people that dislike ads already run adblock software.  I hate disruptive ads, like landing pages, interstitial or audio ads, the really annoying stuff, so I try to keep them non intrusive to start with.  I don’t really like the idea of exclusive content either, I obviously want my work to help as many people as possible as much as possible.

 

There are a few reward ideas I have considered, such as making PDF versions of long tutorial series available to backers.  Another option would be to open up the future direction of GameFromScratch.com’s content to voting.  As it stands right now, I decide what to work on next based on community requests coupled with what I find new, shiny and exciting at the time (part of why I love this job so much!).  I could possibly make this process democratic, to let backers vote on what contet GFS should focus on.  As of right now there are no rewards, other than my gratitude and of course more time focused on GameFromScratch!

 

So that’s my spiel.  I just want to say in closing, that each and every one of you supports GameFromScratch.com simply by visiting.  Your time, support, tweets, links and comments are all deeply appreciated by me.  If however you want to help GameFromScratch thrive and grow going forward, please consider becoming a Patron.

 

My Thanks,

Mike

GameFromScratch.com

General News


12. April 2015

 

A video only version of this tutorial is available here.Untitled 7

 

In this part of the Unreal vs Unity Tutorial Series, we are going to take an introductory look at Unreal Engine.  A bit of a guide tour of the interface as you will need to understand it to make 2D games.  I assume at this point you’ve downloaded and installed Unreal Engine already.  If not, go do so!  It is now completely free, but you will have to register before downloading.

 

Once you’ve finished the install, you will have one icon to deal with, Epic Game Launcher.

image

 

Click this.

 

The Launcher

 

This will load up the Launcher, like so:

image

 

There are currently three tabs across the top, one for Unreal Engine, then one each for the in development games Unreal Tournament and Fortnite.  Generally what you want is the Unreal Engine Tab and simply click the Launch button.  However it is also a good idea to look through the Learn tab to see the wealth of learning materials available for Unreal.  ( this tab is selected in the image above ).  The Marketplace is another great place to browse, full of free and paid assets you can drop into your game, including models, animations, blueprints, sample levels and tutorials.

 

For now though, click Launch.  Don’t be surprised if you have to download an update, there are frequent updates.

 

Once you click Launch, the following dialog should appear:

image

 

If you want Unreal to auto reload the project you are currently working on, instead of this dialog, be sure to tick the “Always load last project on startup” dialog.

 

In our case though, we are going to create a simple project today, although the details are probably going to be in a second post to keep things from getting too long.  Click the “New Project” tab.  Then fill it in like follows:

image

If you want to change the location, you need to click the drop down arrow icon at the bottom right to get additional options.

 

In this dialog you can start from a number of different templates, using either Blueprints or C++.  Templates include starter projects such as FPS, Flying game, Racing Game, etc.  In our case though, we want to start from scratch, so we chose Blank.  Additionally there is a bunch of content to get you started.  We however do not want it right now.  You can easily import it after the fact if you prefer.

 

Once you click “Create Project” the Unreal editor itself should finally load.

 

Unreal Editor

 

Welcome to Unreal Engine!  This is where you are going to spend a great deal of your game development life going forward, so let’s take a quick tour.

 

First, lets start with a shot of the entire editor, then we will break it down into sections.

image

 

Unreal is one of those applications that absolutely eats screen space.  It also supports multiple Windows and you will often have several editors open at once.  This is one of those applications that justifies your extremely expensive, ultra-wide monitor setup!  If you haven’t discovered the joy of multiple monitor development, you really need to!

 

Let’s break the screen down into easy to digest pieces.

 

Modes Panel

 

image

For a 2D game, this is a panel you are rarely going to use.  The tabs across the top are Place, Paint, Landscape, Foliage and Geometry Editing.

 

The last four are almost all entirely used for 3D games and we will be ignoring them.  Place however is used for placing game assets in your game, and we will be using it.  You can quickly add new objects using the Search Classes dialog, like so:

1

 

Once the item you want to place is selected, you can simply drag it into your scene.

 

The Content Browser panel

 

image

 

The Content Browser is critically important.  This is how you get assets into your game.  All the various files that go into making your game, such as models, textures, etc… can be drag/dropped into the right side of the Window.

 

2

 

The left hand folder hierarchy can be organized however you like.  Collections are a way of keeping similar things together.  You can also easily create new content by clicking New or Right clicking:

image

 

Now, remember earlier when we unchecked Include Starter Content?  Well, let’s say you want something that included with the engine itself?  Well fortunately that’s quite simple.

image

Selecct View Options, then check Show Engine Content. 

Now you will see an additional folder in the Content Browser:

image

 

You can then copy this content into your engine and turn it back off again if you wish.

 

The final, and perhaps most important feature of the Content Browser, are the right click context menu when you click game assets, such as the image we dragged in earlier:

image

 

These menus are context sensitive to the type of file you’ve clicked.  As you can see from this being an image file, the top half of the menu is populated with the Texture Actions menu.  Choosing Edit for example, brings up the Texture Editor window:

image

 

Basically the Content Browser is where you add, manage and edit game related assets.

 

The Toolbar

 

image

Across the top of your screen you have the convenient toolbar.  Most of the buttons are self explanatory, but a couple deserve further mention.  Buttons with drop down arrows have additional options, like you can see with the expanded Play button above.  Play runs your game, either in the current viewport, in a new window, as a stand alone game or in the mobile simulator.  Launch on the other hand is used for running your game on an actual device, such as an iPad.  Blueprints and World Settings are very handy, but we will cover both in more depth shortly, so stay tuned.

 

Scene Outliner

 

image

 

This is your scene graph.  This is where you create actual instances of your game assets to put together a level.  Think about it this way…  imagine playing with a set of Lego to build a world.  The individual different lego pieces… the big flat green thing, the 4 post bricks, the 2 post bricks, etc…  this are you building blocks and would be the analog of stuff that appears in the Content Browser.  The actual individual pieces, those that you use to build your house or whatever… those are what would appear in the Outliner.  The minute you drag an item from the Content Browser into the scene, it will appear in this list (technically tree).

 

As you can see from the screenshot above, there are a number of options for selecting each instance, editing it’s code, modifying it’s visibility, etc.  You can of course remove items from the level using this interface as well.

 

The Details Panel

 

image

 

Going hand in hand with the Outliner, the Details panel enables you to edit the individual properties of each object instance in your game world.  It is completely context sensitive, as you can see in the screenshot above, these are the details with the Lightsource selected in the outliner.  All of the editable attributes of each component that makes up the selected object can be edited here.

 

The Viewport

 

And finally… the biggest one for last, the Viewport.

image

 

This is the 3D representation of your scene.  You can drag objects from the Content Browser to the viewport to add them to the scene ( they will also appear in the Outliner ).  You can select, move, rotate and scale objects.  Speaking of moving, rotating and scaling, those can also be controlled using these buttons:

image

 

You can also use the W, E and R keys respectively.  ESC to unselect.  Use the left mouse button to select an object.

 

Here are translation, rotation and scaling in effect.  As you can see, each axis is represented and colour coded in the widget:

3

 

A quick note on scene camera controls.  In Perspective mode you can freely move the camera around.  The controls are as follows:

 

Zoom in/out : Scroll wheel or ALT + RMB

Orbit Camera: Hold RMB + move

Pan Camera: MMB + Move

 

 

There are a number of very important menus for the viewport controls.  The first is the one that lets you switch between the different predefined views, or the free form perspective mode:

image

 

Clicking the drop down arrow at the top left corner contains a series of very important configuration menus, including the ability to change the layout:

image

 

If you prefer the traditional quad view like 3D Studio MAX, you can click the icon in the top right corner to toggle between a quad and single view mode, like so:

image

 

Finally, you will often want to switch visibility modes.  Sometimes you want your scene textured and lit.  Often in 2D you want it textured and unlit.  In a large scene, or working behind something else, wireframe is often handy.  They can all be toggled with this menu:

image

As you can see, the majority of those settings also have a quick Alt + # hotkey available as well.

 

Conclusion

 

So, that is a basic guided tour of the Unreal Engine tools.  In the next text tutorial, we are going to create a simple Hello World scene with a sprite, camera and even a blueprint controlling it all.

Programming


GFS On YouTube

See More Tutorials on DevGa.me!

Month List