when the player touches a type of platform I want it to increase its speed as well as decrease it, I used body touching but it detects all the collisions of the tilemap, so I started using "scene.physics.add.collider (objectsA, objectsB, collideCallback, processCallback , callbackContext); " what I want to achieve is that when the object collides it returns true and when it is not colliding it will return false the problem that when it collides it obviously only returns true and when it stops colliding it does not obviously not return false, there is some way that the player.body recognizes type from collisions and return true / false like body.touching or body.blocked does
A pattern for this is
let playerOnPlatform = false;
function create() {
// …
this.physics.add.collider(player, platforms, () => {
playerOnPlatform = true;
});
}
function update() {
if (playerOnPlatform) {
// …
}
playerOnPlatform = false;
}
Thank you.
That was what she wanted to achieve, I don’t know why she couldn’t see it.