bevyengine / bevyengine/bevy

ECS should reject () component

Open
#24,451 3 comments 0 reactions 0 assignees View on GitHub
A-ECS C-Feature D-Modest S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

This is probably a common pitfall someone try to add a component with rotation or other composite transforms:

```
commands.spawn((
...,
Transform::from_xyz(0., 0., 0.).rotate_local_y(PI)
))
```

Since `rotate_local_y()` mutates `self` and returns `()` a component of type `()` is added to the entity, which does nothing.

I'm new to Bevy and not sure if there is an use case for a component of type `()`, but this is probably never what the user wants?

mutation methods on `Transform` probably should also return `self` to make it chain-able, but that is another conversation.

Contributor guide

Open the contributing guide

Research direction

Start with the commands.spawn tuple expression shown, then inspect how Transform::from_xyz(...).rotate_local_y(PI) is typed and inserted as a component. Confirm whether () is intentionally supported before deciding the expected behavior; done should include coverage for this expression and the chosen behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.