Bevy Mod Transform2d
A 2D Transform component for Bevy.
Usage
Run cargo add bevy_mod_transform2d
.
Or add the dependency to your Cargo.toml
[]
= "0.6"
Example:
use *;
use *;
// Make the sprite orbit the center
Take a look at the other examples.
Version table.
Bevy | transform2d |
---|---|
0.12 | 0.6 |
0.11 | 0.5 |
0.10 | 0.4 |
0.9 | 0.3 |
0.8 | 0.2 |
0.7 | 0.1 |
Further details
Note that the Transform2d
component does not replace Transform
component, instead it writes to it. The Transform
and GlobalTransform
components are required for Transform2d
to function.
This makes this crate compatible with crates that interact with Transform
(eg. bevy_rapier2d
and bevy_xpbd_2d
) at the cost of performance,
and it supports parenting 3D transforms to 2D transforms and vice versa.
Integration with other crates
To integrate with another library that modifies Transform
the state of Transform
and Transform2d
will need to be synchronised back and forth at the right times.
Integrations with bevy_rapier2d
and bevy_xpbd_2d
are included and can be enabled as a feature:
[]
= { = "0.6", = ["bevy_rapier2d"] }
# or
= { = "0.6", = ["bevy_xpbd_2d"] }
If there is another plugin that interacts with the transform here's how you would synchronise the state to make Transform2d
compatible with that plugin.
- When a system needs to read from
Transfrom
add the providedsync_transform_2d_to_3d
system before it. - When a system writes to
Transfrom
add the providedsync_transform_3d_to_2d
system after it.