'How to turn on showPhysics in a Swift UI SpriteView?

I have been playing with the SpriteView in iOS14 and its working quite well however, I noticed that some collisions that worked fine when using a UIViewcontroller would be missed using the SpriteView. So I thought to turn on showsPhysics to help with the debug. However I am stumped as to how I can do that as the skView is not available?

Can anyone help, I must be missing something.

cheers S



Solution 1:[1]

So now I feel a bit dumb. The answer was to put the view.showsPhysics = true into the didMove(to view: SKView) call!

Solution 2:[2]

it is simple, you just need to add a new parameter wend you initialize the SpriteView:

SpriteView(scene: SKScene(), debugOptions: .showsPhysics)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CodeSpringsEnternal
Solution 2 Vitor Cheung