camera shaking good
This commit is contained in:
parent
ee8799c324
commit
329cd173b9
3 changed files with 4 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -328,6 +328,7 @@ name = "bevy-santa"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
|
"derive_more",
|
||||||
"rand",
|
"rand",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,5 @@ edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.17.3"
|
bevy = "0.17.3"
|
||||||
|
derive_more = "2.1.1"
|
||||||
rand = "0.9.2"
|
rand = "0.9.2"
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ pub struct MyCamera {
|
||||||
pub fn spawn_camera(mut commands: Commands) {
|
pub fn spawn_camera(mut commands: Commands) {
|
||||||
let mycam = commands
|
let mycam = commands
|
||||||
.spawn((
|
.spawn((
|
||||||
MyCamera { shaking_intensity_factor: 10.0, shaking_reset_speed: 0.1 },
|
MyCamera { shaking_intensity_factor: 10.0, shaking_reset_speed: 100.0 },
|
||||||
Transform::from_translation(Vec3::ZERO),
|
Transform::from_translation(Vec3::ZERO),
|
||||||
))
|
))
|
||||||
.id();
|
.id();
|
||||||
|
|
@ -39,7 +39,7 @@ pub fn camera_shake(
|
||||||
child_translation -= child_translation * parent.shaking_reset_speed * time.delta_secs();
|
child_translation -= child_translation * parent.shaking_reset_speed * time.delta_secs();
|
||||||
child_transform.translation.x = child_translation.x;
|
child_transform.translation.x = child_translation.x;
|
||||||
child_transform.translation.y = child_translation.y;
|
child_transform.translation.y = child_translation.y;
|
||||||
// println!("{:?}", child_transform.translation);
|
println!("{:?}", child_transform.translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MyCameraPlugin;
|
pub struct MyCameraPlugin;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue