Hi,
I wanted to create a text that follows player and did this:
pub fn update(
mut text_transform_query: Query<
&mut Transform,
(With<MyText>, Without<Player>),
>,
mut text_query: Query<&mut Text2d, With<MyText>>,
player_transform_query: Query<&Transform, (With<Player>, Without<MyText>)>,
player_query: Query<&Player, With<Player>>,
) {
let mut text_transform = text_transform_query.get_single_mut().unwrap();
let mut text = text_query.get_single_mut().unwrap();
let player = player_query.get_single().unwrap();
let player_transform = player_transform_query.get_single().unwrap();
let mut new_text_position = player_transform.translation.truncate().extend(0.0);
new_text_position += Vec3::new(50.0, 50.0, 1.0);
text_transform.translation = new_text_position;
*text = format!("Point = {}", player.point).into();
}
This actually works and there is a text that actively updates itself both for position and point.
Problem is it's not optimized, it's shaking and staying behind from player a little. Especially in high speed. What is the optimized way to do it. I want a text that follows player and updates itself actively?