Making a 2D character

After using the New Game Wizard to set up your game's Managers, you'll need to configure your project to be in 2D.

Look for the Settings Manager's Camera settings panel, and set the Camera perspective to 2D:

A 2D character is one that is made up of one or more sprites - set up to play different animations according to which direction they're facing. You can use your own graphics to follow along, but here we'll be using those used by the 2D Demo's Player character. These graphics can be found in AdventureCreator → Demo2D → Graphics → Sprites → Brain.

Start by dragging your main sprite into the scene. Here, we're using Idle_D, but whichever sprite you use - be sure to set the asset's Pivot to Bottom, so that the GameObject's origin is around their feet:

We'll make use of the Character Wizard to convert this sprite into a character. From the top toolbar, choose Adventure Creator → Editors → Character wizard.

The wizard will pop up in a new window. Click Next, and give them a name. On the next page, select either Player or NPC, and then drag-and-drop the scene sprite into the GameObject field:


The object you assign here needs to be a GameObject in the scene - not the original sprite asset file.

On the next page, leave the Animation engine field set as Sprites Unity, and click Finish to create the character.

Our single-sprite now takes up three objects in the Hierarchy:

The root object now has a Player or NPC component, which the sprite is now parented to.

A Rigidbody 2D has also been added to the root, among other things. This is only necessary if you wish for the character to collide with other objects. If your game is point-and-click, you can remove this for better performance.

The Player or NPC component will have various settings for movement, but the default values should work fine. What you will need to configure next are the animation settings.

When the Animation engine is set to Sprites Unity, standard animations are played through naming convention - and AC will expect animation names to end with a letter that signifies which direction it is intended for. For example, it will expect an animation named walk_DR when the character walks down-right, and talk_L when talking to the left.

To keep things simple, we'll just have the character stand and walk in the four main directions. Under the Standard 2D animations panel in their Player or NPC Inspector, clear the Run name and Talk name fields, and keep Facing directions set to Four:

You can see a list of all the standard animations that AC expects, based on these settings, by expanding the List expected animations? foldout just beneath:

The number after each animation's name indicates the layer that it should be placed in. (0) refers to the Base layer.

To store animations, we'll need an Animator Controller. You can create one by choosing Assets → Create → Animator Controller from the top toolbar. Then select the character's sprite child object, and assign this asset file into the Controller component of the Animator Inspector:

Open up the Animator Controller by double-clicking the asset file. Into here, you'll need to supply animations that control this sprite appropriately. For example, walk_R should be a looping animation that has the sprite animating to the right. This is all using Unity's built-in animation tools, so refer to Unity's own documentation if you're new to this topic.

If you're using the 2D Demo sprites to follow along, though, you can drop in the animation assets found in Adventure Creator → 2DDemo → Animations → Brain:

Just be sure to also set the Idle name and Walk name fields to BrainIdle and BrainWalk to match their naming convention:


Don't worry about transitions, or which animation clip is the default. With 'Sprites Unity' animation mode, animation playback is automatic.

With animation assigned, our character is now ready to appear in a proper scene! One extra thing, though: if this character is intended to be the default Player character, make them a prefab by dropping them into the Project window, and then assign that prefab into the Settings Manager's Player prefab field:

Doing so will cause the Player to be spawned whenever an AC scene is run - meaning you can safely remove the Player from the scene file itself.