I have tried to find out if this is possible but I don’t fully understand how the engine works, how scripts and entities are structured etc. I noticed pc.extend and pc.inherits in the API but don’t understand how to use them.
Is it possible and how do I create a parent script and have other scripts inherit from that?
If you notice that when a new script is added with default template, you have YourClass.prototype, this is sort of extend/inherit the YourClass class. Prototype just adds more functionality to an existing class
Virtuals and overrides are just basically recreate the parent functions in children, pretty much you can search for the net for it, here is one quite good on stackoverflow
But with PlayCanvas, I think we can make these work in PlayCanvas way i.e:
Create a bunch of “reusable” components such as FollowMouse.js, SelfRotate.js, MoveToward.js etc. you can call them as base classes if you want
Attached them to the same working entity, then on the main script, we just go this.entity.script.FollowMouse.DoStuff() for example, where DoStuff() is an “inherited” function from the “base” FollowMouse class