GCVirtualController isn't displaying when used with SKScene class. The Virtual controllers appear but then it seems that they are obscured by the SKScene itself!? The documentation says that calling connect() will display the virtual controllers but I seem to be missing how to add the controllers to the SKScene?
class GameScene: SKScene {
private var _virtualController: Any?
@available(iOS 15.0, *)
public var virtualController: GCVirtualController? {
get { return self._virtualController as? GCVirtualController }
set { self._virtualController = newValue }
}
override func didMove(to view: SKView) {
let background = SKSpriteNode(imageNamed: ".jpg")
background.zPosition = -1
addChild(background)
let virtualConfig = GCVirtualController.Configuration()
virtualConfig.elements = [GCInputLeftThumbstick, GCInputRightThumbstick, GCInputButtonA, GCInputButtonB]
virtualController = GCVirtualController(configuration: virtualConfig)
virtualController?.connect()
}
}
I've also tried adding the virtual controllers in the UIViewController but this doesn't work either.
Tap into virtual and physical game controllers
RSS for tagDiscuss the WWDC21 session Tap into virtual and physical game controllers.
Posts under wwdc21-10081 tag
1 Post
Sort by: