I was trying to expand on the Breaker game and tried to speed up the ball. When it gets too fast, it will pass through the barriers and never return (very similar to this question - Ch 10: Ball and Barrier Bugs - except I’m using the code in the tutorial package instead, so unsharing does not work). I thought at first that maybe it was because in between frames, it was moving so fast that in one frame it would be on one side of the barriers, and then the next frame it would be on the other. But no, this isn’t the case, as seen here. The contact will call the contact test delegate method despite passing through the barriers. Any way to resolve this or understand why it happens? Thanks!
Hi there, you’ve hit the nail on the head. Making the ball move super fast will make it pass thru obstacles, due to the physics update frequency. There’s a way around the problem, and that is to make use of technique known as Ray-Casting. You can use SCNHitTestResult() for this purpose.
Hope that helps you in the right direction.
Thanks so much for your reply, Chris! I really appreciate it. Do you understand why exactly though the contact test delegate is being called but not the collision test? It seems very strange that one would work but not the other. This is what is making me thing that the physics engine is recognizing it but I’m doing something wrong for some reason. Thanks again.
Can you provide slightly more information about how to use Ray-casting to avoid this problem? Would you define the
SCNSceneRendererDelegate.renderer(_ renderer: SCNSceneRenderer, didSimulatePhysicsAtTime time: TimeInterval)
and check to see if the ballNode has moved outside the barrier bounds, and simply treat that as a collision?