3 releases
0.1.2 | Aug 11, 2024 |
---|---|
0.1.1 | Aug 8, 2024 |
0.1.0 | Aug 8, 2024 |
#1047 in Game dev
31KB
66 lines
bevy_mod_lookat
A microplugin and library for bevy to rotate an entity towards a target through a hierarchy
use bevy::prelude::*;
use bevy_ui_anchor::{RotateTowardsPlugin, RotateTo, UpDirection};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(RotateTowardsPlugin)
.add_startup_system(setup)
.run();
}
fn setup(mut commands: Commands) {
let target = commands.spawn((
Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)),
GlobalTransform::default(),
)).id();
commands.spawn((
Transform::from_translation(Vec3::new(1.0, 0.0, 0.0)),
GlobalTransform::default(),
RotateTo {
entity: target,
updir: UpDirection::Target,
},
));
commands.spawn(Camera3dBundle::default());
}
Dependencies
~25MB
~464K SLoC