Skip to content

Commit 813aaf7

Browse files
authored
Merge pull request #389 from VaclavElias/update-29-manual-model-node-example
feat: Example snippet added - Link entity to a bone, various content and styling updates
2 parents fdaf22c + 54f278f commit 813aaf7

18 files changed

Lines changed: 107 additions & 84 deletions

en/manual/animation/additive-animation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ You can use additive animations with animations that use the same skeleton and s
137137
* [Animation scripts](animation-scripts.md)
138138
* [Procedural animation](procedural-animation.md)
139139
* [Custom blend trees](custom-blend-trees.md)
140-
* [custom attributes](custom-attributes.md)
140+
* [Custom attributes](custom-attributes.md)

en/manual/animation/animation-scripts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@ You can also override the animation blend tree and do all animation blending in
110110
* [Procedural animation](procedural-animation.md)
111111
* [Custom blend trees](custom-blend-trees.md)
112112
* [Model node links](model-node-links.md)
113-
* [custom attributes](custom-attributes.md)
113+
* [Custom attributes](custom-attributes.md)

en/manual/animation/custom-blend-trees.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,4 @@ public class AnimationBlendTree : SyncScript, IBlendTreeBuilder
108108
* [Additive animation](additive-animation.md)
109109
* [Procedural animation](procedural-animation.md)
110110
* [Model node links](model-node-links.md)
111-
* [custom attributes](custom-attributes.md)
111+
* [Custom attributes](custom-attributes.md)

en/manual/animation/import-animations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ To use an animation asset, add an [AnimationComponent](xref:Stride.Engine.Animat
6363
* [Procedural animation](procedural-animation.md)
6464
* [Custom blend trees](custom-blend-trees.md)
6565
* [Model node links](model-node-links.md)
66-
* [custom attributes](custom-attributes.md)
66+
* [Custom attributes](custom-attributes.md)

en/manual/animation/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ The templates **First-person shooter**, **Third-person platformer** and **Top-do
5353
* [Procedural animation](procedural-animation.md)
5454
* [Custom blend trees](custom-blend-trees.md)
5555
* [Model node links](model-node-links.md)
56-
* [custom attributes](custom-attributes.md)
56+
* [Custom attributes](custom-attributes.md)

en/manual/animation/model-node-links.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ The **model node link** component attaches an entity to a node of a skeleton on
1010

1111
For example, imagine you have two models: a knight, and a sword. The character has a sword swinging animation. You can use a model link node to place the sword in the knight's hand and attach it to the correct node in the knight skeleton, so the sword swings with the knight animation.
1212

13-
<p>
13+
<div class="ratio ratio-16x9 mb-3">
1414
<video autoplay loop class="responsive-video" poster="../particles/tutorials/media/sword-slash-1.jpg">
1515
<source src="../particles/tutorials/media/sword-slash-1.mp4" type="video/mp4">
1616
</video>
17-
</p>
17+
</div>
1818

1919
## Set up a model node link component
2020

2121
1. In the **Scene Editor**, select the entity you want to link to a node in another entity.
22-
2322
2. In the **Property Grid**, click **Add component** and select **Model node link**.
2423

2524
![Add component](../particles/tutorials/media/add-model-node-link.png)
@@ -38,11 +37,11 @@ For example, imagine you have two models: a knight, and a sword. The character h
3837

3938
4. Select the model you want to link the entity to and click **OK**.
4039

41-
>[!Note]
42-
>The entity you link to must have a model with a skeleton, even if the model isn't visible at runtime.
40+
> [!Note]
41+
> The entity you link to must have a model with a skeleton, even if the model isn't visible at runtime.
4342
44-
>[!Tip]
45-
>If you don't specify a model, Stride links the entity to the model on the parent entity.
43+
> [!Tip]
44+
> If you don't specify a model, Stride links the entity to the model on the parent entity.
4645
4746
5. In **Node name**, select the node in the model you want to attach this entity to.
4847

@@ -58,8 +57,43 @@ To add an offset to the linked entity, use the entity's [TransformComponent](xre
5857

5958
![Transform](media/transform-component.png)
6059

61-
>[!Note]
62-
>If you don't want to add an offset, make sure the values are all set to `0,0,0`.
60+
> [!Note]
61+
> If you don't want to add an offset, make sure the values are all set to `0,0,0`.
62+
63+
## Example script
64+
65+
This script demonstrates how to link one entity (such as a `SwordModel`) to a specific bone (`weapon_bone_R`) in another entity's skeleton hierarchy (in this case, the `mannequinModel`) using Stride's `ModelNodeLinkComponent`.
66+
67+
```csharp
68+
public class BoneLink : StartupScript
69+
{
70+
// This example assumes you've created a project with the default Stride models
71+
// "mannequinModel" and "SwordModel." Add them from the "Assets/Models" folder to your scene,
72+
// and then attach this script to the "SwordModel" entity
73+
74+
ModelNodeLinkComponent boneLink;
75+
76+
public override void Start()
77+
{
78+
// Initialize the script
79+
// Here we locate the entity named "mannequinModel" by searching the root scene's entities
80+
Entity owner = SceneSystem.SceneInstance.RootScene.Entities.Where(e => e.Name == "mannequinModel").Single();
81+
82+
boneLink = new ModelNodeLinkComponent
83+
{
84+
// This is the ModelComponent on the target entity (mannequinModel)
85+
Target = owner.Get<ModelComponent>(),
86+
87+
// We set a "hard link" to Nodes[70], which corresponds to "weapon_bone_R"
88+
// in the target's skeleton hierarchy
89+
NodeName = owner.Get<ModelComponent>().Model.Skeleton.Nodes[70].Name
90+
};
91+
92+
// Finally, add this link component to our current (SwordModel) entity
93+
base.Entity.Components.Add(boneLink);
94+
}
95+
}
96+
```
6397

6498
## See also
6599

@@ -71,7 +105,7 @@ To add an offset to the linked entity, use the entity's [TransformComponent](xre
71105
* [Additive animation](additive-animation.md)
72106
* [Procedural animation](procedural-animation.md)
73107
* [Custom blend trees](custom-blend-trees.md)
74-
* [custom attributes](custom-attributes.md)
108+
* [Custom attributes](custom-attributes.md)
75109

76110
For examples of how model node links are used, see:
77111

en/manual/animation/preview-animations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ The animation preview uses the model selected in the **preview model** in the **
4848
* [Procedural animation](procedural-animation.md)
4949
* [Custom blend trees](custom-blend-trees.md)
5050
* [Model node links](model-node-links.md)
51-
* [custom attributes](custom-attributes.md)
51+
* [Custom attributes](custom-attributes.md)

en/manual/animation/procedural-animation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,4 @@ public class AnimationLight : StartupScript
139139
* [Additive animation](additive-animation.md)
140140
* [Custom blend trees](custom-blend-trees.md)
141141
* [Model node links](model-node-links.md)
142-
* [custom attributes](custom-attributes.md)
142+
* [Custom attributes](custom-attributes.md)

en/manual/animation/set-up-animations.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ After you add animations to an entity, you need to play them with a [script](../
5555
### Example script
5656

5757
```cs
58-
public class SimpleAnimationScript : StartupScript
58+
public class SimpleAnimationScript : StartupScript
59+
{
60+
public override void Start()
5961
{
60-
public override void Start()
61-
{
62-
Entity.Get<AnimationComponent>().Play("Walk");
63-
}
62+
Entity.Get<AnimationComponent>().Play("Walk");
6463
}
64+
}
6565
```
6666

6767
This script looks for an animation with the name *Walk* under the animation component on the entity.
@@ -93,4 +93,4 @@ Game Studio adds the script as a component. You can adjust [public variables you
9393
* [Procedural animation](procedural-animation.md)
9494
* [Custom blend trees](custom-blend-trees.md)
9595
* [Model node links](model-node-links.md)
96-
* [custom attributes](custom-attributes.md)
96+
* [Custom attributes](custom-attributes.md)

en/manual/files-and-folders/distribute-a-game.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,40 +54,36 @@ When you're ready to publish your game, create a release build from Visual Studi
5454
### To build using terminal instead of Visual Studio
5555

5656
1. Ensure the relevant .NET SDK is installed (Stride 4.2 is on .NET 8)
57-
2. open the folder of your project where the *.Windows.csproj file sits.
57+
2. Open the folder of your project where the `*.Windows.csproj` file sits.
5858

5959
![Project Folder](media/project-folder.png)
6060

6161
3. Type `cmd` in the search bar to open the folder easily in terminal.
6262

6363
![Open terminal](media/open-terminal.png)
6464

65-
4. finally publish with the command
65+
4. Finally publish with the command
6666

67-
```
68-
dotnet publish
69-
```
67+
```
68+
dotnet publish
69+
```
7070
71-
or the below to include the .NET runtime with your game
71+
or the below to include the .NET runtime with your game
7272
73-
```
74-
dotnet publish -r win-x64 --self-contained true --framework net8.0-windows
75-
```
73+
```
74+
dotnet publish -r win-x64 --self-contained true -- framework net8.0-windows
75+
```
7676
77-
You can also append `--output <YOUR_EXPORT_FOLDER>` to specify where to export to.
77+
You can also append `--output <YOUR_EXPORT_FOLDER>` to specify where to export to.
7878
7979
## 2. Delete unnecessary files
8080
8181
In the release folder in your project bin folder (eg *MyGame/Bin/MyPlatform/Release*), you can delete the following unnecessary files:
8282
8383
* `.pdb` files (debug information)
84-
8584
* `.xml` files (API documentation)
86-
8785
* files that contain `vshost` in their filenames (eg `MyGame5.vshost.exe` and `MyGame5.vshost.exe.manifest`)
88-
8986
* folders other than the `x64`, `x86`, or `data` folders
90-
9187
* other unnecessary files, such as custom configuration files (ie files not created with Stride)
9288
9389
## 3. Distribute your game
@@ -97,15 +93,12 @@ After you create a release build, how you distribute it is up to you.
9793
To run games made with Stride on Windows, users need:
9894
9995
* .NET 8 Runtime (Unless you published with **self-contained**)
100-
10196
* DirectX11 (included with Windows 10 and later), OpenGL, or Vulkan
102-
10397
* Visual C++ 2015 runtimes (x86 and/or x64, depending on what you set in your project properties in Visual Studio)
10498
10599
## See also
106100
107101
* [Add or remove a platform](../platforms/add-or-remove-a-platform.md)
108102
* [Version control](version-control.md)
109103
* [Project structure](project-structure.md)
110-
111104
* [Microsoft documentation](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish)

0 commit comments

Comments
 (0)