optional head drop impulse
This commit is contained in:
@@ -32,7 +32,9 @@ fn on_head_drop(
|
|||||||
let angle = rand::random::<f32>() * PI * 2.;
|
let angle = rand::random::<f32>() * PI * 2.;
|
||||||
let spawn_impulse = Quat::from_rotation_y(angle) * Vec3::new(0.5, 0.6, 0.).normalize() * 180.;
|
let spawn_impulse = Quat::from_rotation_y(angle) * Vec3::new(0.5, 0.6, 0.).normalize() * 180.;
|
||||||
|
|
||||||
if drop.impulse {
|
let impulse = drop.impulse;
|
||||||
|
|
||||||
|
if impulse {
|
||||||
commands.server_trigger(ToClients {
|
commands.server_trigger(ToClients {
|
||||||
mode: SendMode::Broadcast,
|
mode: SendMode::Broadcast,
|
||||||
message: PlaySound::HeadDrop,
|
message: PlaySound::HeadDrop,
|
||||||
@@ -49,7 +51,6 @@ fn on_head_drop(
|
|||||||
Collider::sphere(1.5),
|
Collider::sphere(1.5),
|
||||||
LockedAxes::ROTATION_LOCKED,
|
LockedAxes::ROTATION_LOCKED,
|
||||||
RigidBody::Dynamic,
|
RigidBody::Dynamic,
|
||||||
OneShotImpulse(spawn_impulse),
|
|
||||||
CollisionLayers::new(GameLayer::CollectiblePhysics, GameLayer::Level),
|
CollisionLayers::new(GameLayer::CollectiblePhysics, GameLayer::Level),
|
||||||
Restitution::new(0.6),
|
Restitution::new(0.6),
|
||||||
Children::spawn(SpawnWith({
|
Children::spawn(SpawnWith({
|
||||||
@@ -71,6 +72,7 @@ fn on_head_drop(
|
|||||||
})),
|
})),
|
||||||
Replicated,
|
Replicated,
|
||||||
))
|
))
|
||||||
|
.insert_if(OneShotImpulse(spawn_impulse), move || impulse)
|
||||||
.with_child((
|
.with_child((
|
||||||
Billboard::All,
|
Billboard::All,
|
||||||
SquishAnimation(2.6),
|
SquishAnimation(2.6),
|
||||||
|
|||||||
Reference in New Issue
Block a user