Jump to content

collider works, but is not colliding just response as overlap


s4m_ur4i
 Share

Recommended Posts

See updates in below comments

I made a collider: this normally works. But however this time it doesn't. There is a collider which lets the player colliding with (this) object. when I move the player on the object, the collideCB is triggered. But there is no collision. Even in debug mode for arcade physics, I can see the body. But they are not colliding, just overlapping. Anyone has an idea why?
body:

this.scene.physics.world.enable(this);
this.setOrigin(0, 0);

this.body.setSize(8, 8, false);
this.body.setImmovable(true);
this.body.allowGravity = false;


colliding code:
 

this.scene.physics.add.collider(this.scene.config.player, this, collideCB, () => {
  return this.getData('active');
}, this)

(...)

collideCB() {
  console.log('working')
}

Also, the debug information seems to clearly address both sprites, that should collide. but it does not collide and the callback is fired. ALl other collisions are working. (attached screenshot)

 

debug.png

Edited by s4m_ur4i
update hint
Link to comment
Share on other sites

If someone has a Tip for what I could look, I would be grateful. I am right now building the game back to just a boilerplate because I can't figure out, why the collision is not working but the callback does. it is not that the collider isn't added. it works, and both sprites have bodies enabled, but the Player just falls through it.

Any ideas would be helpful :)

Link to comment
Share on other sites

update: It still does not work but when I enable the collision from "The other sprite" (the sprite it should collide with), it works. same code.
this makes no sense to me, has anyone a clue why this occurs? It's not practical for me, enabling the collisions that way.

Link to comment
Share on other sites

I found the issue, but this makes me even more confused.

 

//IN a scene this is called:
this.physics.add.overlap(this.config.player, this.config.layers.water, this.config.player.collideWater, null, this.config.player);

It is an overlap with some layer and stuff. It has nothing to do with the issued sprite code above. But it involves the player sprite (which the above sprite should collide with).
If I out-comment this line, the colliders will work again. But since I need the overlap AND the collision check I can't, and this does not seem like it should behave like that?

It even gets more confusing: When I add the overlap or collision in the player class itself. It won't collide with other elements anymore that were not affected to this issue before.

Edited by s4m_ur4i
more issues found.
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...