-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-DocsAn addition or correction to our documentationAn addition or correction to our documentationC-FeatureA new feature, making something new possibleA new feature, making something new possibleS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Description
What problem does this solve or what need does it fill?
This program (note: look_at) appears to insert a Transform, but actually inserts a unit value because Transform::look_at doesn't return a Transform.
This results in the debug system never finding the non-existent Transform at best, and getting a default Transform if another Component that requires a Transform inserts a Default value (such as Mesh3d).
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, startup)
.add_systems(Update, debug)
.run();
}
fn debug(entities: Query<(&Name, &Transform)>) {
for (name, transform) in &entities {
if ["Parent"].contains(&name.as_str()) {
info!(?name, transform=?transform.translation);
}
}
}
fn startup(mut commands: Commands) {
commands.spawn((
Name::new("Parent"),
Transform::from_xyz(10.0, 0.0, 0.0)
.look_at(Vec3::ZERO, Vec3::Y),
));
}What solution would you like?
- functions that accept exclusive references and return (), like
Transform::look_at, should link to versions that returnSelflikeTransform::looking_atif applicable in the documentation - A warning should be logged if
()is inserted as a component value, instead of just ignoring it
What alternative(s) have you considered?
The bevy linter includes a lint for this called unit_in_bundle with a very similar Transform example in the showcase. We could encourage use of the bevy linter instead.
olekspickle
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-DocsAn addition or correction to our documentationAn addition or correction to our documentationC-FeatureA new feature, making something new possibleA new feature, making something new possibleS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished