'AttributeError: 'Player' object has no attribute 'run_dust_animation'

So the problem I'm encountering is that I get an error saying that Player has no attribute run_dust_particles when I just set the function there.

Code for run_dust_particles:

def run_dust_animation(self):
        if self.status == 'run' and self.on_ground:
            self.dust_frame_index += self.dust_animation_speed
            if self.dust_frame_index >= len(self.dust_run_particles):
                self.dust_frame_index = 0

            dust_particle = self.dust_run_particles[int(self.dust_frame_index)]

            if self.facing_right:
                pos = self.rect.bottomleft
                self.display_surface.blit(dust_particle, pos)

Code where I'm calling it:

def update(self):
    self.get_input()
    self.get_status()
    self.animate()
    self.run_dust_animation()

Update() call I am doing:

self.player.update()

Full error message starting at traceback:

Traceback (most recent call last):
File "C:\Users\Daniel\Desktop\PlatformerGame.py", line 28, in <module>
level.run()
File "C:\Users\Daniel\Desktop\level.py", line 98, in run
self.player.update()
File "C:\Users\Daniel\AppData\Local\Programs\Python\Python310\lib\site-packages\pygame\sprite.py", line 
539, in update
sprite.update(*args, **kwargs)
File "C:\Users\Daniel\Desktop\player.py", line 134, in update
self.run_dust_animation()
AttributeError: 'Player' object has no attribute 'run_dust_animation'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source