Last active
February 15, 2021 00:02
-
-
Save cart/96b1d39cd04274da566dbf28bf87c2a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::prelude::*; | |
struct Player { | |
velocity: Vec3, | |
} | |
fn main() { | |
App::build() | |
.add_plugins(DefaultPlugins) | |
.add_startup_system(spawn_player.system()) | |
.add_system(move_player.system()); | |
} | |
fn spawn_player(mut commands: Commands) { | |
commands.spawn((Player, Transform::default()); | |
} | |
fn move_player(time: Res<Time>, mut query: Query<(&mut Transform, &Player)>) { | |
for (mut transform, player) in in query.iter_mut() { | |
transform.translation += player.velocity * time.delta_seconds(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment