Skip to content

Issues rendering sprites and 3D models in 0.6 at the same time #3902

@cart

Description

@cart

Discussed in #3891

Originally posted by cdsupina February 7, 2022
Hello everyone! I'm trying to migrate my game from Bevy 0.5 to 0.6. The core of my game takes place in 2D, but I had a 3D background that gave my game a distinctive look. In Bevy 0.5 I was using a perspective camera and didn't have any issues rendering the 2D sprites and the background 3D models. Below is the Bevy 0.5 code for the perspective camera I was using.

// Setup perspective camera in Bevy 0.5
commands.spawn_bundle(PerspectiveCameraBundle {
    transform: Transform::from_xyz(0.0, 0.0, 950.0)
        .looking_at(Vec3::ZERO, Vec3::Y),
    perspective_projection: PerspectiveProjection {
        far: 10000.0,
        ..Default::default()
    },
    ..Default::default()
});

Snapshot of game from Bevy 0.5:
Capture

Since migrating to 0.6. I haven't been able to setup the camera in a way that lets me view the background 3D models and the sprites. Below is the perspective camera code I was using in Bevy 0.6 after I initially migrated (same as before).

// Setup perspective camera in Bevy 0.6
commands.spawn_bundle(PerspectiveCameraBundle {
    transform: Transform::from_xyz(0.0, 0.0, 950.0)
        .looking_at(Vec3::ZERO, Vec3::Y),
    perspective_projection: PerspectiveProjection {
        far: 10000.0,
        ..Default::default()
    },
    ..Default::default()
});

The image below is the game in Bevy 0.6. 3D models are visible but sprites are not appearing.

Capture

The next thing I tried was a 2D orthographic camera using the following code:

let mut camera = OrthographicCameraBundle::new_2d();
camera.transform = Transform::from_xyz(0.0, 0.0, 1000.0);
camera.orthographic_projection.far = 10000.0;

Now the 2D sprites are appearing but not the background models.
Capture

I was wondering if anyone had insight into how to render both the sprites and the background models like I had from Bevy 0.5 with the perspective camera. I also tried playing around with the other camera properties but didn't have much luck. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorP-RegressionFunctionality that used to work but no longer does. Add a test for this!

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions