~starkingdoms/starkingdoms

03ae4f52d091e573b5ddaaa207deda1635619a47 — ghostlyzsh 2 years ago e63e742
initial rotation bug fixed. i hate math.
2 files changed, 5 insertions(+), 5 deletions(-)

M server/src/handler.rs
M server/src/manager.rs
M server/src/handler.rs => server/src/handler.rs +0 -1
@@ 203,7 203,6 @@ pub async fn handle_client(
                                    ])
                                    .rotation(angle + PI / 2.)
                                    .build();
                                debug!("rotation: {}", player_body.rotation().angle());
                                let player_collider: Collider =
                                    ColliderBuilder::cuboid(25.0 / SCALE, 25.0 / SCALE)
                                        .mass_properties(MassProperties::new(

M server/src/manager.rs => server/src/manager.rs +5 -4
@@ 220,9 220,11 @@ impl AttachedModule {
                ], 0.)
            }
        };
        debug!("anchor: {}", anchor);

        let module_pos = parent_pos + vector![anchor.x * -rotation.sin(), anchor.y * rotation.cos()];
        let relative_pos = 
            vector![anchor.y * -(rotation + parent_body.rotation().angle()).sin(),
                anchor.y * (rotation + parent_body.rotation().angle()).cos()];
        let module_pos = parent_pos + relative_pos;

        // create attachment module
        let module_collider = ColliderBuilder::cuboid(25.0 / SCALE, 25.0 / SCALE)


@@ 230,9 232,8 @@ impl AttachedModule {
            .build();
        let module_body = RigidBodyBuilder::dynamic()
            .translation(module_pos)
            .rotation(parent_body.rotation().angle() - rotation)
            .rotation(parent_body.rotation().angle() + rotation)
            .build();
        debug!("angle: {}", module_body.rotation().angle());
        let attached_handle = data.rigid_body_set.insert(module_body);
        data.collider_set.insert_with_parent(
            module_collider,