stride3d / stride3d/stride-docs

Document `PostTick` and `PreTick` for Simulation

Open
#342 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
39
Forks
74
Avg merge
3h 36m
Merged PRs (30d)
2

Description

We should add a section to the Physics manual to show how to subscribe to the physics tick events in order to mimic what people are used to for FixedUpdate.

Example:

using Stride.Engine;
using Stride.Physics;

public class FixedUpdate : StartupScript
{
	public override void Start()
	{
		var sim = this.GetSimulation();
		sim.PreTick += Sim_PreTick;
		sim.PostTick += Sim_PostTick;
	}

	private void Sim_PreTick(Simulation sender, float tick)
	{
		// Run before the Simulation is updated
	}

	private void Sim_PostTick(Simulation sender, float tick)
	{
		// Run after the Simulation is updated
	}

	public override void Cancel()
	{
		var sim = this.GetSimulation();
		sim.PreTick -= Sim_PreTick;
		sim.PostTick -= Sim_PostTick;
	}
}

This should be a pretty simple manual page I think but we should also add it to the Stride for Unity® developers somewhere that would mention FixedUpdate from Unity.

more things to think about:

  • The Bepu physics implementation does not have these events. This will be a Bullet physics doc.
  • C# events kind of suck for performance apparently. Maybe we should give an example on how to make a single event call that can call multiple scripts with some sort of custom processor?
  • Maybe for Bepu we can show how to use the SimulationUpdateComponent which works very similar to Unitys Monobehaviour with the Fixedupdate replaced by SimulationUpdate and AfterSimulationUpdate methods.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked PhysicsScriptComponentExtensions API and the PostTick and PreTick definitions in Simulation.cs. Add a Physics manual section covering subscription, execution order, and cleanup, then cross-reference it from the Stride for Unity developers page near FixedUpdate. Document the Bullet-only limitation and the Bepu alternatives mentioned in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
documentation, game-dev
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.