use happy_feet as kinematic character controller (#42)
This commit is contained in:
@@ -88,15 +88,24 @@ fn on_head_drop(
|
||||
commands
|
||||
.spawn((
|
||||
Name::new("headdrop"),
|
||||
HeadDrop(drop.head_id),
|
||||
Transform::from_translation(drop.pos),
|
||||
Visibility::default(),
|
||||
Collider::sphere(1.5),
|
||||
LockedAxes::ROTATION_LOCKED,
|
||||
RigidBody::Dynamic,
|
||||
CollisionLayers::new(LayerMask(GameLayer::Collectibles.to_bits()), LayerMask::ALL),
|
||||
CollisionLayers::new(
|
||||
GameLayer::CollectiblePhysics,
|
||||
LayerMask::ALL & !GameLayer::Player.to_bits(),
|
||||
),
|
||||
CollisionEventsEnabled,
|
||||
Restitution::new(0.6),
|
||||
children![(
|
||||
Collider::sphere(1.5),
|
||||
CollisionLayers::new(GameLayer::CollectibleSensors, GameLayer::Player),
|
||||
Sensor,
|
||||
CollisionEventsEnabled,
|
||||
HeadDrop(drop.head_id),
|
||||
)],
|
||||
))
|
||||
.insert_if(
|
||||
ExternalImpulse::new(spawn_dir * 180.).with_persistence(false),
|
||||
@@ -115,7 +124,7 @@ fn collect_head(
|
||||
mut commands: Commands,
|
||||
mut collision_event_reader: EventReader<CollisionStarted>,
|
||||
query_player: Query<&Player>,
|
||||
query_collectable: Query<&HeadDrop>,
|
||||
query_collectable: Query<(&HeadDrop, &ChildOf)>,
|
||||
query_secret: Query<&SecretHeadMarker>,
|
||||
) {
|
||||
for CollisionStarted(e1, e2) in collision_event_reader.read() {
|
||||
@@ -127,7 +136,7 @@ fn collect_head(
|
||||
continue;
|
||||
};
|
||||
|
||||
let key = query_collectable.get(collectable).unwrap();
|
||||
let (key, child_of) = query_collectable.get(collectable).unwrap();
|
||||
|
||||
let is_secret = query_secret.contains(collectable);
|
||||
|
||||
@@ -137,6 +146,6 @@ fn collect_head(
|
||||
commands.trigger(PlaySound::HeadCollect);
|
||||
}
|
||||
commands.trigger(HeadCollected(key.0));
|
||||
commands.entity(collectable).despawn();
|
||||
commands.entity(child_of.parent()).despawn();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user