Are multiple didBeginContact calls called simultaneously?

107 views Asked by At

Say two contacts happen at the exact same time. Will their didBeginContact function calls happen at the exact same time (in different threads I guess) or will one happen after the other?

1

There are 1 answers

0
Steve Ives On

No - didBeginContact is called for every pair of nodes that contact in your scene. The parameter passed to it is an SKPhysicsContact which contains references to the 2 bodies - bodyA and bodyB - involved in the contact.

If 3 nodes (e.g. player, enemy and bomb) appear to contact each other simultaneously, then didBegincontact will be called 3 times - once for the player/enemy contact, once for the player/bomb contact and once for the enemy/bomb contact.

You mention contacts being detected in multiple threads - I can't remember reading this anywhere, but I don't think that having multiple threads controlling a SpriteKit scene is a good idea, if it's even possible.