-
-
Notifications
You must be signed in to change notification settings - Fork 208
Closed
Labels
A-TransformRelates to transforms or physics positionsRelates to transforms or physics positionsC-BugSomething isn't workingSomething isn't working
Description
when spawning objects with a CenterOfMass it apprears as though the given Vec2 was .perp()ed
top left: (50., 0.)
top right: (0., 50.)
bottom left: (-50., 0.)
bottom right: (0., 50.)
use avian2d::prelude::*;
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(PhysicsPlugins::default().with_length_unit(100.))
.add_plugins(PhysicsDebugPlugin::default())
.add_systems(Startup, setup)
.insert_resource(SleepingThreshold {
linear: -1.,
angular: -1.,
})
.insert_resource(Gravity::ZERO)
.run();
}
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
commands.spawn(Camera2d);
let c = Color::hsl(100., 1., 0.2);
let mesh = meshes.add(RegularPolygon::new(1., 6));
let mat = materials.add(ColorMaterial::from_color(c));
// center (copy of the top left but perped 3 times)
commands.spawn((
Mesh2d(mesh.clone()),
MeshMaterial2d(mat.clone()),
RigidBody::Dynamic,
Collider::regular_polygon(1., 6),
CenterOfMass(Vec2::new(50., 0.).perp().perp().perp()),
Transform {
translation: Vec3::new(0., 0., 0.),
scale: Vec3::new(100., 100., 1.),
..default()
},
));
// top left
commands.spawn((
Mesh2d(mesh.clone()),
MeshMaterial2d(mat.clone()),
RigidBody::Dynamic,
Collider::regular_polygon(1., 6),
CenterOfMass(Vec2::new(50., 0.)),
Transform {
translation: Vec3::new(-300., 200., 0.),
scale: Vec3::new(100., 100., 1.),
..default()
},
));
// top right
commands.spawn((
Mesh2d(mesh.clone()),
MeshMaterial2d(mat.clone()),
RigidBody::Dynamic,
Collider::regular_polygon(1., 6),
CenterOfMass(Vec2::new(0., 50.)),
Transform {
translation: Vec3::new(300., 200., 0.),
scale: Vec3::new(100., 100., 1.),
..default()
},
));
// bottom left
commands.spawn((
Mesh2d(mesh.clone()),
MeshMaterial2d(mat.clone()),
RigidBody::Dynamic,
Collider::regular_polygon(1., 6),
CenterOfMass(Vec2::new(-50., 0.)),
Transform {
translation: Vec3::new(-300., -200., 0.),
scale: Vec3::new(100., 100., 1.),
..default()
},
));
// bottom right
commands.spawn((
Mesh2d(mesh.clone()),
MeshMaterial2d(mat.clone()),
RigidBody::Dynamic,
Collider::regular_polygon(1., 6),
CenterOfMass(Vec2::new(0., -50.)),
Transform {
translation: Vec3::new(300., -200., 0.),
scale: Vec3::new(100., 100., 1.),
..default()
},
));
}avian is amazing! thank you so much for making it! 🧡
Metadata
Metadata
Assignees
Labels
A-TransformRelates to transforms or physics positionsRelates to transforms or physics positionsC-BugSomething isn't workingSomething isn't working
