From 4089a5a949ea65bd540f79bf346cf9a229fd159e Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Mon, 16 Oct 2017 19:22:25 -0700 Subject: [PATCH] Slightly cleaner treatment of pi creature automatically tracking animations --- topics/characters.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/topics/characters.py b/topics/characters.py index a7645787..432c30e5 100644 --- a/topics/characters.py +++ b/topics/characters.py @@ -526,18 +526,17 @@ class PiCreatureScene(Scene): lambda anim : pi_creature in anim.mobject.submobject_family(), animations ) - if anims_with_pi_creature: - for anim in anims_with_pi_creature: - if isinstance(anim, Transform): - index = anim.mobject.submobject_family().index(pi_creature) - target_family = anim.target_mobject.submobject_family() - target = target_family[index] - if isinstance(target, PiCreature): - target.look_at(point_of_interest) - continue - animations.append( - ApplyMethod(pi_creature.look_at, point_of_interest) - ) + for anim in anims_with_pi_creature: + if isinstance(anim, Transform): + index = anim.mobject.submobject_family().index(pi_creature) + target_family = anim.target_mobject.submobject_family() + target = target_family[index] + if isinstance(target, PiCreature): + target.look_at(point_of_interest) + if not anims_with_pi_creature: + animations.append( + ApplyMethod(pi_creature.look_at, point_of_interest) + ) return animations def blink(self):