# Remove collider from the update function

**URL:** <https://phaser.discourse.group/t/remove-collider-from-the-update-function/1715>\
**Category:** Phaser 3\
**Created:** [March 17, 2019, 4:12pm UTC](https://phaser.discourse.group/t/remove-collider-from-the-update-function/1715 "2019-03-17T16:12:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yediahell](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@Yediahell](https://phaser.discourse.group/u/Yediahell)\
**Post date:** [March 17, 2019, 4:12pm UTC](https://phaser.discourse.group/t/remove-collider-from-the-update-function/1715/1 "2019-03-17T16:12:23Z")

</div>

hello, first i must say i’m french so i’m going to do my best, i really need your help, i’m trying to build a platform game “escape room” style, i want when my player is on the mario tube i can press the down key and he pass through the tube. i have succeed to detect when my player is on the tube but when i want to remove gravity or move the player sprite down, the game freez just as excepted, i dont konw how to do otherwise. here is the code it’s a mess but only the update part is interesting for my problem. i hope you understanding me guys and thanks for your help.

---

<div class="post-metadata">

**Author:** ![theNeedle](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/theneedle/32/745_2.png) [@theNeedle](https://phaser.discourse.group/u/theNeedle)\
**Post date:** [March 17, 2019, 8:00pm UTC](https://phaser.discourse.group/t/remove-collider-from-the-update-function/1715/2 "2019-03-17T20:00:08Z")

</div>

I think you forgot to add code. 😅

---

<div class="post-metadata">

**Author:** ![Yediahell](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@Yediahell](https://phaser.discourse.group/u/Yediahell)\
**Post date:** [March 26, 2019, 9:26am UTC](https://phaser.discourse.group/t/remove-collider-from-the-update-function/1715/3 "2019-03-26T09:26:00Z")

</div>

let platform  
let player  
let cursors  
let a  
let b  
let c  
let d  
let e  
let f  
let h  
let k  
let q  
var jump = -480;  
var g = false;  
var z = 0;  
var m = 0  
let zeb  
let bla  
var des = 0;  
let scoreText;

class Scene1 extends Phaser.Scene{  
constructor(){  
super(“playGame”);  
}

preload (){  
this.load.image(‘level’, ‘assets/terrain/ground.png’);  
this.load.image(‘fond’, ‘assets/fond.jpg’);  
this.load.image(‘kayou’, ‘assets/terrain/rock.png’);  
this.load.image(‘secret’, ‘assets/interactsecret.png’);  
this.load.spritesheet(‘dude’, ‘assets/dude.png’,{ frameWidth: 32, frameHeight: 48 });  
this.load.audio(‘power’,‘assets/tudut.mp3’);  
this.load.image(‘cadre’,‘assets/carre.png’)  
this.load.image(‘pic’,‘assets/interact/spikes.png’)  
this.load.image(‘cle’,‘assets/interact/keye.png’)  
this.load.image(‘bonus’, ‘assets/interact/bonus.png’)  
this.load.image(‘lock’,‘assets/interact/lock.png’)  
this.load.image(‘bonusu’, ‘assets/interact/bonusu.png’)  
this.load.image(‘coin’, ‘assets/interact/coin.png’)  
this.load.image(‘mario’, ‘assets/interact/mario.jpg’)  
this.load.audio(‘gta’,‘assets/gta.mp3’)  
}  
create(){  
this.add.image(470,320, ‘fond’);  
d = this.physics.add.staticGroup();  
d.create(860,570, ‘secret’);  
platform = this.physics.add.staticGroup({  
key: ‘level’,  
repeat: 12,  
setXY: { x: 35, y: 605, stepX: 70 }  
}  
);  
a = this.physics.add.staticGroup({  
key: ‘level’,  
repeat: 2,  
setXY: { x: 175, y: 455, stepX: 70 }  
}  
);  
b = this.physics.add.staticGroup({  
key: ‘level’,  
repeat: 2,  
setXY: { x: 595, y: 385, stepX: 70 }  
}  
);  
c = this.physics.add.staticGroup();  
c.create(35,105, ‘level’);  
h = this.physics.add.staticGroup();  
h.create(175,105, ‘level’);

e = this.physics.add.staticGroup();  
e.create(82,105, ‘level’);

player = this.physics.add.sprite(5,550, ‘dude’);  
player.setCollideWorldBounds(true);  
this.add.image(850,35, ‘cle’).setScale(1.5);

this.add.image(860,540, ‘kayou’).setScale(1.5);  
this.anims.create({  
key: ‘left’,  
frames: this.anims.generateFrameNumbers(‘dude’, { start: 0, end: 3 }),  
frameRate: 10,  
repeat: -1  
});

this.anims.create({  
key: ‘turn’,  
frames: [{ key: ‘dude’, frame: 4 }],  
frameRate: 20  
});

this.anims.create({  
key: ‘right’,  
frames: this.anims.generateFrameNumbers(‘dude’, { start: 5, end: 8 }),  
frameRate: 10,  
repeat: -1  
});  
f = this.physics.add.image(55,20,‘cle’)  
f.setBounce(0.5);

this.physics.add.collider(player, platform);  
this.physics.add.collider(player, a);  
this.physics.add.collider(player, b);  
this.physics.add.collider(player, c, destroy, null, this);  
this.physics.add.collider(platform, f);  
this.physics.add.collider(f, c);  
this.physics.add.collider(player, d, secret, null, this);  
this.physics.add.collider(player, f, objet, null, this);  
this.physics.add.collider(player,e);  
this.physics.add.collider(player,h);  
this.physics.add.collider(platform,zeb);

function objet(){  
f.disableBody(true, true);  
z = z+2;  
this.add.text(865, 29, ‘I’)  
var w = this.physics.add.staticImage(35,555, ‘pic’);  
this.physics.add.collider(w,platform);  
this.physics.add.collider(player,w,mort,null,this);  
var u = this.physics.add.staticImage(735,318, ‘lock’).setScale(0.9);  
this.physics.add.collider(player, u, serrure, null, this);  
jump = jump +200;  
o.disableBody(true, true);  
}  
var o = this.physics.add.staticImage(735,318, ‘lock’).setScale(0.9);  
this.physics.add.collider(player,o);

function serrure (){  
var k = this.physics.add.staticGroup();  
k.create(455,315,‘bonus’).body.allowGravity = false;

this.physics.add.collider(player,k, bonus, null,this);  
}  
function bonus(player,k){  
var q = this.physics.add.staticGroup();  
q.create(455,315,‘bonusu’).body.allowGravity = false;

var v = this.physics.add.image(455,315,‘coin’).setVelocityY(-300).setScale(0.5);  
this.physics.add.collider(player,v,money,null, this);  
}  
function money (player,v) {  
v.disableBody(true, true);  
player.setCollideWorldBounds(false);  
m = m+1;  
this.scene.start(“bootGame”);  
}  
function mort (player,w){  
player.disableBody(true, true);  
this.add.text(455, 300,‘GAME OVER’,{ font: ‘64px Jazz LET, fantasy’ }).setTint(0xff0000).setOrigin(0.5, 0.5);  
this.add.text(455, 345,‘press F5’,{ font: ‘40px Jazz LET, fantasy’ }).setTint(0xff0000).setOrigin(0.5, 0.5);  
var music = this.sound.add(‘gta’);  
music.play();

}

bla = this.physics.add.staticImage(540,500,‘mario’);

[//this.physics.world.removeCollider](https://this.physics.world.removeCollider)(collider)

function destroy(player, e){  
e.disableBody(true, true);  
}

```
function secret (player, d){
player.setTint(0xff0000);
jump = jump-220;
var music = this.sound.add('power');
music.play();
d.disableBody(true,true);
zeb.body.allowGravity = true;
player.x = 50;

```

}  
if (z==2){  
test();  
}

cursors = this.input.keyboard.createCursorKeys();

[//this.cameras.main.setBounds](https://this.cameras.main.setBounds)(0, 0, 2000 , 2000);  
[//this.physics.world.setBounds](https://this.physics.world.setBounds)(0, 0, 2000, 2000);  
[//this.cameras.main.startFollow](https://this.cameras.main.startFollow)(player, true, 0.05, 0.05);

zeb = this.physics.add.image(500,10,‘level’);  
zeb.body.allowGravity = false;  
this.physics.add.collider(player, bla);  
scoreText = this.add.text(16, 16, ‘score: 0’, { fontSize: ‘32px’, fill: ‘#000’ });

}  
update(){  
if (cursors.left.isDown)  
{  
player.setVelocityX(-160);

```
player.anims.play('left', true);

```

}  
else if (cursors.right.isDown )  
{  
player.setVelocityX(160);

```
player.anims.play('right', true);

```

}  
else  
{  
player.setVelocityX(0);

```
player.anims.play('turn');

```

}

if (cursors.up.isDown && player.body.touching.down)  
{  
player.setVelocityY(jump);  
}  
if (player.y\<4010 && player.y\>400 && player.x\>505 && player.x\<575 && cursors.down.isDown){  
player.setTint(0xff0000);  
}  
else {  
player.setTint(354032);  
des = -420;  
}  
if (m\>4){  
this.add.text(455, 345,’ putain de capitaliste’,{ font: ‘30px Jazz LET, fantasy’ }).setTint(0xff0000).setOrigin(0.5, 0.5);

}  
if (zeb.y\<300 && zeb.y\>299 ) {  
}

}  
}

function score () {  
des = 420;  
}
