Inheritence and OOP with PlayCanvas

We currently use ApeECS + babylonjs and are looking into switching to playcanvas (it renders a lot faster!) are you saying that the ECS system in playcanvas is essentially internal to playcanvas and you can’t just add your own components + systems?

Yes to a degree. You can add your own system and components but they won’t be accessible in the Editor. The components would need to be added via code.

For example, you could have a pc.script that just has data and adds the custom component to the entity and some global code that adds the system to the engine and that would give you some degree of Editor control/input.

You could also use ApeECS on top of PlayCanvas as there are some events fired by the engine that you could hook into (eg ‘update’ on the application object. There are also some internal ones that you could use for a bit more control).

1 Like

I don’t think we’re planning on using the editor (p.s. is it possible to just summon the editor or is it only from the hosted service?) as we already have a lot of application logic thats separate to the actual renderer. I am concerned about the complexity of running two ecs systems side by side so any tips on best practice would help a lot

I assume you use your ECS for game logic … and have some kind of actors that do things in your world. In that case, perhaps some of these classes that represent something from Playcanvas (Mesh, light, camera, collider and whatever else) would simply store Entity reference, linking to matching part in the hierarchy of Playcanvas. You could then move them by setting position and similar.

1 Like

It’s hosted service unfortunately.

If you are using the engine only then yes, this becomes easier whether you want to use the existing Ape ECS or extend PlayCanvas’

You may need a bit of patching/modifying of the engine to make it easier for you to plug in systems in the desired update order but generally, it shouldn’t be too tricky to do in the application.js file of the engine