bevy_mod_lookat

Crates.iobevy_mod_lookat
lib.rsbevy_mod_lookat
version0.1.2
sourcesrc
created_at2024-08-08 18:40:40.144289
updated_at2024-08-11 15:57:30.81272
descriptionA microplugin for Bevy, that allows adding a component to an entity, that makes it target either an entity, or a position
homepage
repositoryhttps://github.com/TotalKrill/bevy_mod_lookat.git
max_upload_size
id1329851
size120,780
(TotalKrill)

documentation

README

bevy_mod_lookat

A microplugin and library for bevy to rotate an entity towards a target through a hierarchy

Crates.io Documentation License

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());
}

Commit count: 0

cargo fmt