Sprite tracking cursor jitters when panning camera #21248
-
I want a sprite to track the cursor when "placing" it, any ideas why it jitters when I pan the camera? It doesn't jitter when I move the cursor. The system to update the Sprite transform looks like this: fn update_shadow_to_cursor(
windows: Query<&Window, With<PrimaryWindow>>,
cams: Query<(&Camera, &GlobalTransform), With<Camera2d>>,
mut q: Query<&mut Transform, With<ColonyShadowMarker>>,
) {
let window = windows.single().unwrap();
let (cam, cam_transform) = cams.single().unwrap();
if let Some(screen_pos) = window.cursor_position() {
if let Ok(world_pos) = cam.viewport_to_world_2d(cam_transform, screen_pos) {
let mut t = q.single_mut().unwrap();
t.translation = world_pos.extend(t.translation.z);
}
}
} and I am running it in My pan logic runs in Thanks a lot! Screen_Recording_2025-09-28_at_13.04.51.mov |
Beta Was this translation helpful? Give feedback.
Answered by
liamaharon
Sep 28, 2025
Replies: 1 comment
-
@gμ helped me resolve this on Discord. I needed to use the cam |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
liamaharon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gμ helped me resolve this on Discord.
I needed to use the cam
Transform
(notGlobalTransform
), and then run the system.before(TransformSystem::TransformPropagate)
instead of.after
.