Unity 5 Vs. Unreal Engine 4. The next major tutorial project on GameFromScratch.com

29. March 2015

 

I’ve been trying to decide what major project to embark on here at Gamefromscratch.com.  All of the current tutorial series are at a stage that I feel they are “good enough” to get anyone started and I will keep adding to them over time.  Once I reach that point I need to decide on what project to work on next.  It’s both a fun and frustrating problem to have!

 

I’ve been thinking about it long and hard, then recently there were some major announcements I simply couldn’t afford to ingore.  First the folks over at Unreal announced that Unreal Engine would no longer have a monthly subscription.  This is actually something I called for ( with a fair bit of hyperbole… ) when Unreal Engine 4 was released.  Immediately after, and with much thunder stolen, Unity made a very similar announcement.  These lowered barriers of entry vastly increased the appeal of both engines.

 

I’ve long intended to cover both engines in more detail.  I immediately subscribed to Unreal 4 on it’s release and did a bit of an overview post.  I never got the opportunity to get much deeper, as frankly, there is a pretty steep learning curve attached and I simply didn’t have the time.  Way back when I launched this game I was intending to “create a game from scratch” using Unity.  Somewhere along the way I got distracted and we ended up with a series of LibGDX, Phaser, Blender, HTML, C++, JavaScript and more game development tutorials.  Oops.

 

So, basically I’ve always intended to cover both for the longest time, but which one should I cover first?

 

I struggled with this for a long time, going back and forth between the two so many times I got nowhere.  Then I had a thought…

 

Lot’s of you have got to be asking “What should I use, Unity or Unreal?”.  It’s a fair and difficult question, as I obviously can’t decide myself!  So I am going to learn both and document the process, both in text and video.  So essentially I am going to do a Unity and Unreal tutorial series at the same time, learning both and documenting the process in both video and text form as I go.

 

Untitled 7

 

That all said…  this thread title and the above image are both a bit on the sensational side.  I am not actually comparing the two engines, there will never be a “Unity is greater than Unreal” or vice versa conclusion.  Both engines are obviously quite viable, popular and each has it’s own strengths and weakness.  Determining which engine is better than the other engine all comes down to your own preferences and requirements.  At this point arguing which engine is better is about as useful as the endless programming language wars.

 

Instead I will be going the process of creating a typical 2D game ( at least initially, 2D only ) in each game engine, documenting the process as thoroughly as possible.  So by the time I am done I should have a fairly comprehensive tutorial series covering creating a 2D game in each engine, and you should have a nice side by side comparison of how each engine works, which should aid in your selection process.

 

I intend to cover subjects such as the following, for each engine, in both video and text tutorial form:

  • Engine overview
  • Learning resources
  • Simple graphics
  • Game loop/Event processing
  • Input
  • Audio
  • Animation
  • Level composition
  • Collisions
  • Physics
  • AI
  • Networking ( maybe )
  • etc…

 

So basically all the pieces that go in to making a simple game.  I will learn it in one engine, document the process, learn it in the other engine, document the process then continue on to the next item in the list.  Obviously if there is something you think I should cover, let me know and I’ll do my best.

 

There are a few caveats of course…  first, this might take a very long time.  I’ve a lot of learning to do here, so there might be a bit of lag between posts.  The biggest catch though is I’ll be documenting things I’ve only just learned!  Expect some mistakes, inefficiencies and other hiccups as I go.  Obviously as I go I will try to be as “right” as possible, but I am no subject matter expert here!  I have a small bit of experience with both engines and tons of experience with game programming in general, but I don’t for a second claim to be an expert with either technology!

 

One other aspect of a game project like this is obviously game assets.  For a programmer, often getting art assets is as much of a time sink as programming!  Therefore I am going to be implementing this project in parallel with another very interesting art tutorial over at 2dgameartforprogrammers to create and release all of the assets to create a game called BotBox.

 

So, essentially I am going to attempt to create that game using both the Unity and Unreal game engines.  Wish me luck and I hope you enjoy it!

 

Of course, any and all feedback highly appreciated.  Please have patience with me… this might take a while!

Programming, News, General , ,




Phaser HTML5 Game Dev Library release version 2.3

29. March 2015

 

The popular HTML5 library Phaser have just released 2.3.  It’s not a huge new functionality release, but it’s got some major architecture changes that will affect you greatly if you are a Phaser user.  First off, they went down a more modular approach leading to fewer god classes.  This is aPhaser 2.3.0 good thing™.  Then thanks to this redesign, they also made the Phaser build process different, allow you to disuse unneeded portions.

 

From the release notes:

 

Significant Updates

 

GAME OBJECTS AND COMPONENTS

