Cannot read properties of undefined (reading 'texture')

Viewed 304
preload() {
    // prelaoding atlas png and json and anim json
    this.load.atlas('character','./Assets/Sprites/character_atlas.png','./Assets/Sprites/character_atlas.json');
    this.load.animation('character_anims','./Assets/Sprites/character_anim.json');
}


create(){
    // assigning player object to a physic
    this.player = new Phaser.Physics.Matter.Sprite(this.matter.world,0,0,'character','male_1');
    // printing sprite onto screen
    this.add.existing(this.player);
    // assigning keyboard inputs to variables
    this.inputKeys = this.input.keyboard.addKeys({
        up: Phaser.Input.Keyboard.KeyCodes.UP,
        down: Phaser.Input.Keyboard.KeyCodes.DOWN,
        left: Phaser.Input.Keyboard.KeyCodes.LEFT,
        right: Phaser.Input.Keyboard.KeyCodes.RIGHT,
    })
    console.log(this.player);
}

update(){
    this.player.anims.play('walking_right')

Why is this.player.anims undefined? Doesn't this.load.animation create this.player.anims?

Inspector showing that anims has been initialized:

Inspector showing that anims has been initialized

0 Answers
Related