vleue_navigator icon indicating copy to clipboard operation
vleue_navigator copied to clipboard

Avian2d colliders flipped relative to mesh

Open JosefKuchar opened this issue 3 months ago • 0 comments

When using avian2d updater plugin, all colliders appear to be flipped on the Y axis.

image

Minimal example:

use avian2d::prelude::*;
use bevy::{color::palettes, math::vec2, prelude::*};
use vleue_navigator::prelude::*;

#[derive(Component)]
struct Obstacle;

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins,
            PhysicsPlugins::default(),
            PhysicsDebugPlugin::default(),
            VleueNavigatorPlugin,
            NavmeshUpdaterPlugin::<Collider, Obstacle>::default(),
        ))
        .insert_resource(NavMeshesDebug(palettes::tailwind::RED_800.into()))
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());
    commands.spawn(NavMeshBundle {
        settings: NavMeshSettings {
            fixed: Triangulation::from_outer_edges(&[
                vec2(-128.0, -128.0),
                vec2(-128.0, 128.0),
                vec2(128.0, 128.0),
                vec2(128.0, -128.0),
            ]),
            agent_radius: 10.0,
            simplify: 10.0,
            merge_steps: 1,
            ..default()
        },
        update_mode: NavMeshUpdateMode::Debounced(0.2),
        ..NavMeshBundle::with_default_id()
    });
    commands.spawn((
        RigidBody::Static,
        Collider::triangle(
            Vec2::new(-15.0, -15.0),
            Vec2::new(15.0, -15.0),
            Vec2::new(-15.0, 15.0),
        ),
        TransformBundle {
            local: Transform::from_xyz(0.0, 0.0, 0.0),
            ..Default::default()
        },
        Obstacle,
    ));
}

JosefKuchar avatar Nov 01 '24 11:11 JosefKuchar