How to make camera follow player phaser 3

why the camera doesn’t want to not follow the player who moves upwards. can anyone help?

//set semua audio
this.allSound = [];
this.allSound.push(this.sound.add(“klikMenu”));
this.allSound.push(this.sound.add(“lompat”));
this.allSound.push(this.sound.add(“tabrakan”));
this.allSound.push(this.sound.add(“uh”));
this.allSound.push(this.sound.add(“backSoundMenu”));
this.allSound.push(this.sound.add(“backSoundGame”));
for (var i = 0; i < this.allSound.length; i++) {
this.allSound[i].setVolume(0.3);
}

//scene menu game bagian ui menu
var midX= 1024/2;
var midY= 768/2;
var musicMenu = false;
var playGame= false;
this.power= 0;
this.newHalangan=false;
this.menu = this.add.sprite(midX,midY,“backMenu”).setDepth(1);
this.judul= this.add.sprite(midX,200,“judul”).setDepth(1).setScale(2);
this.unmute = this.add.sprite(midX, 568, “unmute”).setDepth(2).setScale(0.2).setInteractive().on(Phaser.Input.Events.GAMEOBJECT_POINTER_DOWN, () => {
this.unmute.setVisible(false);

this.mute = this.add.image(midX, 568, "mute").setDepth(2).setScale(0.1).setInteractive().on(Phaser.Input.Events.GAMEOBJECT_POINTER_DOWN, () => {
    this.unmute.setVisible(true);
    this.mute.setVisible(false);
	musicMenu= true;
  });

});
//highscore
this.poin=0;
this.highscore = localStorage[“highscore”] || 0;
this.score = this.add.text(850,50 , this.highscore );
this.score.setOrigin(0.5);
this.score.setDepth(10);
this.score.setFontSize(30);
this.score.setColor(’#ffff00’);
this.score.setText("Highscore : " + this.highscore);

//tween menu
this.tweens.add({
targets: this.judul,
ease: “Elastic”,
duration: 1000,
delay: 300,
scaleX: 1,
scaleY: 1,
});
this.tweens.add({
targets: this.unmute,
ease: “Back”,
duration: 1000,
delay: 300,
scaleX: 0.1,
scaleY: 0.1,
});

// play game
this.play = this.add.sprite(midX, 400,“play”).setDepth(1).setScale(0.3).setInteractive().on(Phaser.Input.Events.GAMEOBJECT_POINTER_DOWN, () => {
this.tweens.add({
targets: this.score,
ease: “Elastic”,
duration: 750,
scaleX: 0,
scaleY: 0,
});
this.tweens.add({
targets: this.judul,
ease: “Power1”,
duration: 750,
y:0- 768,
});
this.tweens.add({
targets: this.play,
ease: “Power1”,
duration: 750,
y:0- 768,
});
this.tweens.add({
targets: this.unmute,
ease: “Power1”,
duration: 750,
y:0- 768,
});
if(musicMenu){
this.tweens.add({
targets: this.mute,
ease: “Power1”,
duration: 750,
y:0- 768,
});
}
this.tweens.add({
targets: this.menu,
ease: “Power1”,
duration: 750,
y:0- 768
});
var backGame =this.add.image(0, 0,‘backGame’).setOrigin(0);
this.cameras.main.setBounds(0, 0,1024, 768);
this.scoreGame = this.add.text(850,50 , this.poin );
this.scoreGame.setOrigin(0.5);
this.scoreGame.setDepth(10);
this.scoreGame.setFontSize(30);
this.scoreGame.setColor(’#ffff00’);
this.scoreGame.setText("Score : " +this.poin);
this.click= 1;
this.startJump= function(){
this.playerTween = this.tweens.add({
targets: this.player,
ease: “Power1”,
duration: 750,
y: this.player.y - 215,
});
this.newHalangan= true;
this.click++;
}

this.player = this.add.sprite(midX, 955,“head”).setScale(0.15).setDepth(1);
this.cameras.main.startFollow(this.player,false,0.5,0.5);
this.input.on(‘pointerdown’,this.startJump,this);
this.input.on(‘pointerdown’,this.jump,this);

});
this.tweens.add({
targets: this.play,
ease: “Elastic”,
duration: 1000,
delay: 300,
scaleX: 0.2,
scaleY: 0.2,
});

}

    function update() 
    {
        this.arrHalangan=[];

this.arrMove=[];
if(this.newHalangan){
var halangan = this.add.sprite(0,1000-this.click*215,“halangan”).setDepth(2).setScale(0.8);
this.arrHalangan[this.click]=halangan;
this.arrMove[this.click] = this.tweens.add({
targets: this.arrHalangan[this.click],
x: 415,
duration: 3000,
ease: ‘Power1’,
deplay:0
});
}
this.newHalangan= false;

this.jump = function (){

console.log(“d”)
}
}

    function render()
    {
        
    }
});

Screenshot (228) Screenshot (229)

Probably because of setBounds().

1 Like