In this tutorial we’ll set up the player and take our first steps in the game.
Our player combatant’s name is Ellen – from Unity’s 3D Game Kit assets. Say hello to Ellen:
We’ll set up the following things:
- player/camera controls
- Ellen’s animations
- Ellen’s combatant
- initial scene setup (game starter, spawn point)
- start schematic
Let’s get to it!
Game Controls #
Navigate to Base/Control > Game Controls, we’ll set up the player and camera controls.
Learn more about player/camera controls in this documentation.
Player Settings > Collision Camera Settings #
First, we’ll enable using a collision camera, i.e. our camera will try not to go through level architecture.
This uses a raycast from the player to the camera to check if anything is blocking the view.
- Enable Collision Camera
Enable this setting. - Check Type
Select Cross. - Layer Mask
Select only the Default layer.
Click on Nothing and on the Default layer. - Move Toward
Set to 0.1.
This’ll move the camera closer to the player from the position that was hit by the raycast. - Player Child Name
Select Path.
We’ll define a path to a child object. - Find Child
Set to Head.
This child object will be the target for the camera.
ORK Control Settings > Player Controls #
We’ll use ORK’s built-in Button player control and Animator Root Motion for movement.
We’ll move using the WASD keys, which are already set up for us in a new project.
- Player Control Type
Select Button. - Move Type
Select Animator Root Motion.
This’ll forward the move speed to the animator.
The animator will play movement animations based on the speed, moving the game object via root motion. - Forward Speed Parameter
Set to Speed. - Vertical Speed Parameter
Remove the text (empty field).
We’re not using this. - Grounded Parameter
Remove the text (empty field).
We’re not using this. - Set Controller Gravity
Enable this setting.
We’ll use a Character Controller component on the player’s prefab to add gravity.
The default project setup already has WASD keys set up for our movement input.
- Vertical Axis
Select Vertical Move. - Horizontal Axis
Select Horizontal Move.
We’ll enable using sprinting, which consumes our Stamina status value.
- Use Sprint
Enable this setting. - Sprint Key
Select Sprint. - Sprint Factor
Set to 1.3.
I.e. sprinting will increase the move speed by around 30%. - Use Energy
Enable this setting. - Energy Consume
Select Value > Value.
Set the value to 10.
Spriting consume 10 stamina per second. - Use Status Value
Enable this setting. - Status Value
Select Stamina.
ORK Control Settings > Camera Controls #
We’ll use the built-in Mouse camera control, changing the rotation and height via mouse input.
- Camera Control Type
Select Mouse. - Child Object
Select Path.
We’ll define a path to a child object. - Find Child
Set to Head.
This child object on the player will be the target of the camera. - Use Unscaled Time
Enable this setting.
The camera isn’t affected by time scale changes.
We’ll later stop the time (via time scale 0) while selecting a target for the grenade to throw at, this allows us to still change the camera during this. - Distance
Set to 5. - Height
Set to 3. - Minimum Height
Set to 0. - Maximum Height
Set to 5.
The Mouse/Touch Controls are already set up as we need it, using the right mouse button to control the camera (holding the button and moving the mouse).
However, we’ll change the zoom factor to make the changes slower.
- Zoom Factor (Zoom Settings)
Set to 0.2.
Animations #
Next, we’ll set up the animations used by the player’s combatant. We’re using Mecanim animations, the animator controllers are already set up.
The movement animations are handled by a blend tree, which plays them based on the Speed parameter that’s set via the player controls (as we just set it up).
Since this is already handled by our control, we don’t need to do anything for the idle/movement animations.
What we need to set up is playing different animations, e.g. attacks or damage. We’ll directly play them or crossfade to them.
You can learn more about animations in ORK in this documentation.
Navigate to Base/Control > Animations, we’ll change the Default animation setup.
- Name
Set to Ellen.
Mecanim Settings #
We’ll set up animations for damage, death, attack 1-4, healing and roll.
Mecanim Animation 0 #
Click on Add Mecanim Animation.
- Animation Type
Select Damage.
Adjust the already added Animation 0.
- State Name
Set to EllenHitFront. - Duration Type
Select Animation Clip.
We get the duration for the animation from the animation clip used by the state.
Mecanim doesn’t report animation play times, so ORK has to find the duration, either via a defined time or by finding the animation clip by it’s name. - Use State Name
Enable this setting.
Since the state name and the animation clip’s name match, we can just use the state name to find the clip for the duration.
If your own animations are set up differently, you might need to define the name of the animation clip instead. - Play Mode
Select Cross Fade. - Transition Duration
Set to 0.1.
We can add multiple animations to an animation type, one of them will be played randomly. We’ll use this to play different damage animations.
Copy the Animation 0 setup.
- State Name
Set to EllenHitBack.
Copy the Animation 1 setup.
- State Name
Set to EllenHitLeft.
Copy the Animation 2 setup.
- State Name
Set to EllenHitRight.
Mecanim Animation 1 #
Click on Add Mecanim Animation.
- Animation Type
Select Death.
Adjust the already added Animation 0.
- State Name
Set to EllenDeath. - Duration Type
Select Animation Clip. - Use State Name
Enable this setting. - Play Mode
Select Cross Fade. - Transition Duration
Set to 0.1.
Mecanim Animation 2 #
Copy Mecanim Animation 1.
- Animation Type
Select Attack. - State Name
Set to EllenCombo1. - Play Mode
Select Play.
We directly play the attack animations instead of fading them.
Mecanim Animation 3 #
Copy Mecanim Animation 2.
- Animation Type
Select Attack 2. - State Name
Set to EllenCombo2.
Mecanim Animation 4 #
Copy Mecanim Animation 3.
- Animation Type
Select Attack 3. - State Name
Set to EllenCombo3.
Mecanim Animation 5 #
Copy Mecanim Animation 4.
- Animation Type
Select Attack 4. - State Name
Set to EllenCombo4.
Mecanim Animation 6 #
Click on Add Mecanim Animation.
- Animation Type
Select Healing.
Adjust the already added Animation 0.
- State Name
Set to EllenIdleLandFast. - Duration Type
Select Animation Clip. - Use State Name
Enable this setting. - Play Mode
Select Cross Fade. - Transition Duration
Set to 0.1.
Mecanim Animation 7 #
Copy Mecanim Animation 6.
- Animation Type
Select Roll. - State Name
Set to EllenRoll. - Play Mode
Select Play.
Player Faction #
Next, we’ll set the player’s faction, navigate to Game > Game Settings.
ORK Game Settings > Player/Group Settings #
- Default Faction
Select Player.
Combatant General Settings #
Navigate to Combatants > Combatants > General Settings, we’ll set up some default settings for all combatants.
Animations & Movement #
We’ll set up the default animation system (all use Mecanim), movement component (using NavMesh Agent) and damage sounds.
Default Animation System #
- System Type
Select Mecanim.
Default Movement Component #
The movement component is used by the move AI to move the combatant.
- Component Type
Select Nav Mesh Agent. - Add Component
Enable this setting.
In case a combatant’s prefab doesn’t have an agent set up (ours do), this’ll automatically add one.
Sound Settings #
Click on Add Sound.
- Sound Type
Select Damage. - Audio Clip
Select hit26.
Copy Audio Clip 0.
- Audio Clip
Select hit27.
Copy Audio Clip 1.
- Audio Clip
Select hit28.
Copy Audio Clip 2.
- Audio Clip
Select hit29.
Player Combatant #
Now it’s finally time to set up the player’s combatant.
Navigate to Combatants > Combatants, we’ll change the Default combatant.
- Name
Set to Ellen.
Base Settings #
- Combatant Type
Select Default.
We don’t really need it, but it’s always a good idea to have it set.
Prefab Settings #
- Prefab
Select Ellen Variant.
You can find the prefab in Assets/Tutorial Assets/Prefabs/Combatants/.
Status Settings #
- Class
Select Default.
We also don’t use it, but it’ll be set to the first class by default in any case.
Status Value Settings > Start Values #
We’re not using any status development, so we’ll directly set the status values we want here.
Click on Set Default, this adds all Normal type status values (e.g. Max HP, ATK, etc.) with their default initial value.
We now only need to adjust the values as we want them. I’ll just list the status values and their names here – you need to change the Start Value setting of the corresponding status value.
- Max HP
Set to 100. - Max Stamina
Set to 100. - ATK
Set to 5. - RATK
Set to 1.
Not used by the player.
Status Bonuses #
We’ll add the Stamina Regen status effect as an auto status effect via a custom status bonus.
Auto effects are always added (or removed, based on the setup), giving a combatant unremovable effects or prevent effects from being added.
- Custom Bonus
Enable this setting.
Scroll down to the Auto Status Effects and click on Add Status Effect Change.
- Change
Select Add. - Status Effect
Select Stamina Regen.
Animations & Movement #
We’ll now add the animations we set up and set up the move speed used by the player.
Animations #
- Replace Default Animations
Enable this setting.
In case we later add default animations to the general settings (Combatants > Combatants > General Settings), they’ll not affect this combatant.
Click on Add Animations.
- Animations
Select Ellen.
Movement > Move Speed #
- Own Move Speed
Enable this setting. - Maximum Speed
Set to 15. - 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 14.
Save Changes #
That’s it for the setup in the editor.
Don’t forget to save your changes by clicking on Save Settings at the bottom of the editor.
Scene Setup #
Open the Scene scene (found in Assets/Scenes/).
We’ll add an ORK Game Starter and a Spawn Point.
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.
It doesn’t really matter where you place the game starter.
Add Spawn Point #
Next, we’ll add a spawn point – we’ll spawn in the upper right corner of the scene, on the rocks in front of the door-entrance-thingy.
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 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 #
We’ll do a small change to the transform – we’ll rotate it on the Y-axis.
- Rotation
Set to X=0, Y=180, Z=0.
Spawn Point #
We’ll enable using the spawn point’s rotation for the placement.
- Use Rotation
Enable Y.
That’s it for the scene, save your changes.
Start Schematic #
Back to the editor, navigate to Schematics – it’s time to set up a schematic we’ll use when starting our game.
We’ll join Ellen 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 Ellen to the player group.
- 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 Ellen.
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.
Start Menu #
We don’t use a start menu in our game (we just play in this one 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 #
Hit play to start your game in the Scene scene. Your player will spawn in on the rocks and you can move around using WASD controls.
You can also sprint while holding the shift key and change the camera perspective by holding down the right mouse button and moving the mouse.
Next, we’ll set up the player’s weapon.