add spotlight to player

This commit is contained in:
yuni 2024-05-07 15:35:47 +02:00
parent fa54f0e57a
commit f88d063beb

View file

@ -17,6 +17,7 @@ use bevy::math::DVec3;
use bevy::pbr::{NotShadowCaster, NotShadowReceiver}; use bevy::pbr::{NotShadowCaster, NotShadowReceiver};
use crate::{actor, camera, chat, hud, nature, shading, skeleton, var, world}; use crate::{actor, camera, chat, hud, nature, shading, skeleton, var, world};
use regex::Regex; use regex::Regex;
use std::f32::consts::PI;
use std::f64::consts::PI as PI64; use std::f64::consts::PI as PI64;
use std::time::SystemTime; use std::time::SystemTime;
@ -743,6 +744,30 @@ fn spawn_entities(
if let Some(_) = state.ar_model { if let Some(_) = state.ar_model {
actor.insert(hud::AugmentedRealityOverlayBroadcaster); actor.insert(hud::AugmentedRealityOverlayBroadcaster);
} }
if state.is_player {
actor.with_children(|builder| {
builder.spawn((
world::DespawnOnPlayerDeath,
SpotLightBundle {
transform: Transform {
translation: Vec3::new(0.0, 0.0, 1.0),
rotation: Quat::from_rotation_y(180f32.to_radians()),
..default()
},
spot_light: SpotLight {
intensity: 40_000_000.0, // lumens
color: Color::WHITE,
shadows_enabled: true,
inner_angle: PI / 8.0 * 0.85,
outer_angle: PI / 4.0,
range: 2000.0,
..default()
},
..default()
}
));
});
}
actor_entity = actor.id(); actor_entity = actor.id();
} }