Skip to content

Conversation

@Jondolf
Copy link
Member

@Jondolf Jondolf commented Apr 17, 2025

Objective

Add no_std compatibility.

Solution

TODO


Migration Guide

TODO

@Jondolf Jondolf added M-Migration-Guide A breaking change to Avian's public API that needs to be noted in a migration guide C-Dependencies A change to the crates that Avian depends on labels Apr 17, 2025
@Jondolf Jondolf added this to the 0.3 milestone Apr 17, 2025
@tapmondev
Copy link

tapmondev commented Apr 17, 2025

I'm not sure if this is the right place to document this, but I'm trying to run this pr in a pretty confined WASM env , where there is no time/rng access. I'm running into the following error:

2025-04-17T20:57:46.512Z panicC:\Users\tapmondev\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\bevy_ecs-0.16.0-rc.5\src\error\handler.rs:141: Encountered an error in system `bevy_transform_interpolation::hermite::ease_rotation_hermite<avian2d::interpolation::AngVelSource>`: Parameter `Res<Time<Fixed>>` failed validation: Resource does not exist

I'm running with bevy 0.16 rc5 and these plugins:

  let mut app = App::new();
    app.add_plugins(
        (
            // Use MinimalPlugins and disable features not needed for server-side logic.
            MinimalPlugins
            .build()
            .disable::<ScheduleRunnerPlugin>() // No need for Bevy to run its own schedule loop
            .disable::<TimePlugin>(), // SpacetimeDB handles time/ticks
            PhysicsPlugins::default(),
        )
    );

I manually call the bevy update by running app.update()

From what my gut tells me I can't use the default Physics Plugins, as there is the PhysicsSchedulePlugin ? I'm pretty to new bevy and rust in general. So not sure if I'm missing something obvious here. I'd love some pointers how to call updates to the physics system/world.

EDIT:

I got it running, I was able to use the time plugin by calling:

  unsafe {
        bevy_platform::time::Instant::set_elapsed(get_tick_based_elapsed_time);
    }
    
// --- Tick-Based Elapsed Time Tracking ---
const TICK_INTERVAL_NANOS: u64 = 16_000_000; // 16ms in nanoseconds
static ELAPSED_NANOS: AtomicU64 = AtomicU64::new(0);

// Function to provide elapsed time based on ticks
fn get_tick_based_elapsed_time() -> Duration {
    let nanos = ELAPSED_NANOS.load(Ordering::Relaxed);
    Duration::from_nanos(nanos)
}

However one quirk I noticed is that I manually need to init some resources, not sure this is due to no_std support.

app.init_resource::<avian2d::collision::CollisionDiagnostics>();
    app.init_resource::<SolverDiagnostics>();
    app.init_resource::<SpatialQueryDiagnostics>();
    

@Jondolf Jondolf modified the milestones: 0.3, 0.4 May 9, 2025
@Jondolf Jondolf removed this from the 0.4 milestone Jul 21, 2025
@janhohenheim
Copy link
Member

Marking as Waiting-on-Author due to merge conflicts

@janhohenheim janhohenheim added the S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged label Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Dependencies A change to the crates that Avian depends on M-Migration-Guide A breaking change to Avian's public API that needs to be noted in a migration guide S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants