Difference between revisions of "My first: Animation"

From Divinity Engine Wiki
Jump to: navigation, search
(Introduction)
(Examples)
 
(4 intermediate revisions by the same user not shown)
Line 11: Line 11:
 
|'''For more information on:'''
 
|'''For more information on:'''
 
|-
 
|-
| How to import a resource: [[My_first:_Item]]
+
| How to import a resource: [[My_first:_Item| My First Item]]
 
|-
 
|-
| How to create a character: [[My_first:_Character]]
+
| How to create a character: [[My_first:_Character| My First Character]]
 
|-
 
|-
| How to create an interactive ttem: [[My_first:_Item_-_Interactable_animated_items]]
+
| How to create an interactive ttem: [[My_first:_Item_-_Interactable_animated_items| My First Interactable Item]]
 
|-
 
|-
| How the export tools function: [[Modding:_Maya_Exporter]]
+
| How the export tools function: [[Modding:_Maya_Exporter| Maya Exporter Manual]]
 
|-
 
|-
| An Animation Resource: [[Animation_resource_panel]]
+
| An Animation Resource: [[Animation_resource_panel| Animation Resource Panel]]
 
|-
 
|-
| An Animation Set: [[Animation_set_resource_panel]]
+
| An Animation Set: [[Animation_set_resource_panel| Animation Set Resource Panel]]
 
|-
 
|-
| Visual Resources: [[Visual_resource_panel]]
+
| Visual Resources: [[Visual_resource_panel| Visual Resource Panel]]
 
|-
 
|-
| Root Templates: [[My_first:_Root_template]]
+
| Root Templates: [[My_first:_Root_template| My First: Root Template]]
 
|-
 
|-
 
| The Sidebar: [[Sidebar]]
 
| The Sidebar: [[Sidebar]]
 
|-
 
|-
| Use Actions: [[Category:Use_Actions]]
+
| Use Actions: [[:Category:Use_Actions|Use Actions]]
 
|-
 
|-
 
| The Remote Console: [[ReCon]]
 
| The Remote Console: [[ReCon]]
 
|-
 
|-
| Remote Console Commands: [[Command_list]]
+
| Remote Console Commands: [[Command_list|Command List]]
 
|}
 
|}
  
Line 43: Line 43:
 
* How to use an animations set.
 
* How to use an animations set.
 
* How to use a default animation set.
 
* How to use a default animation set.
* Example for a Door.
+
* Example for a Door and how this logic also applies to a container.
 
* Example for a Bear it's base animaiton set.
 
* Example for a Bear it's base animaiton set.
 
* How to quickly test animations in the editor with the remote console.
 
* How to quickly test animations in the editor with the remote console.
Line 49: Line 49:
 
Included in this guide are a couple of example files:
 
Included in this guide are a couple of example files:
  
insert Door example here
+
[[:File:Door_Example.zip|Door example files]]<br />
  
insert Container example here
+
[[:File:Bear Example.zip|Bear example files]]<br />
 
 
insert Bear animation example here
 
  
 
== My First animation ==
 
== My First animation ==
Line 185: Line 183:
 
|}
 
|}
  
== My First Item Animation ==
+
==In Depth Examples ==
 
 
===My First Door===
 
 
 
A door is one of the simpler animatable objects you can make. In our example we'll have 2 different types of doors: A single and double door. <br \>
 
We'll have 3 files: A base file with both doors rigged and two animation files; one for each of the doors.<br \>
 
 
 
[[File:DoorExampleStruct.PNG|none]]
 
 
 
In the base maya file we have the two doors rigged and sorted into two separate layers.
 
 
 
[[File:DoorExampleRig.PNG|none]]
 
 
 
Note that in this case the mesh is part of the rig hierarchy and is parented to an animation joint. <br \>
 
Currently the animation manager only writes data to joints. So please use joints when creating animated items. <br \>
 
 
 
Each animation file references the base file and has an animation on a different door. <br \>
 
In each file the Animation Manager data is on the root of the door that is animated in the file <br \>
 
 
 
[[File:DoorExampleAMData.PNG|none]]
 
 
 
''In this case we could also merge both animation files. Technically the animation of one door does not get in the way of the other door.''<br \>
 
 
 
From the base file with this set up you can export all the relevant data with the MLE script.
 
 
 
[[File:DoorExampleMLE.PNG|none]]
 
 
 
