-
Notifications
You must be signed in to change notification settings - Fork 46
1.1 Getting Started: The Basics
- URP or HDRP installed on your Unity project
- ShaderGraph installed o your project
- Installed DMotion
Go to Window -> Package Manager
select Packages: In Project
in the dropdown, click the DMotion
package, and import the samples
You'll see a new folder on Samples/DMotion
. There are multiple samples there which we will go over in detail. For now, Open the scene named DMotion - Basic - Play Single Clip
under All Samples/1 - Basics/1 - Play Single Clip
.
Hit play and see the cool robot walking in a loop :)
Of course, you probably want to know what is happening in this scene. So let's explore the setup in the next section...
In order for a Skeletal Mesh to work with DMotion, it needs some setup. Go to All Samples/Common/Art/Models/LowPolyRobot
and select LowPolyRobot.fbx
. You will notice it has the following import settings:
- Model tab:
- (Required):
Read/Write
enabled
- (Required):
- Rig tab:
- (Recommended)
Optimized Game Objects
enabled - (Recommended for Humanoid clips):
Animation Type
set to Humanoid
- (Recommended)
- Animation Tab:
- (Recommended) Set
Anim. Compression
toOff
- (Recommended) Set
Why turn off Anim. Compression?
DMotion uses a custom compression algorithm provided by Kinemation. If it reads from Unity’s lossy-compressed clips, quality will be significantly reduced without any benefit.After you've done a similar setup with your Model, it should be ready to be used with DMotion.
DMotion currently used Kinemation low level framewok for Animation sampling and skinning. This framework requires a Latios Bootstrap to be added to your project.
This is already set up for you under All Samples/Common/Scripts/LatiosBootstrap.cs
, so unless you are using a custom bootstrap, you don't need to do anything else. Just make sure to move LatiosBootstrap.cs
to another folder in your project if you sant to delete the Samples folders.
DMotion uses a custom scriptable object for defining Animation clips, which has more features than Unity's AnimationClip. You can create a AnimationClipAsset
by going to Create -> DMotion -> Clip
If you select 1 - Play Single Clip/1.1_PlaySingleClip_Walk.asset
, you will see the AnimationClipAsset we're using in this sample. Below it's a brief explanation of the asset's properties:
Property | Definition |
---|---|
Preview Object | Editor-only preview mesh. Used for previewing the selected clip |
Clip |
AnimationClip to be played |
Events | List of AnimationClipEvent for this clip. See this page for more information on Animation Events. |
Now, let's go back to the DMotion - Basic - Play Single Clip
scene in Unity. If you select the LowPolyRobot
game object in the hierarchy, you'll see the a component called PlayClipAuthoring
This component is provided by DMotion, and it's the only thing you need if all you want is o play a single clip in an object (of course, we will do much cooler things in the following sections). For now, here's a description of it's properties:
Property | Definition |
---|---|
Owner | Owner of the animated object. Useful when your logical GameObject and the GameObject being animated are different. Otherwise, it should be the same GameObject containing the Animator omponent |
Animator | Object containing the Animator component |
Clip | Clip to be played (with speed and loop options) |
RootMotionMode | Option for RootMotion handling. See this page for more information on automatic root motion |
Enable Events | Whether AnimationClipEvents should be enabled |
Enable Single Clip Requests | Whether to enable other clips to be requested via code. See this documentation page for more information. |
This section explained how to setup a model for DMotion, and how to play a clip without writing any code. In the next section you'll learn about Animation Events.