Browse Source

Physics Update

Eideren 1 year ago
parent
commit
d8f402ab8d

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

@@ -29,6 +29,8 @@ Here's everything that may prevent those objects from moving smoothly:
 - You are setting the entity's position/rotation instead of the physics object's `LinearVelocity`/`AngularVelocity`
 - Your objects are not `Awake`
 
+Lastly, maybe consider using a [Constraint](constraints.md) instead.
+
 ## See also
 
 * [Simulation](simulation.md)

+ 1 - 1
en/manual/physics/index.md

@@ -17,7 +17,7 @@ This section explains how physics components work, how to add them to your proje
     * [Bodies](rigid-bodies.md): Objects that can be knocked around, cans, balls, boxes ...
     * [Characters](characters.md): Entities which are moved programmatically, the player character, animals, moving platforms ...
 * [Collider Shapes](collider-shapes.md): Define the geometric shape of yours collidable components
-* [Constraints](constraints.md): Create appealing and realistic physics
+* [Constraints](constraints.md): Join physics objects together, constrain them around points.
 * [Triggers](triggers.md): Use triggers to detect passing objects
 * [Physics Queries](raycasting.md): Operations to find objects in the scene
 * [Physics Update](physics-update.md): Updating logic alongside physics

+ 38 - 4
en/manual/physics/physics-update.md

@@ -1,7 +1,41 @@
 # Physics Update
 
-> [!WARNING]
-> WIP
-
 <span class="badge text-bg-primary">Beginner</span>
-<span class="badge text-bg-success">Programmer</span>
+<span class="badge text-bg-success">Programmer</span>
+
+When you need your logic to interact, query or otherwise modify the state of a simulation, you may need to do so right before or after physics updates. You can implement the `ISimulationUpdate` interface in your EntityComponent or Scripts to be notified of when simulation updates.
+
+```cs
+using System;
+using Stride.BepuPhysics;
+using Stride.BepuPhysics.Components;
+using Stride.Engine;
+
+public class MyPhysicsComponent : SyncScript, ISimulationUpdate
+{
+    public override void Update()
+    {
+        // Here you would call stuff you need to do every frame
+    }
+
+    public void SimulationUpdate(BepuSimulation simulation, float simTimeStep)
+    {
+        // Here is for stuff you need to do right before physics runs, 
+        // sample player input, setting body velocities, etc.
+    }
+
+    public void AfterSimulationUpdate(BepuSimulation simulation, float simTimeStep)
+    {
+        // Here is for stuff you need to check right after physics ran, 
+        // check if an object collided with anything, if it's on the ground, 
+        // if it failed to increase in height when jumping, etc.
+    }
+}
+```
+
+## See also
+
+* [Character](characters.md)
+* [Physics Jitter](fix-physics-jitter.md)
+* [Body](rigid-bodies.md)
+* [Index](index.md)