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.