In this tutorial we’ll set up our player and spawn it in the scene.
While the player group will have 2 members, we’ll only set up one for now – the fighter. The goal of this tutorial is to be able to run around with our player.
We’ll set up:
- animations
- the player (combatant)
- world scene (spawn, camera borders)
- start game schematic
Let’s get to it!
Animation Types #
First, we’ll set up a new animation type.
Animation types are used to play animations without having to worry what that animation actually is. E.g. an Attack animation type can play different animations based on what combatant plays it, or what weapon the combatant has equipped. You can learn more about animations in this documentation.
A new project already comes with multiple default animation types, so we only need to add one more for our use (though we don’t use most of the default ones).
Navigate to Base/Control > Animation Types and add new type.
13: Use #
This’ll be used to play an animation when using an item or ability.
- Name
Set to Use.
Animations #
Next, we’ll set up movement animations, i.e. idle, walk and run animations.
The models used in the tutorial assets worked best using the legacy animation system, so that’s what we’re going with. Also, the legacy animation system is great at giving you control over playing animations when you want, instead of relying on state transitions like Mecanim does.
Legacy animations are played on layers, higher layers overrule lower layers, we’ll use that to ensure the correct animation has priority:
- Layer -1: idle
- Layer 0: walk, run
- Layer 1: damage, evade, etc.
- etc.
0: Movement #
Navigate to Base/Control > Animations, select the Default animation setup and change the following settings.
Base Settings #
- Name
Set to Movement. - Random First Start Time
Enable this setting.
This’ll use a random time for the initial animation that is played to prevent all combatants using the same animations from looking exactly the same.
Legacy Settings #
Since we’re using the legacy animation system, that’s where we’ll do our animation setup.
Click on Add Legacy Animation.
- Animation Type
Select Idle.
Animation types can have multiple animations assigned to them – one will be played randomly. There’s already an animation added, so let’s change it.
- Animation Name
Set to Idle. - Set Layer
Enable this setting. - Animation Layer
Set to -1.
We’ll use the default Play Settings for all our animations, they’re:
- Play Type
Select Cross Fade. - Play Mode
Select Stop Same Layer. - Fade Length
Set to 0.1.
Copy Legacy Animation 0 and change the following settings.
- Animation Type
Select Walk. - Animation Name
Set to Walk. - Animation Layer
Set to 0.
Copy Legacy Animation 1 and change the following settings.
- Animation Type
Select Run. - Animation Name
Set to Run.
That’s it for the animations.
Combatants General Settings #
Next, we’ll handle some general settings for all our combatants. You can learn more about combatants in this documentation.
Navigate to Combatants > Combatants > General Settings.
Animations & Movement #
We’ll set up Legacy as the default animation system and use the animations we just set up.
Default Animation System #
- System Type
Select Legacy.
Default Animations #
Click on Add Animations.
- Animations
Select Movement.
Auto Animation #
Auto animations are best only used with Legacy animation systems. They’ll automatically play idle/movement animations based on the current move speed of a combatant.
- Use Auto Animation
Enable this setting. - Minimum Run Speed
Set to 4.
This is the minimum speed needed to play the run animation. - Minimum Sprint Speed
Set to 10.
We don’t really use sprint animations, though.
The auto animations use the Default Animation Types that are set up in Base/Control > Animation Types > General Settings. A new project has them automatically set up to use the (also automatically set up) Idle, Walk, Run, etc. animation types. In case your auto animations don’t work, make sure they’re set up correctly and use the animation types you use for your movement animations.
Default Move Speed #
The move speed handle how fast a combatant will move for walk, run and sprint movement (e.g. when used by the player controls or the move AI).
- Use Position Change
Enable this setting.
This’ll use the combatant’s actual position change to calculate the movement speed, i.e. it is independent from however the game object is actually moved.
This is the default setup and usually what you want to use. - Walk Speed
Select Value > Value.
Set the value to 3. - Run Speed
Select Value > Value.
Set the value to 8. - Sprint Speed
Select Value > Value.
Set the value to 12.
Sound Settings #
We’ll make use of the sound types we’ve set up and assign default audio clips to them for all our combatants. The individual combatants can replace them with their own setup if you want.
You can also assign multiple audio clips to a sound type – one of the added clips will be played randomly.
The audio clips can be found in Assets/Tutorial Assets/NinjaAdventure/Sounds/Game/.
Click on Add Sound.
- Sound Type
Select Attack. - Audio Clip
Select swoosh01.
You can find it in Assets/Tutorial Assets/Audio/Sounds/swoosh/.
We’ll add multiple audio clips, one of them will be used randomly.
Click on Add Audio Clip.
- Audio Clip
Select swoosh02.
Click on Add Audio Clip.
- Audio Clip
Select swoosh03.
Alright, and another sound – click on Add Sound.
- Sound Type
Select Hit. - Audio Clip
Select hit03.
You can find it in Assets/Tutorial Assets/Audio/Sounds/hits/.
Click on Add Sound again.
- Sound Type
Select Death. - Audio Clip
Select random6.
You can find it in Assets/Tutorial Assets/Audio/Sounds/RPG Sound Pack/misc/.
Fighter Combatant #
For now, we’ll just change the name and set up a prefab, we don’t need any status setup (other than the automatic default setup), since we don’t fight in battles yet and only want to run around.
Navigate to Combatants > Combatants and select the Default combatant.
Content Information #
- Name
Set to: Fighter
Base Settings > Prefab Settings #
- Prefab
Select the Warrior prefab.
You can find it in Assets/Tutorial Assets/Prefabs/Combatants/Player/. - Update Mode
Select Auto or Update.
Our combatants are moved by a CharacterController, i.e. the update mode (which determines when things like the move speed or movement direction are calculated) has to be set to update in regular frames.
If your prefabs are using physics for movement (e.g. Rigidbody), you need to use the physics based update mode (Fixed Update).
Save Changes #
That’s it for the setup in the editor for now.
Don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.
Scene Setup #
Open the World scene (found in Assets/Scenes/).
We’ll add an ORK Game Starter, a Spawn Point and Camera Borders.
Add Game Starter #
First, we’ll add a game starter to the scene and set it up for quick game testing. We’ll go with the ORK Game Starter variant.
Game starters are used to initialize your project, without it, you can’t access any functionality without causing errors. You can learn more about game starters in this documentation.
You can either use the scene hierarchy context menu or the scene wizard (e.g. via CTRL + ALT + W, or using the Unity menu: Window > Gaming Is Love > Makinom Scene Wizard).
I’ll use the context menu: ORK Framework > ORK Game Starter
The added game starter should already have your Project asset set up. Change the following setting in the ORK Game Starter component’s inspector.
- Start Game
Enable this setting.
This will immediately start a new game after initializing ORK.
It doesn’t really matter where you place the game starter, but it’s best to have them somewhere outside your actual level architecture to not get in the way.
Add Spawn Point #
Next, we’ll add a spawn point – we’ll spawn on the right side of town, near the gate.
Like the game starter, you can add a spawn point via the context menu or the scene wizard. The scene wizard has searchable popups for adding game objects or components, which can get very convenient when having to set up multiple things.
I’ll use the context menu: Makinom > Spawn Point
The spawn point will be placed directly on the ground (or whatever else is hit by the raycast into the scene) at the screen’s center – and it automatically has the next free Spawn ID assigned. Spawn IDs are used to identify a spawn point, so when we (soon) spawn our player using a schematic, that’s the spawn ID we’ll use.
Since there wasn’t a spawn point in the scene before, we’ll have the spawn ID 0 assigned.
Transform #
Change the position of the spawn point in the inspector.
- Rotation
Set to X=0, Y=90, Z=0.
Spawn Point #
- Use Rotation
Enable Y.
We’ll use the Y-axis rotation when spawning the player on this spawn point.
Add Camera Borders #
If you look at the scene hierarchy, you’ll see a game object called Camera Borders, it’s child objects are for our camera borders:
- Town
- Gate
- Field 1
- Field 2
They already have a collider components (used as triggers) set up to cover their parts of the scene – when the player moves between them, the camera will switch over.
All we need to do is add a Camera Border component to each of them using the component menu. The component offers a few settings, but we don’t need any of them for our setup, except for the Gate camera border, so select the Gate child object and change the following setting.
- Use Border Height
Enable this setting.
This’ll place the camera at the upper edge of the game object’s collider.
That’s it for the scene, save your changes.
Start Schematic #
A schematic is a reusable, node-based blueprint for what you want to do. It consists of connected nodes that work similar to a flow chart – each node performs a task and decides the next node that’ll be executed. You can learn more about schematics in this Makinom documentation.
You’ll make frequent use of schematics when creating your games, e.g. to talk to an NPC, animate an action in battle or, as in this case, set up what happens at the start of a new game. We’ll cover different setups as part of this tutorial series.
Open the Makinom editor again and navigate to Schematics – it’s time to set up a simple schematic we’ll use when starting our game.
We’ll join the Fighter to the player group and spawn at the spawn point (spawn ID 0).
Join Group #
Add Node > Group > Group > Join Group
First, we’ll add Fighter to the player group. This will automatically join a combatant to the group’s battle group as well, unless no free slot is available.
- Group Origin
Select Active Player Group.
This’ll join the combatant to the currently active player group. - Get From
Select Combatant.
We’ll create a new combatant from a defined combatant’s settings.
You could also use combatants of a combatant group setup, a random combatant of a combatant type or an existing combatant (via an object). - Combatant
Select Fighter.
Spawn ORK Player #
Add Node > Game > Player > Spawn ORK Player
Now, we’ll spawn the player in the scene.
- Spawn At
Select Spawn Point. - Spawn Point ID
Set to 0.
And that’s it for the schematic. Click on Save Schematic to save it, e.g. as StartGame.
I usually save all my schematics in Assets/Schematics/ and sub folders of it.
Start Menu #
We don’t use the start menu yet (we just hit play in the World scene), but we’ll need to set up our start schematic.
Navigate to UI > Start Menu and change the following settings.
New Game Settings #
- Start Schematic
Select the StartGame schematic.
Save Changes #
And that’s it – we’re ready to take our player for a test walk!
Don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.
Testing #
Alright – let’s take a walk. With the World scene still open, hit play.
Great, we spawn, can move around and the camera border is doing it’s job!
Next, we’ll set up the game’s music and connect our scenes.