Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions en/manual/game-studio/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,3 @@ The **Asset view** (4) displays the project assets. You can create new assets us
The **Asset preview** tab (5) displays a preview of the selected asset. The preview changes based on the type of the asset you have selected. For example, you can play animations and sounds. This is a quick way to check changes to an asset when editing it in the Property grid. By default, the Asset preview is in the bottom right.

You can show and hide different parts of the Game Studio in the View menu. You can also resize and move parts of the UI.

## In this section

* [World units](world-units.md)
14 changes: 3 additions & 11 deletions en/manual/game-studio/world-units.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# World units

In Stride, one unit is one meter. This is used by the physics and rendering engines.

Game Studio displays units as a grid.

![Grid in Scene editor](media/scene-creation-basic-scene-in-stride.png)

## See also

* [Physics](../physics/index.md)
---
redirect_url: ../scenes/entities/transform/world-units.html
---
7 changes: 3 additions & 4 deletions en/manual/glossary/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,12 @@
- [Property grid](../game-studio/index.md): Panel used to view and edit properties of selected entities/components.
- [Splash screen](../files-and-folders/game-settings/splash-screen.md): Configure startup visuals.
- [Use assets](../assets/use-an-asset.md): Reference and place assets in scenes.
- [World units](../game-studio/world-units.md): Scene scale conventions (unit size, conversions).

## General terms

- [ECS (Entity Component System)](../engine/entity-component-system/index.md): The architecture where entities host components and systems process them.
- [Entity](../engine/entity-component-system/index.md): An object in the scene that can represent anything from a 3D model to a camera or light and aggregates multiple components.
- [Entity component](../engine/entity-component-system/index.md): A piece of data/behavior attached to an entity (for example Transform, Model, Light).
- [Game](https://doc.stride3d.net/latest/en/api/Stride.Engine.Game.html): A Stride application or interactive experience running the game loop.
- [Game loop](https://en.wikipedia.org/wiki/Video_game_programming#Game_structure): The main loop that updates and renders the game each frame.
- [Transform](../../tutorials/csharpbeginner/transform-position.md): Defines an entity's position, rotation, and scale in the scene.

## Graphics terms

Expand Down Expand Up @@ -188,6 +184,9 @@

- [Scene](../scenes/index.md): A loadable portion of a game containing world data (e.g. models, lights, character controllers).
- [Sub-scene](../scenes/sub-scenes.md): A scene that is a child of a different scene.
- [Entity](../scenes/entities/index.md): An element of a scene containing components which are used to define what it is, how it looks and what it does.
- [Component](../scenes/entities/components.md): A piece of code that can be attached to an entity. Components contain their own data, can execute their own code or be used by other components or processors.
- [Transform](../scenes/entities/transform/index.md): A component that defines an entity's position, rotation and scale.
- [Prefab](../scenes/prefabs/index.md): A reusable entity template that can be used for creating elements of a game that keep in-sync with the original or used for instantiating at runtime.
- [Nested prefab](../scenes/prefabs/nested-prefabs.md): A prefab which is added as a child entity of another prefab.
- [Prefab models](../scenes/prefabs/prefab-models.md): A model created from a prefab.
Expand Down
2 changes: 1 addition & 1 deletion en/manual/graphics/lights-and-shadows/point-lights.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Once selected, the point light gizmo displays the sphere in which it projects li
| Property | Description
| ------------------- | ------------------
| Color | The color of the light (RGB)
| Radius | The sphere influence radius in [world units](../../game-studio/world-units.md). Beyond this range, the light doesn't affect models
| Radius | The sphere influence radius in [world units](../../scenes/entities/transform/world-units.md). Beyond this range, the light doesn't affect models
| Shadow | <p><br>If shadows are enabled, the light casts shadows.</p></br><p><br> **Filter:** Produces soft shadows instead of hard shadows via PCF (Percentage Closer Filtering) </p></br> <p><br>**Size:** The size of texture to use for shadowing mapping. Larger textures produce better shadows edges, but are much more costly. For more information, see [Shadows](shadows.md)</p></br>
| Bias Parameters | <p><br>These parameters are used to avoid some artifacts of the shadow map technique.</p></br> <p><br>**Depth Bias:** The amount of depth to add to the sampling depth to avoid shadow acne</p></br> <p><br>**Normal Offset Scale**: A factor multiplied by the depth bias toward the normal </p></br>
| Intensity | The intensity of the light. The color is multiplied by this value before being sent to the shader. Note: negative values produce darkness and have unpredictable effects
Expand Down
2 changes: 1 addition & 1 deletion en/manual/graphics/lights-and-shadows/spot-lights.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Once selected, the gizmo of the spot light displays its main direction, range an
| Property | Description
| ------------------- | -----------
| Color | The color of the light (RGB)
| Range | The range in [world units](../../game-studio/world-units.md). Beyond the this range, the light doesn't affect models.
| Range | The range in [world units](../../scenes/entities/transform/world-units.md). Beyond the this range, the light doesn't affect models.
| Angle Inner | The inner angle of the spot cone where the light intensity influence is at one
| Angle Outer | The outer angle of the spot cone where the light intensity influence is zero
| Shadows | <p><br> Cast shadows</p></br><p><br>**Filter**: Produces soft shadows instead of hard shadows via PCF (Percentage Closer Filtering) </p></br> <p><br>**Size**: The size of texture to use for shadowing mapping. Larger textures produce better shadows edges, but are much more costly. For more information, see [Shadows](shadows.md)</p></br> <p><br>For spot lights, the default value is **medium**, as a spot light has usually a medium visual impact</p></br>
Expand Down
2 changes: 1 addition & 1 deletion en/manual/graphics/materials/subsurface-scattering.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The shadows are much softer in the second image, as more light passes through th

| Property | Function
|--------------------|--------------------
| Scattering width | How far the light scatters in [world units](../../game-studio/world-units.md)
| Scattering width | How far the light scatters in [world units](../../scenes/entities/transform/world-units.md)
| Translucency | How much light pentrates the material. `0.0` is no translucency; `1.0` is max.
| Translucency map | Specify a [grayscale map](material-maps.md) to control how translucent different regions of the material are. Brighter values produce more scattering. For example, ears should scatter more light than the top of the head, because they're thinner and therefore light passes through them more easily. The texture is multiplied by the **Translucency** parameter.
| Scattering profile | The scattering profile to use during the forward render pass. <p><br>**Skin:** A preconfigured shader for rendering skin <p><br>**Custom (skin-based):** A profile based on the Skin profile you can customize yourself
Expand Down
2 changes: 1 addition & 1 deletion en/manual/particles/create-particles.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ With a particle system entity selected, you can edit its properties in the **Pro
| Editor control | This changes how Game Studio displays particles while you work on the scene. You can play, pause, and stop the particle system. You can also reset the particle effect at set intervals, which is useful for previewing one-shot effects. The editor controls don't affect how particles are displayed at runtime.
| Warm-up time | If you set the warm-up time to a value greater than 0, the particle appears as if it's already active when it appears. This value is in seconds. For example, if you set the warm-up time to 1, the particle effect appears as if it has already been active for 1 second when it appears. This is useful, for example, if you set a fire effect warm-up time to 0, the fire appears to ignite as soon as it's rendered. If you want the fire to appear as if it's already ignited when it's rendered, increase the warm-up time.
| Speed scale | Controls the speed of the particle effect.
| Culling AABB | This creates an axis-aligned bounding box (AABB) around the particle effect. If the bounding box isn't in the camera view, Stride doesn't render the particle effect. This is useful for culling and optimization. **Rotated AABB** sets box shape in XYZ co-ordinates. **Uniform AABB** creates a cube of the scale you specify (in [world units](../game-studio/world-units.md)). To view the AABB in the Scene editor, select **Debug Draw**.
| Culling AABB | This creates an axis-aligned bounding box (AABB) around the particle effect. If the bounding box isn't in the camera view, Stride doesn't render the particle effect. This is useful for culling and optimization. **Rotated AABB** sets box shape in XYZ co-ordinates. **Uniform AABB** creates a cube of the scale you specify (in [world units](../scenes/entities/transform/world-units.md)). To view the AABB in the Scene editor, select **Debug Draw**.
| Emitters | The emitters the particle system contains. The emitters are updated and drawn in the order they appear in the list, and can be re-ordered. For more information, see [Emitters](emitters.md).

## See also
Expand Down
2 changes: 1 addition & 1 deletion en/manual/particles/ribbons-and-trails.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Unlike billboards, which are individual quads, ribbons and trails have a single

![Stretched texture mapping](media/particles-diagram-stretched.png)

* **DistanceBased**: The texture is repeated based on the actual world length of the ribbon or trail rather than the number of particles. The **UV Factor** defines the distance in [world units](../game-studio/world-units.md) after which the texture repeats
* **DistanceBased**: The texture is repeated based on the actual world length of the ribbon or trail rather than the number of particles. The **UV Factor** defines the distance in [world units](../scenes/entities/transform/world-units.md) after which the texture repeats

![Distance-based texture mapping](media/particles-diagram-distancebased.png)

Expand Down
2 changes: 1 addition & 1 deletion en/manual/physics-bullet/simulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You can change how Stride initializes the [simulation](xref:Stride.Physics.Simul

At runtime, you can change some [Simulation](xref:Stride.Physics.Simulation) parameters:

* `Gravity` — the global gravity, in [world units](../game-studio/world-units.md) per second squared
* `Gravity` — the global gravity, in [world units](../scenes/entities/transform/world-units.md) per second squared
* `FixedTimeStep` — the length of a simulation timestep, in seconds
* `MaxSubSteps` — the maximum number of fixed timesteps the engine takes per update

Expand Down
2 changes: 2 additions & 0 deletions en/manual/scenes/edit-a-scene.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ The **Property grid** displays a list of properties of the selected entities. It

![](../game-studio/panels/media/property-grid.webp)

For more information about components, visit [Components](entities/components.md).

## Transforming entities

The **Viewport** displays a transformation gizmo next to selected entities. You can use it to move, rotate and scale objects in a visual way by clicking on a part of the gizmo and dragging it.
Expand Down
80 changes: 80 additions & 0 deletions en/manual/scenes/entities/components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Components

<span class="badge text-bg-primary">Beginner</span>
<span class="badge text-bg-success">Designer</span>
<span class="badge text-bg-success">Programmer</span>

Every entity has a list of **components** that define what the entity is, how it looks and how it behaves.

## Create a new component

Stride allows you to create your own components with scripts. For more information, visit [Scripts](../../scripts/index.md).

## Add a component in Game Studio

1. Select an entity in the **Entity tree**. This will make your entity's components show up in the **Property grid**.

![](media/view-components.webp)

2. Press the **➕ Add component** button located at the top and select a component.

![](media/add-component.webp)

## Manage components in code

When coding in Stride, you are given full control over components in entities.

To add a component use [`Entity.Add`](xref:Stride.Engine.Entity.Add*).

```csharp
var myComponent = new MyComponent();
Entity.Add(myComponent);
```

To get a component use [`Entity.Get`](xref:Stride.Engine.Entity.Get*), [`Entity.GetAll`](xref:Stride.Engine.Entity.GetAll*) or [`Entity.GetOrCreate`](xref:Stride.Engine.Entity.GetOrCreate*).

```csharp
// Get a single component
var component = Entity.Get<MyComponent>();
// Get all components
var component = Entity.GetAll<MyComponent>();
// Add a new component if it doesn't exist and then get it
var component = Entity.GetOrCreate<MyComponent>();
```

> [!WARNING]
> It's recommended to avoid getting components directly through code and instead, creating a property to assign them in the **Property grid**.

You can iterate over all components of an entity.

```csharp
foreach (var item in Entity)
{
if (item is MyComponent component)
{
// Your code here
}
}
```

You can access or modify properties and fields or call methods of any component.

```csharp
component.SomeProperty = "New value";
component.DoSomething();
```

To remove a component, use [`Entity.Remove`](xref:Stride.Engine.Entity.Remove*) or [`Entity.RemoveAll`](xref:Stride.Engine.Entity.RemoveAll*).

```csharp
// Remove a specific component
Entity.Remove(component);
// Remove the first component of type
Entity.Remove<MyComponent>();
// Remove all component of type
Entity.RemoveAll<MyComponent>();
```

## See also

* [Scripts](../../scripts/index.md).
75 changes: 75 additions & 0 deletions en/manual/scenes/entities/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Entities

<span class="badge text-bg-primary">Beginner</span>
<span class="badge text-bg-success">Designer</span>
<span class="badge text-bg-success">Programmer</span>

**Entities** are game elements containing a collection of [components](components.md) that define what they are and how they behave (e.g. [model component](xref:Stride.Engine.ModelComponent)).

Entities can have **child entities** with their own components.

![](media/nesting-entities.webp)

Every entity has a [transform component](xref:Stride.Engine.TransformComponent) that defines how it's positioned in relation to its parent.

## Create an entity in Game Studio

You can open the entity creation menu by pressing the ➕ icon at the top of the **Entity tree** or right clicking anywhere in the **Scene editor**. Here, you can select from one of the entity templates or create an empty entity.

![](media/create-an-entity.webp)

## Entities in code

Entities can be instantiated from a [prefab](../prefabs/index.md), or created at runtime from scratch like so:

```csharp
// Create a blank entity
var myNewEntity = new Entity("Entity name");

// Create an entity with components
var myNewLightEntity = new Entity("Entity name")
{
new LightComponent(),
new MyScript()
}
```

These entities exist **outside of the game world** in an inactive state — none of their scripts are doing anything. To change this, they have to be either:

* Assigned a scene:

```csharp
myNewEntity.Scene = MyScene;
```

* Added as a child of a scene:

```csharp
MyScene.Children.Add(myNewEntity);
```

* Assigned a parent:

```csharp
myNewEntity.Transform.Parent = myParent;
```

* Added as a child of an entity:

```csharp
MyEntity.Transform.Children.Add(myNewEntity);
```

To remove an entity, simply set their scene to `null`.

```csharp
entityToRemove.Scene = null;
```

## In this section

* [Components](components.md)
* [Transform](transform/index.md)
* [Types of rotation](transform/types-of-rotation.md)
* [Local and world matrix](transform/local-and-world-matrix.md)
* [World units](transform/world-units.md)
3 changes: 3 additions & 0 deletions en/manual/scenes/entities/media/add-component.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions en/manual/scenes/entities/media/create-an-entity.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions en/manual/scenes/entities/media/nesting-entities.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions en/manual/scenes/entities/media/view-components.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions en/manual/scenes/entities/transform/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Transform

<span class="badge text-bg-primary">Beginner</span>
<span class="badge text-bg-success">Designer</span>
<span class="badge text-bg-success">Programmer</span>

The [transform component](xref:Stride.Engine.TransformComponent) exists on every entity in Stride. It defines the **position**, **rotation** and **scale** of an entity in the world, relative to its parent.

## Local and world

An entity's transform is **relative to its parent**. This means that the parent transform creates a sort of isolated world for its children.

For example: if two entities are 1m apart from each other and the parent's scale is set to 20, those entities will in reality be spaced 20m from each other.

![](media/local-and-world.webp)

Values relative to their parent are referred to as **local-space** and the "real world" ones as **world-space**.

Typically, **we work with values from the local-space**, but sometimes, when accessing entities nested in other entities, we might have to use their **world** values.

## Get or set position, rotation and scale

Position, rotation, euler angles and scale can be accessed from `Position`, `Rotation`, `RotationXYZ` and `Scale` respectively.

```csharp
// Getting values
var position = Entity.Transform.Position;
var rotation = Entity.Transform.Rotation;
var eulerAngles = Entity.Transform.RotationXYZ;
var scale = Entity.Transform.Scale;

// Setting values
Entity.Transform.Position = Vector3.Zero;
Entity.Transform.Rotation = Quaternion.Identity;
Entity.Transform.EulerAngles = Vector3.Zero;
Entity.Transform.Scale = Vector3.One;
```

## Get or set world position, rotation and scale

There are many utilities for managing world values. Most of them involve the **world matrix**, which needs to be updated before anything is done with it.

To get the world transformation, you can use `GetWorldTransformation`.

```csharp
Entity.Transform.UpdateWorldMatrix();
Entity.Transform.GetWorldTransformation(out var position, out var rotation, out var scale);

// Get yaw pitch roll
rotation.YawPitchRoll(out var yaw, out var pitch, out var yaw);

// Get euler angles (notice the order)
var eulerAngles = new Vector3(pitch, yaw, roll);
```

> [!WARNING]
> The world scale may be inaccurate due to the nature of how it's represented (more about that later).

To set the world position and/or rotation, you can use `SetWorld`.

```csharp
var worldPosition = Vector3.Zero;
var worldRotation = Quaternion.Identity;

Entity.Transform.UpdateWorldMatrix();
Entity.Transform.SetWorld(worldPosition, worldRotation);
```

As mentioned previously, the world scale may not be what you expect it to be. In certain configurations of rotations and uneven scales, you can achieve scale modifications which are **impossible to represent in a standard `Vector3`**.

![](media/impossible-world-scale.webp)

However **if you're using even scales** (meaning that `X`, `Y` and `Z` are set to the same value) for the entity and its parents, then you can set the world scale by modifying the local scale to your desired value, demodulated by the parent world scale.

```csharp
var lossyWorldScale = new Vector3(1f, 1f, 1f);

// Updating your own world matrix will also update all parents
Entity.Transform.UpdateWorldMatrix();

if (Entity.Transform.Parent == null)
{
// Local scale is world scale if the entity has no parents
Entity.Transform.Scale = worldScale;
}
else
{
Entity.Transform.Scale = Vector3.Demodulate(worldScale, Entity.Transform.Parent.WorldMatrix.ScaleVector);
}
```

## See also

* [Entities](../index.md)
* [Local and world matrix](local-and-world-matrix.md)
Loading