#Changing the position of text after the text is spawned

4 messages · Page 1 of 1 (latest)

verbal lagoon
#

So, I know how to set the position of text when I spawn it but after that I can't really change its position. I tried to move it using transform like I would move my player sprite for example but that doesn't work for text.

raw crest
#

if you're using text bundle, then it's using the ui layout system, which has a transform but it's calculated based on the style:

/// This field is automatically managed by the UI layout system.
/// To alter the position of the `NodeBundle`, use the properties of the [`Style`] component.
pub transform: Transform,

if you're using absolute position for your text then you can modify style.position instead

fn move_text(mut styles_query: Query<&mut Style>) {
    for mut style in styles_query.iter_mut() {
        style.position.top.try_add_assign(Val::Px(1.0)).ok();
    }
}

this will move the text down 1px every time it runs

verbal lagoon
#

Let me try

#

Yep, it works. Thank you!