0 Replies
      Latest reply on Oct 13, 2017 3:49 PM by Zak MacKracken
      Zak MacKracken Level 1 Level 1 (0 points)
        import GameplayKit
        
        class RootComponent: GKComponent {}
        class ChildComponent: RootComponent {}
        
        let root = RootComponent()
        let child = ChildComponent()
        
        var system = GKComponentSystem(componentClass: RootComponent.self)
        
        system.addComponent(root)
        system.addComponent(child)
        

         

        Throws exception: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'component class is not supported by this system'

         

        This is undesirable. If I have, say, a "VisualComponent" and several subclasses of it each with their own "update" methods, and I want them all to be updated by a single GKComponentSystem, I cannot do so, because a GKComponentSystem will accept one and only one specific class, and not its subclasses.

         

        Is this intended?

         

        Is there a workaround, besides creating multiple GKComponentSystems for effectively the same kind of components?