bevyengine / bevyengine/bevy

Support setting transform parent independendly from logical parent

Open
#25,468 4 comments 0 reactions 0 assignees View on GitHub
A-ECS A-Transform C-Feature S-Needs-Design X-Contentious
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Currently Bevy has a single hierarchy representing both a logical hierarchy, which is used to recursively despawn entities, and a transform hierarchy which is used to attach entities to other entities.
An entity can only be attached to another entity by setting its parent, also changing the logical hierarchy, which is not always desirable. For example a player might be attached to a vehicle by setting its parent, which means if the vehicle despawns so does the player. Conversely entities can also live longer than they are supposed to, for example if an entity in a level can be picked up by a player, parenting it to the players hand can cause it to outlive the level.

## What solution would you like?

Add a relationship that allows overriding the transform parent of an entity. If this relationship is absent the logical parent doubles as the transform parent. This relationship could be called Anchor, and the related entity could be optional, with None making the entity anchored to world space.

## What alternative(s) have you considered?

- Split logical and transform parents to be fully independent of each other. Specifying both logical and transform parents, even if identical, for all entities would be too cumbersome
- Disable linked spawn for the ChildOf relationship, and have users bring their own logical hierarchy relationship. Despawning a hierarchy of entities is a common enough pattern for this to be undesirable.

## Additional context

I am working with user generated content with a scripting system, where the problem of the lifetime of an entity changing due to the parent relationship changing is especially problematic. Hence the parent relationship is made immutable to scripts, and a separate relationship is required to allow scripts to change which entity an entity is attached to.

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named in the issue. Start by reading the existing logical and transform hierarchy implementation, then determine the relationship design and its interaction with despawning and scripting; done means transform attachment can differ without changing entity lifetime.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.