Once you're done exporting open ''The Divinity Engine 2'', load a mod and level, open the content browser and select or make a correct package. <br \>
 
Add resource and import an ''animation'' for all 4 exported door animations. Import the models as ''models'' and the physics as ''physics''. <br \>
 
 
 
[[File:DoorExampleEditor.PNG|none]]
 
 
 
Before we make a Root Template for the object we need to assign the animations to the doors. Open the visual resource and go to the default animations tab. <br \>
 
Change the Animation Set Type to ''Item''. This should give you a default set of animations slots appropriate for an item. <br \>
 
Add the open door animation to the Open slot in the Default Animations Tab. Add the close door animation to the Close slot in the Default Animations Tab. <br \>
 
 
 
[[File:DoorExampleAnimSet.PNG|600px]]
 
 
 
Now we can make a root template so we can preview the animation in the editor. Create a new root template, set the type to item and assign the model and the physics to their appropriate slots. <br \>
 
Create the root template and place this new root in an appropriate folder. <br \>
 
 
 
[[File:DoorExampleRootCreate.PNG|none]]
 
 
 
Once the root template is made open the side bar and add to the '''Use Actions''' the '''Door''' action. Place the root template in game go into game mode and try out your new animated door. <br \>
 
 
 
[[File:DoorExampleSideBar.PNG|none]]
 
 
 
===My First container===
 
 
 
For a container the set up is pretty much the same. A simple rig with a single animating bone. <br \>
 
However, a container is a single mesh with only part of it rotating. Rather than have the mesh be part of the rig hierarchy it'll be seperate and skinned to the rig. <br \>
 
The exporter can find the rig an object is skinned to, but it is advised to keep the two in a single layer. <br \>
 
 
 
The export set up with animation files referencing the base file remains the same. Setting up the animaiton data and exporting remains the same as well. <br \>
 
Importing and creating the root remaind the same too. The use action changes though. You set the use action to '''open/close''' instead. <br \>
 
You'll also need to define the '''Treasure UI Type''' and give '''Treasure''' a treasure stats to have it fully function as a container .
 
 
 
[[File:ContainerExampleSideBar.PNG|none]]
 
 
 
== My First Character Animation ==
 
 
 
For all the following examples we'll use one character: '''A Bear'''.
 
 
 
In the example is included:
 
* A combat set: draw, hit, hit UA (combat hit), attack, stow
 
* An idle set: idle, Still
 
* A skill set: rush prepare, rush cast
 
* A movement set: walk (f_normal), run (f_fast)
 
 
 
We'll also use an Animation Set Resource set up for a character.
 
 
 
[[File:BearExampleSet.png|none]]
 
 
 
I hope by now you are familiar with how to assign animation data and how to export and import the animations.<br \>
 
We'll start right away with data already present in the engine.
 
 
 
[[File:BearExampleEngine.png|none]]
 
 
 
Add an animation set resource and open it. Assign the character animation set type and add an unarmed subset. <br \>
 
Assign the animations to the following slots:
 
* Default Animation Subset
 
** dodge slot: dodge_01
 
** dodge_backstab slot: dodge_01
 
** run slot : F_Fast_01
 
** walk slot : F_Normal_01
 
** hit slot: Hit_01
 
** hit_backstab slot: Hit_01
 
** hit_magic slot: Hit_01
 
** idle1,2,3 slots: Idle_01
 
** still slot: Still 01
 
 
 
 
 
* Unarmed(UA) Animation Subset:
 
** attack 1,2,3 slots: Attack_UA_01
 
** dodge slot: dodge_UA_01
 
** dodge_backstab slot: dodge_UA_01
 
** hit slot: Hit_UA_01
 
** hit_backstab slot: Hit_UA_01
 
** hit_magic slot: Hit_UA_01
 
** idle 1,2,3 slots: Still_UA_01
 
** still slot: Still_UA_01
 
** unsheat slot: Draw_UA_01
 
** sheat slot: Stow_UA_01
 
 
 
* Skills Animation Subset:
 
** skill_cast_rush_01_cast: Cast_Rush_UA_01_Cast
 
** skill_prepare_rush_01_start: Prepare_Rush_UA_01_Start
 
** skill_prepare_rush_01_loop: Prepare_Rush_UA_01_Loop
 
<br \>
 
[[File:BearExampleAnimSet.png|900px|]]
 
 
 
Once all the slots are filled in open the bear model resource and assign the animation set we just made to the first slot in the bear it's '''Animation Waterfall'''. <br \>
 
Assign the animation to the empty slot in the animation waterfall and apply the changes <br \>
 
 
 
[[File:BearExampleWaterfall.png|none]]
 
 
 
===My First Idle Animations===
 
 
 
The idle animations are the easiest animations to implement. You have one still slot per state group. i.e. one for out of combat and one for each weapon type the character can use. <br \>
 
Per state group there are multiple idle slots. The engine automatically cycles through idle and still slots if a character is doing nothing. <br \>
 
The still is the default state so it needs to be looping<br \>
 
To make an animation looping select it in the content browser make sure the '''preview panel''' is visible and check looping checkbox in the side bar bellow the preview panel.<br \>
 
If the animation is open in the text key editor you can also check looping in the animation properties panel.
 
 
 
[[File:BearExampleLoop.png|700px|]]
 
 
 
You won't need to add any text keys either unless your creature breathes fire while idelling, then you'll need an '''effect text key'''. <br \>
 
If you're character tramples in place you'll need to add a '''footstep text key'''.
 
 
 
===My First Run/Walk Animations===
 
 
 
The run walk animations are still fairly easy to implement. They need to loop like the still animation because thye can repeat for as long as a character moves. <br \>
 
The walk run animations require a bit more effort to have it interact with the sounds in the game. <br \>
 
When a character runs or walks we want to hear their footsteps. To do this open the '''animation resource''' or the '''animation set''' and then click the '''Text Keys''' button. <br \>
 
 
 
[[File:BearExampleWalkKeys.png|700px]]
 
 
 
To add a footstep text key right click the animation timeline and select Left or Right foot. Left and Right are defined by what the character itself would consider left and right. <br \>
 
These text keys contain information that is used by the '''root template''' it's '''footstep property list'''. <br \>
 
The '''footstep property list''' defines which bone and effect is associated with the footsteps defined in the animations of a character. <br \>
 
Important for making the distinction on with the text key is the foot id. As a rule of thumb the numbering in the characters is from left to right, front to back as it would be for the creature itself. <br \>
 
in the case of our bear this means:
 
* '''front left paw''' is 0
 
* '''front right paw''' is 1
 
* '''back left paw''' is 2
 
* '''back right paw''' is 3
 
 
 
the type of sound that is player is define by the '''footstep weight''' on the character roottemplate. <br \>
 
In the case of player characters equipment also defines the footstep sounds.
 
 
 
===My First Combat Animations===
 
 
 
The combat animations are a bit more complex:
 
* When a draw or stow animation plays we need to signal to the engine that the character is drawing it's weapon (even when it is unarmed). <br \>
 
* When a character gets hit we want the combat grunts to play.
 
* When a characte dodges or blocks an attack we don't want combat grunts to play.
 
* When a character attacks we want to signal to the engine ''when'' a hit would connect.
 
 
 
====Draw and stow====
 
 
 
[[File:BearExampleDrawStowKeys.png|none]]
 
 
 
The draw stow in the case of the bear and unarmed animations merely require a '''switch''' text key to be present.<br \>
 
To get a switch text key right click on the animation timeline and select '''switch'''.
 
The funciton of this key is to indicate when an equiped weapon should appear in a character it's hands. <br \>
 
So in the case of player characters move the switch key to the moment where the character takes out it's weapon or puts it away in the animation.
 
 
 
====Hit and dodge====
 
 
 
This is much like the walk and run nanimations. they don't need to loop, but it's nice to have the movement of the character it's feet be registered with footstep keys.
 
 
 
====Attacks====
 
[[File:BearExampleAttackKeys.png|none]]
 
 
 
An attack animation needs to indicate when it would be connecting with it's target. We do this with a hit text key <br \>
 
To get a hit text key merely right click on the animation timeline and select hit out of the list. <br \>
 
 
 
When a hit text key gets executed it shows the impact numbers of the hit in game.<br \>
 
 
 
===My First Skill Animation===
 
 
 
Skill animations have a rather specific structure due to Divinity: Original Sin 2 being a turn based game. <br \>
 
This means that when a player is trying to decide where to use a skill the character already starts preparing the skill. Much like a still and walk a skill prepare needs to loop. <br \>
 
Additionally skill animations interact with the skill data. Once a character gets certain animations assigned it can execute skills that relly on those animations being present.<br \>
 
 
 
[[File:BearExampleCastKeys.png|none]]
 
 
 
Skills do relly on a few signals coming from the animations. The most common signal being '''cast''' on the cast animation. <br \>
 
When making animations for skills it's a good idea to look how the text keys are set on the an existing player character's their equivalent skill animations. <br \>
 
The cast signal usually functions like the hit text key on an attack. It's when the animation would be executing the action of the skill <br \>
 
To add a cast text key right click on the animaiton time line and select '''cast''' from the list.<br \>
 
 
 
In the case of the rush skill (this animation slot is used by the battering ram skill) there is also movement of the character involved in the attack. <br \>
 
To indicate where the movement happens in the animation you use '''move_start''' and '''move_end''' text keys.<br \>
 
To add a '''move_start''' or '''move_end''' text key right click on the animaiton time line and select '''move_start''' or '''move_end''' from the list.<br \>
 
 
 
===Testing character animations in game mode===
 
 
 
To test a character in the engine you'll need to make a character root template.In the root template panel add a new root template. <br \>
 
Set the type to character and fill in physics and visual resource with the character physics and model. <br \>
 
This creates the character from scratch. Preferable you find a creature that almost behaves like the creature you're making in the root templates and copy that. <br \>
 
To copy an existing root template and it's functions right click on the root you want to copy and select '''Create new from selected...'''. <br \>
 
In this window to root type is locked. Set the Visual resource and Physics resource just like you would with a new root template.. <br \>
 
 
 
[[File:BearExampleRoot.png|none]]
 
 
 
Put this newly made or copied root in an appropriate folder and then place it in your level. Open the side bar panel with the character in the level selected and check the '''Player''' checkbox. <br \>
 
Start game mode and open the remote console with CTRL+SHIFT+F11. <br \>
 
 
 
In the remote console type oe animtest ''<animation slot name>''. This should play the animation once.<br \>
 
To loop the animation type oe animtest ''<animation slot name>'' -1. <br \>
 
To end a loop test type oe animtest stop. <br \>
 
 
 
[[File:ExampleAnimTestConsole.png|none]]
 
 
 
{| class="wikitable"
 
|-
 
|'''For more information on:'''
 
|-
 
| The Remote Console: [[ReCon]]
 
|-
 
| Remote Console Commands: [[Command_list]]
 
|}
 
 
 
===But I want to have a humanoid player character!!!===
 
  
For player characters all the same principles apply. The main difference is that they need to support every weapon set type rather than just a few. <br \>
+
[[File:LarianLogo_Icon.png|32px]] <big><b>[[My First: Item Animation]]</b></big> <br \>
The basics remain the same. Every set will need an idle, move and attack set and skills depends on the animations the skill requires. <br \>  
+
[[File:LarianLogo_Icon.png|32px]] <big><b>[[My First: Character Animation]]</b></big>
Animations called via scripts can have their own unique slot names. The slot name determines the name for the script to play the animation.
 

Latest revision as of 11:18, 7 February 2018

Introduction

In this guide we're assuming that you're reusing an existing character and rig or an existing interactive item.
We're also assuming you've imported resources before in the editor.
We'll also mention the provided export tools throughout the guide.
We'll also refer to visual resources, animation sets and resources, the Side Bar and Root Templates.
For interactive items we'll mention use actions and how to set up a door and container
Finally we'll skim over how the remote console can help you test character animations

For more information on:
How to import a resource: My First Item
How to create a character: My First Character
How to create an interactive ttem: My First Interactable Item
How the export tools function: Maya Exporter Manual
An Animation Resource: Animation Resource Panel
An Animation Set: Animation Set Resource Panel
Visual Resources: Visual Resource Panel
Root Templates: My First: Root Template
The Sidebar: Sidebar
Use Actions: Use Actions
The Remote Console: ReCon
Remote Console Commands: Command List

In this guide we'll explain:

  • How your maya files should be structured down to the folder structure.
  • How to define animation data for the exporter.
  • How to export the resources.
  • What type of editor resources you'll be importing for animations.
  • How to use an animations set.
  • How to use a default animation set.
  • Example for a Door and how this logic also applies to a container.
  • Example for a Bear it's base animaiton set.
  • How to quickly test animations in the editor with the remote console.

Included in this guide are a couple of example files:

Door example files

Bear example files

My First animation

How do I structure my maya resources?

The bear file structure

When creating animations we make use of maya's ability to reference scenes.
We'll have a base file with the mesh and it's rig (Animals_Bear_ABC.ma) and a sister animation folder of the same name (Animals_Bear_ABC) containing the animation files.
Each animation file has only one animation or animation sequence and has a file reference to the base file. (More on sequences later)

A file containing the rig that gets referenced we name the base file
A file referencing the base file we name the animation file

Referencing in my animation file

When starting from a new animation file we'll want to reference the base file which contains the rig. The caveat for this is the MLE doesn't support namespaces in rigs.
In your new file: Top Menu -> File -> Create Reference -> Options Square

CreateRefOpt.png

In the options window look for Namespace Options
Select Use selected namespace as parent and add new namespace string and fill in a colon : in the textbox
Click reference and browse to your base file, select it and click reference. The base file contents should now appear in your scene

NamespaceCreateOpt.png

Save your animation file in the animation folder and name it: <item/characterName>_<AnimationSlotName>.
An animation slot name either refers to the name the animation will get in the engine when assigning it to a character it's Animation Waterfall or it's Visual Default Animations

For more information on:
An Animation Set: Animation_set_resource_panel
Visual Default Animations: Visual_resource_panel

Confirming the structure

To make sure that your file structure is correct open the base file.
Run the MLE script and check the animations checkbox.
If you did everything correctly the Animations List should show you animations in the Animation Folder

Alternatively open an animation file.
Run the MLE script. The Animation list should immediately be visible. A warning about missing Animation Manager Data is normal.

The MLE with animations listed

If neither of these cases check out make sure:

  • The animation folder has the same name as your base file.
  • The animation folder should be in the same folder as the base file.

Exporting the animation

With the current set up you can already export animations once they are made. Simply launch the MLE in the base file, check the animation checkbox select the relevant files and export.
From an animation file you can launch the MLE and press export right away.

By default the MLE will use the last saved timeline of an animation file to export the animation with.
However, it is possible to have multiple animations come out of a single file. It's also possible to make sure the same animation length is exported regardless of the current timeline.

For this purpose we use Animation Data.

Creating Animation Data for the exporter

To define Animation Data we use the animation manager script. This script writes data to the root of a rig as: name:AnimationName start:StartTime end:EndTime
This is also how the MLE will show the entries when in the animation file.

The animation manager supports multiple entries allowing us to define an animation sequence. A sequence is usually an animation that will concist of a start, loop and end segement.
The goal is to allow an animator to more easily set up animations that need to follow eachother up in game.

MayaExporter Animation.png

Example animation data for the knockdown animation of the bear.

When exporting from the base file the MLE will automatically export all the entries in the Animation Data as seperate animation files.
If you export a file containing the same Animation Data as the example image above you get the following files as a result:

KnockdownExportExample.png
For more information on:
The Animation Manager: Modding:_Maya_Exporter

Editor Resources

Once we've exported our resources it's time to import them into the editor.

Launch The Divinity Engine 2 and load in a mod and level. Open the content browser, select or create a correct package and add a resource.
Our animation files are in the same format as a model file (.lsm), but when importing in the editor we will be importing an Animation Resource.

AddAnimResource.png

If your animations are going to be shared across multiple character models with a similar rig then it's best to also create an Animation Set resource.
Again select or create a correct package and add a resource. This time create an Animation Set.<br\>

Warningred.png Reexporting animations while they are active in the editor can cause the editor to crash.

Animation Resource

An animation resource when just made will just contain the animation data. However, to have it interact with other game systems you can also add Text Keys to the Animation Resource
When you want the creature to use the existing sounds you'll have to add multiple text keys. If you want the player to be able to use weapons you'll need to tell the engine to switch it's weapon state from sheated to unsheated.
If certain animations need certain effects to play in conjunction a text key will help you do the job.

Read up on the animation resource in the technical documentation to get a fully in depth look into how these resources can be expanded with extra functions.
In this guide we'll cover a few basic cases and their require text keys.

Animation Set

To more easily share your animations across multiple models with the same rig you can plug your animations into an Animation Set resource.
As a rule for characters it's prefered to work with animation resources. You can also plug in multiple animation sets into a single visual.

For more information on:
How to import a resource: My_first:_Item
An Animation Resource: Animation_resource_panel
An Animation Set: Animation_set_resource_panel

In Depth Examples

LarianLogo Icon.png My First: Item Animation
LarianLogo Icon.png My First: Character Animation