This.physics.collide() dont work

Why dont work calling this.physics.collide() from create() method of scene?
It should work, because in docs there is class ArcadePhysics, and it is accesible from this.physics of scene (source). According to that docs source, ArcadePhysics should have method collide(), so it should work to call “this.physics.collide(args)”. But nothing happens when I write it to my code. I must change it to this.physics.add.collider().
Why, if docs says, that this.physics.collide() also add collider?

Thanks!

this.physics.collide tells you whether two bodies are colliding at the moment it’s called. It should be called continuously, e.g. from update, and its result should be used immediately (or ignored if you only need the collision).

this.physics.add.collider creates an autonomous object (a collider) that checks for collision by itself. It should only be created once, e.g. in create. In that regard, you can think of it as an invisible Game Object (even though internally it has nothing in common with one) that calls this.physics.collide for you every frame (technically every physics update step).

Both approaches to collision (calling collide yourself every frame or letting a collider do the job) are equivalent, but colliders are synced to the physics updates, which might make them slightly more reliable. I don’t think you’ll run into problems if you combine the two, but there’s no point in it. It’s easier to remember the difference you use the method names: collide implies that it has an immediate effect, while add.collider implies that it creates a standalone object.

Thanks for answer. Do you know how are that two ways related to performance? Is one of them more preffered due to performance?
Thanks.

There should be little to no difference. Generally, you shouldn’t worry about potential performance issues unless they become actual problems.