Search code examples
iossprite-kitcollision-detectiongame-physicsskphysicsbody

Is collision detection in Sprite Kit deterministic when not using physics?


I have found out thanks to this article: http://blog.element84.com/comparing-sprite-kit-physics-to-direct-box2d.html and personal experience that Sprite Kit is not deterministic when using physics simulations. However I was wondering if the collision logic actually deterministic when handling the node's position in a deterministic way. i.e. Repeatability works fine but my position handling.

Thanks!

UPDATE: Added more detail

In SpriteKit, physics simulations don't seem to be deterministic since they are evaluated in the game loop and depending on the frame rate of the device they can be executed at different rates. My question, is collision detection (such as the didBeginContact method) for physics bodies independent from the loop and called right after the position of the node has changed. I am trying to use only the collision properties from Sprite Kit to achieve repeatability in 2 instances that might perform at different frame rates.


Solution

  • Just in case this could help someone, I just found out that all collisions happen in the Sprite Kit loop, therefore they are not repeatable nor deterministic for that matter.