Random orientation for spawned NPCs

This commit is contained in:
Joshua Barretto 2020-10-05 19:52:33 +01:00 committed by Snowram
parent 97ec94fd3d
commit 87edbf02ab

View File

@ -17,6 +17,7 @@ use specs::{
};
use tracing::warn;
use vek::*;
use rand::prelude::*;
pub trait StateExt {
/// Updates a component associated with the entity based on the `Effect`
@ -121,7 +122,11 @@ impl StateExt for State {
.create_entity_synced()
.with(pos)
.with(comp::Vel(Vec3::zero()))
.with(comp::Ori::default())
.with(comp::Ori(Dir::new(Vec3::new(
thread_rng().gen_range(-1.0, 1.0),
thread_rng().gen_range(-1.0, 1.0),
0.0,
).try_normalized().unwrap_or_default())))
.with(comp::Collider::Box {
radius: body.radius(),
z_min: 0.0,