All of the core Game Objects have received an important internal restructuring. We have moved all of the common functions to a new set of Component classes. They cover functionality such as 'Crop', 'Physics Body', 'InCamera' and more. You can find the source code to each component in the src/gameobjects/components folder of the repo.

All of the Game Object classes have been restructured to use the new component approach. This puts an end to the "God classes" structure we had before and removes literally hundreds of lines of duplicate code. It also allowed us to add features to Game Objects; for example Bitmap Text objects are now full-class citizens with regard to physics capabilities.

Although this was a big internal shift from an API point of view not much changed - you still access the same methods and properties in the same way as before. Phaser is just a lot leaner under the hood now.

It's worth mentioning that from a JavaScript perspective components are mixins applied to the core game objects when Phaser is instantiated. They are not added at run-time or are dynamic (they never get removed from an object once added for example). Please understand that this is by design.

You can create your own custom Phaser classes, with your own set of active components by copying any of the pre-existing Game Objects and modifying them.

 

CUSTOM BUILDS

As a result of the shift to components we went through the entire source base and optimised everything we could. Redundant paths were removed, debug flags removed and new stub classes and hooks were created. What this means is that it's now easier than ever to "disable" parts of Phaser and build your own custom version.

We have always included a couple of extra custom builds with Phaser. For example a build without P2 Physics included. But now you can strip out lots of additional features you may not require, saving hundreds of KB from your build file in the process. Don't use any Sound in your game? Then you can now exclude the entire sound system. Don't need Keyboard support? That can be stripped out too.

As a result of this work the minimum build size of Phaser is now just 83KB (minified and gzipped).

Please see this tutorial on how to create custom builds.

 

ARCADE PHYSICS

We've updated the core of Arcade Physics in a number of significant ways.

First we've dropped lots of internal private vars and moved to using non-cached local vars. Array lengths are no longer cached and we've implemented physicsType properties on Game Objects to speed-up the core World collideHandler. All of these small changes have lead to a nice improvement in speed as a result, and also allows us to now offer things like physics enabled BitmapText objects.

More importantly we're now using a spacial pre-sort for all Sprite vs. Group and Group vs. Group collisions. You can define the direction the sort will prioritize via the new sortDirection property. By default it is set to Phaser.Physics.Arcade.LEFT_RIGHT. For example if you are making a horizontally scrolling game, where the player starts on the left of the world and moves to the right, then this sort order will allow the physics system to quickly eliminate any objects to the right of the player bounds. This cuts down on the sheer volume of actual collision checks needing to be made. In a densely populated level it can improve the fps rate dramatically.

There are 3 other directions available (RIGHT_LEFT, TOP_BOTTOM and BOTTOM_TOP) and which one you need will depend on your game type. If you were making a vertically scrolling shoot-em-up then you'd pick BOTTOM_TOP so it sorts all objects above and can bail out quickly. There is also SORT_NONE if you would like to pre-sort the Groups yourself or disable this feature.

Another handy feature is that you can switch the sortDirection at run-time with no loss of performance. Just make sure you do it before running any collision checks. So if you had a large 8-way scrolling world you could set the sortDirection to match the direction the player was moving in and adjust it in real-time, getting the benefits as you go. My thanks to Aaron Lahman for inspiring this update.

 

PHASER.LOADER

The Phaser.Loader has been updated to support parallel downloads which is now enabled by default (you can toggle it via the Loader.enableParallel flag) as well as adding future extensibility points with a pack/file unified filelist and an inflight queue.

There are no known incompatibilities with the previous Loader. Be aware that with parallel downloading enabled the order of the Loader events may vary (as can be seen in the "Load Events" example).

The parallel file concurrency limit is available in Loader.maxParallelDownloads and is set to 4 by default. Under simulated slower network connections parallel loading was a good bit faster than sequential loading. Even under a direct localhost connection parallel loading was never slower, but benefited most when loading many small assets (large assets are more limited by bandwidth); both results are fairly expected.

The Loader now supports synchronization points. An asset marked as a synchronization point must be loaded (or fail to load) before any subsequent assets can be loaded. This is enabled by using the withSyncPoint and addSyncPoint methods. Packs ('packfile' files) and Scripts ('script' files) are treated as synchronization points by default. This allows parallel downloads in general while allowing synchronization of select resources if required (packs, and potentially other assets in the future, can load-around synchronization points if they are written to delay final 'loading').

Additional error handling / guards have been added, and the reported error message has been made more consistent. Invalid XML (when loading) no longer throws an exception but fails the particular file/asset that was being loaded.

Some public methods/properties have been marked as protected, but no (except in case of a should-have-been-private-method) public-facing interfaces have been removed. Some private methods have been renamed and/or removed.

A new XHR object is created for each relevant asset (as there must be a different XHR for each asset loaded in parallel). Online searches indicated that there was no relevant benefit of XHR (as a particular use-case) re-use; and time will be dominated with the resource fetch. With the new flight queue an XHR cache could be re-added, at the cost of some complexity.

The URL is always transformed through transformUrl, which can make adding some one-off special cases like #1355 easier to deal with.

This also incorporates the fast-cache path for Images tags that can greatly speed up the responsiveness of image loading.

Loader.resetLocked is a boolean that allows you to control what happens when the loader is reset, which happens automatically on a State change. If you set resetLocked to true it allows you to populate the loader queue in one State, then swap to another State without having the queue erased, and start the load going from there. After the load has completed you could then disable the lock again as needed.

Thanks to @pnstickne for vast majority of this update.

 

PIXI V2

We are now using our own custom build of Pixi v2. The Pixi project has moved all development resources over to Pixi v3, but it wasn't ready in time for the release of Phaser 2.3 so we've started applying our own fixes to the version of Pixi that Phaser uses.

As a result we have removed all files from the src/pixi folder that Phaser doesn't use, in order to make this distinction clearer. This includes EventTarget, so if you were relying on that in your game you'll need to add it back in to your local build.

We've also removed functions and properties from Pixi classes that Phaser doesn't require: such as the Interaction Manager, Stage.dirty, etc. This has helped us cut down the source code size and make the docs less confusing, as they no longer show properties for things that weren't even enabled.

We've rolled our own fixes into our version of Pixi, ensuring we keep it as bug-free as possible.


You can read the entire release notes here.

Programming, News ,




An Hour with Blender and GameFromScratch.com

26. March 2015

 

I just started a new concept off today, please let me know if you like it.  Basically it’s a fixed duration (one hour) overview on a specific topic, in this case Blender.  The idea is to give a cross between an introduction and a tutorial on getting started with using a certain product.  In this video we look at Blender, how to configure it, how to navigate and customize the interface, what it’s composed off and the basics of operating it.

 

If there is interest, I can do “An hour with” topics that are much more focused, such as “An hour Modelling” or “An hour texturing”, etc.

 

Additionally, this is not a deep dive Blender tutorial.  Fortunately I already have one of those!  If you are looking at specifics of learning Blender, the hotkeys, etc, please start here.

 

Below is an embedded version of the video.  It is also available in full 1080p on YouTube here.

 

The Video

 

Art , ,




LibGDX Video Tutorial: 3D Part 1

24. March 2015

 

In this tutorial we start looking at 3D game development using LibGDX.  We explore creating a Camera, Model, ModelInstance and look at the basics of working in 3D using LibGDX.

 

You can watch the tutorial in HD here or embedded below.  The following is the source used in this example.

 

The Source


package com.gamefromscratch;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g3d.*;
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
import com.badlogic.gdx.math.Vector3;

public class Demo3D extends ApplicationAdapter implements InputProcessor {
    private PerspectiveCamera camera;
    private ModelBatch modelBatch;
    private ModelBuilder modelBuilder;
    private Model box;
    private ModelInstance modelInstance;
    private Environment environment;
   
   @Override
   public void create () {
        camera = new PerspectiveCamera(75,Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
        camera.position.set(0f, 0f, 3f);
        camera.lookAt(0f,0f,0f);
        camera.near =0.1f;
        camera.far = 300f;

        modelBatch = new ModelBatch();
        modelBuilder = new ModelBuilder();
        box = modelBuilder.createBox(2f,2f,2f,
                new Material(ColorAttribute.createDiffuse(Color.BLUE)),
                VertexAttributes.Usage.Position|VertexAttributes.Usage.Normal);
        modelInstance = new ModelInstance(box,0,0,0);
        environment = new Environment();
        environment.set(new ColorAttribute(ColorAttribute.AmbientLight,0.8f,0.8f,0.8f,1f));

        Gdx.input.setInputProcessor(this);
   }

   @Override
   public void render () {
      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT|GL20.GL_DEPTH_BUFFER_BIT);

        camera.update();
        modelBatch.begin(camera);
        modelBatch.render(modelInstance,environment);
        modelBatch.end();
   }

    @Override
    public boolean keyDown(int keycode) {
        // In the real world, do not create NEW variables over and over, create
        // a temporary static member instead
        if(keycode == Input.Keys.LEFT)
            camera.rotateAround(new Vector3(0f, 0f, 0f), new Vector3(0f, 1f, 0f), 1f);
        if(keycode == Input.Keys.RIGHT)
            camera.rotateAround(new Vector3(0f,0f,0f),new Vector3(0f,1f,0f), -1f);
        return true;
    }

