ios – Find out how to create a mini-map of a SpriteKit scene the usage of a special digital camera place

I have a SpriteKit SKScene presented via SwiftUI SpriteView.

What I want is a mini-map that is a real-time duplicate of the SKScene.

So, whatever happens in the main scene also happens in the mini-map. In other words, I’m not interested in a simplified recreation of the scene.

This would be pretty simple if not for one very important detail: The mini-map’s camera needs to be scaled (which will make the camera “zoom out”). So, we’re talking about two different cameras.

If one camera was enough, I’d be able to simply use two SpriteView instances pointing to the same SKScene. But the need for a second camera is a challenge because an SKScene can only use one camera at a time.

The only other solution I’m aware of — using view.texture(from:) or view.texture(from:crop:) to create an SKTexture of the rendered scene — technically works, but has a hugely negative impact on performance when used in real-time. So that technique seems useless here.

Are you aware of any other strategy that might solve this problem?

Shaders maybe?

Or, is there a way to synchronize the rendering of two different SKScene‘s so that they both show the same content, but from different camera positions?


Leave a Reply

Your email address will not be published. Required fields are marked *