I have a node bundle like this:
commands.spawn((
NodeBundle {
style: Style {
position_type: PositionType::Absolute,
height: Val::Px(100.0),
width: Val::Px(100.0),
..Default::default()
},
transform: Transform::from_translation(Vec3::ZERO),
visibility: Visibility::Visible,
background_color: BackgroundColor(Color::BLACK),
..Default::default()
},
Node {
x: 0,
y: 0,
kind: NodeKind::Player,
},
));
and I want to move this node:
fn move_node(
mut node: Query<(&mut Transform, &mut Node)>,
keyboard_input: Res<ButtonInput<KeyCode>>,
) {
let (mut transform, mut node) = node.single_mut();
if keyboard_input.pressed(KeyCode::KeyD) {
transform.translation.x += 100.0;
} else if keyboard_input.pressed(KeyCode::KeyS) {
transform.translation.y += 100.0;
} else if keyboard_input.pressed(KeyCode::KeyA) {
transform.translation.x -= 100.0;
} else if keyboard_input.pressed(KeyCode::KeyW) {
transform.translation.y -= 100.0;
}
}
but I find that I just can not move it ? I am new to bevy, could anyone help me, thanks a lot !!