Browse Source

Merge branch 'stride3d:master' into master

Vaclav Elias 1 year ago
parent
commit
90f02df266

+ 115 - 0
en/manual/physics/fix-physics-jitter.md

@@ -0,0 +1,115 @@
+# Fix Physics Jitter
+
+<span class="badge text-bg-primary">Beginner</span>
+<span class="badge text-bg-success">Programmer</span>
+
+In Stride there is no default smoothing applied to Entities that are attached to physics entities. This can cause a noticable jitter especially if you have the camera attached to a character component.
+In this tutorial we will look at whats needed to add smoothing to an entity through a SyncScript.
+
+>[!Note]
+>You can also decrease the `Fixed Time Step` in the physics configuration, for example change it from `0.016667` to `0.008` for more accurate physics but this will be more expensive on the CPU.
+
+## Code to handle smoothing between 2 entities
+This should be all thats needed to attach 2 entities together. Make sure that you unparent the entity you are trying to smooth or else the transofrm processor will override this script.
+```cs
+[ComponentCategory("Utils")]
+[DataContract("SmoothFollowAndRotate")]
+public class SmoothFollowAndRotate : SyncScript
+{
+	public Entity EntityToFollow { get; set; }
+	public float Speed { get; set; } = 1;
+
+	public override void Update()
+	{
+		var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
+		var currentPosition = Entity.Transform.Position;
+		var currentRotation = Entity.Transform.Rotation;
+
+		var lerpSpeed = 1f - MathF.Exp(-Speed * deltaTime);
+
+		EntityToFollow.Transform.GetWorldTransformation(out var otherPosition, out var otherRotation, out var _);
+
+		var newPosition = Vector3.Lerp(currentPosition, otherPosition, lerpSpeed);
+		Entity.Transform.Position = newPosition;
+
+		Quaternion.Slerp(ref currentRotation, ref otherRotation, lerpSpeed, out var newRotation);
+		Entity.Transform.Rotation = newRotation;
+	}
+}
+```
+
+## Example Usage
+For this example we will modify the First Person Shooter Template.
+
+Step 1: Detach the camera from the Physics entity
+
+Step 2: Remove the FPS camera script from the camera
+
+Step 3: create a new entity as a child to the character body
+
+Step 4: Add the FPS script to the new entity
+
+Step 5: change the following code since they reference the CameraComponent directly
+
+### PlayerInput.cs
+change
+```cs
+public CameraComponent Camera { get; set; }
+```
+to
+```cs
+public Entity Camera { get; set; }
+```
+
+---
+
+### Utils.cs
+change
+```cs
+CameraComponent camera
+```
+to
+```cs
+Entity camera,
+```
+and change
+```cs
+camera.Update();
+var inverseView = Matrix.Invert(camera.ViewMatrix);
+```
+to
+`var inverseView = camera.Transform.WorldMatrix;`
+
+---
+
+### FpsCamera.cs
+Remove
+```cs
+
+        /// <summary>
+        /// Gets the camera component used to visualized the scene.
+        /// </summary>
+        private Entity Component;
+```
+and change
+```cs
+        private void UpdateViewMatrix()
+        {
+            var camera = Component;
+            if (camera == null) return;
+            var rotation = Quaternion.RotationYawPitchRoll(Yaw, Pitch, 0);
+
+            Entity.Transform.Rotation = rotation;
+        }
+```
+to 
+```cs
+private void UpdateViewMatrix()
+{
+    var rotation = Quaternion.RotationYawPitchRoll(Yaw, Pitch, 0);
+
+    Entity.Transform.Rotation = rotation;
+}
+```
+
+That should be all thats needed to see the smoothing in action as a before and after. You can see the original issue in the Stride Github [here](https://github.com/stride3d/stride/issues/2216) if you need to find more info on the problem.

+ 12 - 12
en/manual/platforms/linux/setup-and-requirements.md

@@ -1,8 +1,8 @@
 # Setup and requirements
 
-To develop for Linux using Stride, you need a Linux PC with a graphics card that supports at least OpenGL 4.2 or Vulkan 1.0. The preferred Linux distribution for Stride is Ubuntu 16.04 or later, as this was the setup we used to develop the Linux version of Stride.
+To develop for Linux using Stride, you need a Linux PC with a graphics card that supports at least OpenGL 4.2 or Vulkan 1.0. The preferred Linux distribution for Stride is Debian 12 or later, as this was the setup we used to develop the Linux version of Stride.
 
-The instructions below assume you have Ubuntu 16.04 installed. You might need to adapt them according to your Linux distribution.
+The instructions below assume you have Debian 12 installed.
 
 You will also need a Windows PC to build your projects for Linux using Game Studio.
 
@@ -13,16 +13,16 @@ You need the following packages:
 * [FreeType](#freetype)
 * [OpenAL](#openal)
 * [SDL2](#sdl2)
-* either Mono or .NET Core (it's OK to install both)
+* [Latest .NET](https://dotnet.microsoft.com/en-us/download)
 
 ## FreeType
 
 To render fonts, we use the [FreeType](https://www.freetype.org/) library. The minimum required version is 2.6 and can be installed via:
 
-### [Ubuntu](#tab/freetype-ubuntu)
+### [Debian / Ubuntu](#tab/freetype-ubuntu)
 
 ```bash
-sudo apt-get install libfreetype6-dev
+sudo apt install libfreetype6-dev
 ```
 
 ### [Fedora](#tab/freetype-fedora)
@@ -43,10 +43,10 @@ sudo pacman -S freetype2
 
 To play sounds and music, we use the [OpenAL](https://www.openal.org/) library. It can be installed via:
 
-### [Ubuntu](#tab/openal-ubuntu)
+### [Debian / Ubuntu](#tab/openal-ubuntu)
 
 ```bash
-sudo apt-get install libopenal-dev
+sudo apt install libopenal-dev
 ```
 
 ### [Fedora](#tab/openal-fedora)
@@ -67,10 +67,10 @@ sudo pacman -S openal
 
 To run games on Linux, we use the [SDL2](https://www.libsdl.org/) library which provides the ability to create windows, handle mouse, keyboard and joystick events. The minimum required version is 2.0.4 and can be installed via:
 
-### [Ubuntu](#tab/sdl2-ubuntu)
+### [Debian / Ubuntu](#tab/sdl2-ubuntu)
 
 ```bash
-sudo apt-get install libsdl2-dev
+sudo apt install libsdl2-dev
 ```
 
 ### [Fedora](#tab/sdl2-fedora)
@@ -87,11 +87,11 @@ sudo pacman -S sdl2
 
 ---
 
-## .NET Core
+## .NET
 
-For information about how to install .NET Core, see the [.NET Core instructions for Linux](https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites).
+For information about how to install .NET, see the [.NET instructions for Linux](https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites).
 
-Make sure version 2.1.300+ and runtime 2.1+ is installed. To check which version you have installed, type:
+We recommend to install .NET 8. To check which version you have installed, type:
 
 ```
 dotnet --info