TypeError: Cannot read properties of undefined (reading 'texture')

 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_9');
        // 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.anims);
    }

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

Hello everyone! I am new to Phaser and Coding in general, why is there an undefined ‘texture’ for my Physics.Matter.Sprite object when I passed in ‘character’ as the parameter for the texure.

:wave:

Remove this for now and see if it fixed the problem.

Add to create():

console.log('anims', this.anims.anims.entries);

and check console.

1 Like

sorry for the late reply, fixed the problem, I was using a wrong key to link my atlas to my animations!