if distanceToplayer > self.detectiondistance: self.walking = True self.heading = self.standard.signedAngleDeg(varyangle) self.velocity = search_speed elif distanceToplayer < self.detectiondistance and distanceToplayer > 30: self.heading = self.standard.signedAngleDeg(position_vevtor2D) self.walking = True self.velocity += position_vevtor * self.acceleration * dt elif self.attackWaitTimer > 0 and distanceToplayer <= 30: self.heading = self.standard.signedAngleDeg(position_vevtor2D) self.walking = False self.velocity = Vec3(0, 0, 0) self.attackWaitTimer -= dt if self.attackWaitTimer <= 0 : self.attackWaitTimer = random.uniform(0.5, 0.7) self.actor.play("attack") self.a -= 1 print(self.a) if self.walking: self.actor.enableBlend() self.actor.setControlEffect('walk', 0.7) self.actor.setControlEffect('attack', 0.3) walkingControl = self.actor.getAnimControl("walk") if not walkingControl.isPlaying(): self.actor.loop("walk") self.actor.loop("attack") else: self.actor.stop() self.actor.loop("stand") self.actor.disableBlend() self.actor.setH(self.heading + 180)
I’m not sure, but I think that the problem may be that, while the character is walking, you continually call ‘actor.loop(“attack”)’, which I think may be resetting the attack animation. Since the animation is continually restarted, it never gets to its second frame, and so looks as though it’s not playing.
I also note that if the character is not walking, you stop all animations–presumably including the “attack” animation–and loop the “stand” animation. Thus, if the character attacks while not walking, the “attack” animation will presumably not visibly play.
OK, I see. It’s really caused by cycling the “stand” animation when it stops. Thank you very much.
It’s my pleasure; I’m glad if I’ve been of service.