Hi have a simple system where I bundle a Marker component in with the player which all of the watchers look at.
This code allows for the marker to be anywhere from the parent down at any child level.
pub struct Watcher;
#[derive(Component)]
pub struct Marker;
pub fn watch_marker(
mut watcher_query: Query<&mut Transform, With<Watcher>>,
marker: Query<&GlobalTransform, With<Marker>>,
) {
if let Ok(marker_global_transform) = marker.get_single() {
let global_marker_position = marker_global_transform.translation();
for mut watcher_transform in watcher_query.iter_mut() {
watcher_transform.look_at(global_marker_position, Vec3::Y);
}
}
}
This works great if the Watcher is in the parent, but that’s not what I want if it is a head looking, or a turret, as I don’t want the whole person or tank to move to look at the marker.
If I add the watcher to a child, it all goes to hell and it doesn’t look in the right place at all.