    @Override
    public boolean keyUp(int keycode) {
        return false;
    }

    @Override
    public boolean keyTyped(char character) {
        return false;
    }

    @Override
    public boolean touchDown(int screenX, int screenY, int pointer, int button) {
        return false;
    }

    @Override
    public boolean touchUp(int screenX, int screenY, int pointer, int button) {
        return false;
    }

    @Override
    public boolean touchDragged(int screenX, int screenY, int pointer) {
        return false;
    }

    @Override
    public boolean mouseMoved(int screenX, int screenY) {
        return false;
    }

    @Override
    public boolean scrolled(int amount) {
        return false;
    }
}

 

The Video


Programming , , ,




Blender 2.74 release candidate 2 available

22. March 2015

 

For those of you that like living on the bleeding edge, RC2 of the upcoming Blender 2.7 is now available.  If nothing else it gives you an idea of what is coming in Blender 2.74.

 

Splash 274.png

 

 

Cycles Rendering

Rl pointiness.png

  • Several improvements for BVH like making it watertight, solving several precision issues and reducing noise
  • Optimizations:
    • Black world backgrounds are now removed from the shader graph, resulting in great speed improvements
    • Various (and great!) memory optimizations

 

  • Nodes:
    • New Pointiness attribute for the Geometry node
    • Control texture space of one object by another

 

 

User Interface

Viewport FX release notes.png

  • New Viewport Compositing brings Ambient Occlusion and Depth of Field right into the Viewport!
  • View-depth can now be picked using an Eyedropper
  • Outliner:
    • An Orphaned Datablocks Mode was added for datablock management
    • Deleting of entire object hierarchies
    • Drag&Drop objects to groups

 

  • The Node Editor can now show text-blocks in frames
  • Customizable camera safe areas
  • And more!

 

Modeling

Rl split normals.png

  • Support for Custom Normals was added
  • Transferring data layers between meshes is now possible thanks to a new Mesh Data Transfer operator and modifier
  • Tools:
    • UV handling for Edge- and Vertex Slide was improved
    • Inverse-square blending for proportional-edit-mode
    • "Fit Camera View" now works for orthographic cameras as well
    • A "Split Concave Faces" tool to ensure a convex geometry was added

 

 

Particles

07 shape cut AFTER.png

  • Hair dynamics and editing tools were improved massively:
    • Support for hair collission with meshes
    • Simulation no happens using volumetric calculations for more realistic results
    • Strand bending uses a more realistic approach
    • Controlling of child hair shapes using curve widgets
    • New "Spiral" kink mode to generate spirals at hair ends
    • Toggle buttons for render and viewport visibility were added to the particle settings in the Properties Editor
  • And much more!

 

Sculpting/Painting

Release notes cavity.png

  • Brushes/Strokes:
    • Improvements to rake and random mapping
    • Line strokes now support constrains to 45 degree increments
  • Texture Painting:
    • Support for dithering for painting on byte images
    • A new tool "Cavity Mask" was added that creates masks based on mesh cavities or hills
  • And more!

 

Freestyle NPR Rendering

Blender 274 Freestyle BNPR NY2015.png

  • A great memory consumption optimization in stroke rendering was done
  • And more!

 

Animation

Rl anim.png

  • Grease Pencil:
    • New Editing tools like copy & paste strokes, duplicating active layer, ...
    • Enable eraser on the fly while drawing with "Continuous Drawing"
    • Various UI tweaks such as color swatches for Stroke and Fill colors
    • Grease Pencil data layers are now shown in the Outliner

 

  • Improvements to the action management to reduce the cases where unused actions are deleted
  • Pasting keyframes can now be done flipped
  • Using a new "Follow" option, the animation editors can now follow the time indicator
  • And more!

 

Game Engine

  • Physics:
    • The first contact point of colliding can now be accessed from Python
    • Usability improvements
  • New option "Lock Z Velocity" to avoid micro-jumping
  • And more!

 

Add-ons

  • A new Auto Tile Size Add-on helps setting up the fastest tile size for Cycles rendering
  • Import images as planes now works for Cycles as well
  • POV-Ray Renderer now supports volumetric rendering
  • FBX and OBJ now support custom normals import
  • New Python API functions
  • And more!

 

More Features

There are a lot more features that are new in Blender 2.74, so make sure to check them out!

 

It may be a minor thing, but that “fit camera view” fix is certainly going to make my life a happier thing.  Full release notes are available here.  You can download the RC2 release here.  Or wait 2-4 weeks for the full release.

Art, News