Tutorial EN
Tutorial EN
After you have imported your character’s graphic into your project, create new Animator Controller to create and
configure your character’s animation.
In Animator Controller, you will need the following parameters:
Boolean variables:
run
grounded (for Platformer)
Trigger variables:
hurt
dash
cancelDash
cancelGuard
and additional Trigger variables for using weapon and spell casting. (You may also add or change the name of
these triggers in ItemDatabase and SkillDatabase)
sword1
sword2
bow
staff
cast
cast2
guard
Drag your character’s graphic onto a Scene, then Add Component “Animator” for your character, and then drag
the Animator Controller you’ve created into the “Controller” in “Animator” component as below:
After that, create Animation and set the blend tree similar to the example.
To learn more about creating 2D animation for your character, you can refer to the following documents:
If you use Sprite Sheet, you can read how to create animation here:
https://learn.unity.com/tutorial/introduction-to-sprite-animations#5fa66921edbc2a0020bcaadf
Or if you prefer to use 2D skeletal, you can refer to the following resources:
https://unity.com/features/2danimation
https://learn.unity.com/tutorial/rigging-a-sprite-with-the-2d-animation-package#6017535aedbc2a69ae9b3b
9b
After you have created your Animation and set up your Animator Controller, now you can configure components
for the player character.
After selecting it, the system will spawn an Example Player into the scene (at position 0, 0, 0).
(Please note that this Prefeb use resources from Assets\2D-ARPG\Prefab\Player\Knight-Player. If you have
selected, but and nothing happens, check if the path is valid or if the folder has been moved.)
After that, put the sprite of your character as a Child of Example Player as follows:
Adjust the position of your Sprite. (You may reset the position or set the position to 0, 0, 0 after setting the Sprite
as a child.)
You can also adjust the collider as appropriate for the size of your Sprite at "Box Collider 2D" component, or
change the collider into another shape.
After that, drag the character sprite into the “Main Sprite” in “Status” component.
To make sure that everything is configured correctly, try playtesting your game. Your character is now ready to
roam free and play in the world!
You may configure different attributes as desired at each following component on the player as follows:
"Status" – Used for different status such as attack, defense, magic power, and so on, including Main Sprite and
Dead Prefab.
"Topdown Input Controller 2D" – Used to configure walk and dash speed.
"Attack Trigger" – Used to configure different attacks from toggling on/off mouse aiming. Configure Shortcut UI
here.
For attack animation, attack prefab and attack delay, you may configure them at the Item Database since those
attributes are tied to weapons.
If you don’t want weapon to be changed at all, you can configure the aforementioned in the Attack Trigger then
set the value in “Weapon Equip” in “Inventory” component to 0
The system won’t refer to any value from the Item Database.
"Inventory" – Used to set initial money and equipment, as well as the size of item and equipment slots.
"Skill Status" – Used to set initial Skill Slot’s size and starting Skills.
"Quest Stat" – Used to set the slot of all quests and maximum number of quests that can be received.
"UI Master" – Used to set UI parameters. (Each UI is a child of the player in PlayerUI. You can edit the picture and
position as desired in there.)
Main Camera
Prefab of an example camera asset will be in "Assets\2D-ARPG\Prefab\Player\Camera2D".
You can configure the offset of the camera at "Camera Follow Player 2D" Component.
If you have multiple prefab cameras and wish to change the main camera, you can set it at the Main Camera
Prefab in "Attack Trigger" component of the player.
Item Database
Item Database is a prefab used to store values of each item and equipment.
You can configure the Item Database at "Assets\2D-ARPG\Database\ItemDatabase". Here, it has 2 main tabs,
Usable Item and Equipment.
For Usable Item, you can configure consumable items that can be used for various purposes, such as HP and MP
restoration effect, their price and create an Attack Item that can be used.
Equipment tab is for configuring different equipment, be it weapons or defensive gears.
You can set the attack, defense and other bonus stats here.
- For weapons, you can set its Attack Animation. (Attack Animation will call Trigger in Animator according to the
name you’ve set here.)
- You can set the pre and post-attack delay in Attack Cast and Attack Delay.
- Weapon Type is to reference when using skills. An example would be a bow skill requiring a bow to be
equipped to be usable.
- Set whether the weapon can be used to block attacks by checking the “Can BlocK” box. The animation for
blocking can be set at "Blocking Animation Trigger".
- Charge Attack can be configured if the weapon allows charged attack by holding down a button.
Skill Database
Skill Database is a prefab used to store values for each skill.
You can set the Name, Icon , Prefab , Animation Trigger, Mana Cost, Cast Time , Delay Time, and description
here.
- For Required Weapon, if the box is checked, the skill can only be used if the player has the required weapon
type equipped. The number of Weapon Type can be referred in the Equipment / Weapon Type section of the
ItemDatabase.
- You can expand the Multiple Hit section and set if you want the skill to fire continuous stream of a prefab at a set
amount. You can also swap the animation as well as other prefab.
Skill Prefab
You can create Skill Prefab and Attack Prefab of weapons by creating new 2D Object or Empty Object and then
go to Component/Create Bullet.
For Skill Prefab, the system will require the following:
- "Collider 2D" of any shape. Don’t forget to check the “Is Trigger” box since the system will use Trigger2D to
check for collision.
- Variance: is used to randomize the damage in percent. The more the variance, the more the damage number
will vary from the base value.
- Critical Chance: is the chance of inflicting Critical damage from the skill.
- Inflict Status: is to configure the status ailment that can be inflicted upon hitting enemy.
- Hit Effect: is a prefab that will spawn when hitting an enemy or a wall.
- Effect at Target: If checked, the game will always spawn hit effect at the target hit. Good for skills with wide
radius collider.
- Flinch: If checked, the enemy hit will be temporarily flinched (Mini Stun).
- Knock Back Force: Used along with Flinch. The more the value, the further the target will be knocked back.
- Penetrate: Upon hitting a target, it won’t disappear. Use this to make an attack that can pierce and hit multiple
targets.
- One Hit per Enemy: This attack will hit only once per enemy. Even if that enemy is attacked again, there will be
no damage inflicted.
- Attack Type: There are 2 types, Physical which depends on the user’s Attack, and Magic which depends on
user’s Magic Attack.
- Drain HP: Will drain enemy’s HP and restore player’s upon hitting.
- Bomb Hit Setting: Upon hitting a target or a wall, will explode and inflict AoE damage.
- Spawn Child When Hit: Upon hitting a target or a wall, spawn a set attack prefab at the point on impact.
- Fwd Plus after Spawn: Upon shooting, this skill prefab will spawn in front of the player character at the distance
set.
Skill Tree
You can configure your Skill Tree by opening the PlayerUI/SkillTree (which is a child of player character).
The Child of the Skill Tree will be skill buttons of each skill. In our example, we’ve pre-configured everything for
you. If you want to add another skill, you can just copy the button from the example without needing to configure
anything further.
Here, we will see how to configure the Skill Tree and "Skill Tree UI" component.
You can set configure setting for each skill, such as:
Unlock Condition ID – Must have the set required skill to unlock this skill.
Unlock Level – Must have the level equal or more than the set value to unlock the skill.
Sk Point Use – How many skill point is needed to level up this skill.
As for the Skill Button, you can drag the Skill Button you wish to link to the skill here.
Event Maker
Event Maker is a system to create events for your game in a simple manner. Start off by selecting the object you
want.
Click the " Add Component" button and select "Add Event"
Event Activator & Start Condition
You can set the condition for starting event at "Start Condition" in the "Event Activator" component
Key Trigger - The event will trigger upon entering event’s proximity (via Collider2D / Trigger) and then press “E”
Event to activate.
Collide - Will trigger when two objects with Collider2D and RidgidBody2D collide.
Trigger Enter - Will trigger when the player enters the trigger area (via Collider2D / Trigger)
Trigger Exit - Will trigger when the player leaves the trigger area (via Collider2D / Trigger)
None - Will not start until called by other scripts or other conditions.
Event Settings
You may select events from the list, and you can Add Event as much as you desire.
In this example, the event will have the following happen in sequence:
Here, you can set the quest’s name, description, progression step to clear, as well as its experience and
monetary reward after the quest is complete.
For the “Show Progress” box, if checked, it will show the quest’s progress in the player’s quest window.
For the “Cant Cancel” box, if checked, player can’t cancel the quest. Good for important or story quests.
Quest Client
This section is for the quest’s client NPC. First, we’ll use the “Quest Client EV” script to store all events according
to the quest’s condition. This is shared with Event Marker, whether it’s for display message or other events while
receiving quest.
For the “Quest Client EV”, we recommend you to create another blank object to insert this component to make it
easier to divide the events up for NPC that can give out more than one quest.
Talking Event - Call this event when talking to the NPC before receiving the quest.
Ongoing Quest Event - Call this event when talking to the NPC after receiving the quest.
Finish Quest Event - Call this event when talking to the NPC after fulfilling the quest’s condition.
Already Finish Quest Event - Call this event when talking to the NPC after the quest is finished.
Quest Full Event - Call this event when talking to the NPC, but the quest log is full and can’t accept more.
After you’ve configured the quest, use the “Quest Trigger EV” at NPC. This script will then call “Quest Client EV”. If
the NPC can give out more than one quest, you can add quests in order you want. After the first quest is finished,
the NPC will give out the next quest in sequence until all is complete.
Quest Progressive
This script is to progress the quest according to the Quest ID you’ve set. Once this script is called, if the player
has a quest that match the Quest ID, the quest’s progress will increase. You can put this script into a monster’s
Death Prefab is into an object that player must collect for the quest.
Trigger – The player must collide with the trigger of the object with this script to activate.
None – This script will not activate until called from other functions or scripts.
Crafting Database
Crafting Database is a prefab to store Craft Menu values.
In the Ingredient section, you can refer to the item needed for crafting using:
The Got Item is the item that you will receive after crafting is finished.
Crafting NPC
For in-game crafting NPC or Craft Menu, you can use “Crafting UI” script.
You can put in as many Craft ID as you want into the Crafting List ID in the “Crafting UI” component.
You can call a menu by calling the function "OpenCraftMenu" in the "Crafting UI" component.
You can see an example for how to set up an NPC and UI in "Assets\2D-ARPG\ExampleScenes\Camp".
Shop
You can configure a shop using "Shop Ui" script. You can configure the items sold in the shop with Item ID and
Item Type in the Shop Slot.
You can see an example for how to set up an NPC and UI in "Assets\2D-ARPG\ExampleScenes\Camp".
Creating Monsters
As with the player character, first, you must prepare character graphic and create new Animator for the monster.
- run (bool)
- hurt (trigger)
- attack (trigger)
*Note that for attack, you can add or change the name of the trigger. This will refer to the trigger’s name when
attacking set in the “Monster AI” component.
After selecting, the system will spawn an Example Monster into the scene (at 0 , 0 , 0).
(Please note that this Prefeb use resources from Assets\2D-ARPG\Prefab\Monster\Goblin. If you have selected,
but nothing happens, check if the path is valid or if the folder has been moved.)
After that, put the character graphic in as a Child of Example Monster as below:
Adjust the position of your Sprite. (You may reset the position or set the position to 0, 0, 0 after setting the Sprite
as a child.)
You can also adjust the collider as appropriate for the size of your Sprite at "Box Collider 2D" component, or
change the collider into another shape.
After that, drag the character sprite into the “Main Sprite” in “Status” component.
If you have configured all the basic settings correctly, the monster will be able to roam around and attack the
player!
You can set the status of the monster in the "Status" component and configure additional settings in the "Monster
AI" component.
Approach Distance - The attack range of the monster. Once it approaches according to the distance, it will start
attacking.
Detect Range - The detection range of the target. Once its enemy enter this range, the monster will change to
chasing phase.
Lost Sight - The monster will give up chasing if its target leaves this range.
Gravity - The monster’s gravity. This setting is defaulted to 0 in Top-Down mode. You can set to 1 or more for use
in Platformer mode.
Attack Animation Trigger - The name of the trigger for playing animation when attacking.
Attack Prefab – Prefab that the monster will spawn upon attacking.
Attack Point - The spawn point of the Attack Prefab. (If not set, the Attack Prefab will always spawn from the
monster itself.)
While Attack - Set whether the monster will stay still while attacking or move forward a little.
Aim at Target - Always aim towards the target if checked. If not checked, the attack will aim at the monster’s front
instead.
Patrol Setting – Set the monster’s random patrol pattern in idle mode.
Skill - Configure the skill of the monster. If set to 0, the monster will only attack normally.
Skill Distance - The distance of where the monster will use the skill.
Monster Drop Items
You can use the "Drop Item" script to make the monster drop an item(s) by putting the script in the monster’s
Dead Prefab. Upon its death and spawn of Dead Prefab, the script will activate immediately.
If you set the ID to more than 0 and Item Prefab has “AddItem” component, the system will change the ItemID to
the ID you’ve configured here.
Gain EXP
This script will activate automatically. You can put it in a monster’s Dead Prefab and set the EXP gain as much as
you desire.
Monster Respawn
Like the previous one, this script will also activate automatically. You can put it in a monster’s Dead Prefab and
configure the respawn time.
Point Name - The name of the tag for an object that will be used as spawn point for the monster. If the scene has
multiple objects of the same tag, the system will randomize the position from one of those.
Random Point – Set how further the monster can respawn from the respawn point.
Mobile Setup
You can toggle controller for mobile phone by enabling the “MobilePanel” in the player’s child at
(PlayerUI/MobilePanel).
Upon enabling the "MobilePanel", you can use the mobile controller right away.
For Platformer
If you wish to create a platformer game, we have a sample scene available at
"Assets\2D-ARPG\ExampleScenes\PlatformerExample".
For the player character, mainly you’ll have to change the component from “Top Down Input Controller 2D” to
"Platformer Controller 2D” instead.
For monsters, set the gravity in “Monster AI” component to be 1 or more, except for the flying enemies.
*Caution! For wall object in a platformer game, we recommend you put Physic Material “PlatformerWall”
(Assets\2D-ARPG\Prefab\PlatformerWall) into the collider every time to prevent the player character from being
stuck to a wall if the press move forward while being mid-air.