#rotating inserted 2d sprites

14 messages · Page 1 of 1 (latest)

sudden yoke
#

Hey,

I have this problem where I cant rotate the sprites im inserting to spawned bullet entities using the 3d sprite crate:

https://github.com/FraserLee/bevy_sprite3d

tried using the method with_rotation on transform but no success. systemlooks like this:

    q: Query<(Entity, &Position, &Rotation), (With<BulletMarker>, Added<Collider>)>,
    mut commands: Commands,
    scene_assets: Res<SceneAssets>,
    asset_server: Res<AssetServer>,
    mut sprite_params: Sprite3dParams,
) {

    let laser_handle = scene_assets.lasers.clone();

    for (entity, pos, rot) in q.iter() {
        println!("pos: {:?}, rot: {:?}", pos.0, rot.0);

        // Spawn left laser
        commands.entity(entity).insert(
            Sprite3d {
                image: laser_handle.clone(),
                alpha_mode: AlphaMode::Blend,
                transform: Transform::from_translation(pos.0)
                    .with_rotation(rot.0)
                    .with_scale(Vec3::splat(5.0)),
                ..default()
            }
            .bundle(&mut sprite_params),
        );


    }
}````

also tried other methods where I set the rotation manually without using the `rot` variable im querying in but it has no effect on the rotation/orientation of the sprite. 

println comes out looking like this:

```pos: Vec3(15.582591, 0.0, 6.8688116), rot: Quat(0.0, 0.45316583, 0.0, -0.8914262)```

any suggestions what more methods I can try?
GitHub

Use sprites in a 3d bevy scene. Contribute to FraserLee/bevy_sprite3d development by creating an account on GitHub.

#

method with_scaleis working fine tho. so at least something is. just not with_rotation and looking_at

sudden yoke
#

lasers are spawned using avian3d colliders. could it be related to this?

#general message

bleak flower
sudden yoke
sudden yoke
bleak flower
#

Which Bevy version are you using?

sudden yoke
#

0.14

bleak flower
#

Try running that example I linked and see if it work for you. If not that means there is issue with the library. If the example works you will have to do some digging on where do you have any differences. Also try spawning them as their own new entities

#

Perhaps something is interfering with rotation in other systems you have?

sudden yoke
sudden yoke
#

ok so works in a minimal example. so def something interfering with the transform on my newly inserted sprite

sudden yoke
#

I think I found the issue. the new transform with its rotation is being synced by lightyear since im inserting the sprite to a replicated entity as a child.

sudden yoke
#

Oh I found my mistake...Ive added rotation on x and z lock to both my ship AND bullet physics 😂