I have recently been testing out bevy for the first time and I wanted to make a window with a green plane inside of it when I run the code it shows errors related with the color and shape.
In bevy 0.14.0, the colors have been refactored. Try:
material: materials.add(bevy::color::palettes::css::DARK_GREEN.into()),
.. instead.
I'm not sure where shape::Plane
is supposed to come from, so I have no idea how to fix that. With that said -- have you tried browsing through the examples in the bevy repository? They even have them accessible/runnable in the browser(!).
tysm, the color problem has been fixed but I'm still having problems with the plane
Go to the place where you found the example code you got shape::Plane
from, and look carefully at its Cargo.toml
and its use
lines to find out what library it is importing that defines shape::Plane
.
The shape
API changed in Bevy 0.13, so where you once used shape::Plane
, now you'd use Rectangle
(see also Plane2d
which extends infinitely) from bevy::math::prelude
(also exported by bevy::prelude
)
I won't be able to help with your bevy
issues.
However, speaking generally, you should post both code and errors as text, not as images. See the pinned formatting guide to learn how, or in short:
```
code/error output goes here
```
When posting errors, you should also post the complete error from running cargo build
in the console, and not what your IDE shows you. IDEs are notorious for stripping out useful information provided in the rustc
warning and error output.
I tried implementing the code it wanted and I tried looking in the docs for any information I can find about adding colors.
I found the solution, this code does not have errors anymore.
use bevy::prelude::*;
use bevy::math::primitives::Plane3d;
fn main() {
App::new().add_plugins(DefaultPlugins).run();
}
fn spawn_floor(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
let floor = PbrBundle {
mesh: meshes.add(Plane3d::default().mesh().size(20., 20.)),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..default()
};
}
Instead of using the css colors I used rgb and changed the names of meshes and materials to mesh and material. Thanks to @blonk, @Water_Face for the help
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.