Yes, you can. I just provided you with an example of inheritance above. I don’t actually know how to even properly respond to that. Why not? What do you even mean by that? Inheritance is at the very core of OOP. You can’t really get far without it. If you’re casting, you’re already using inheritance…
Obviously, a weapon should not inherit from a character because that’d make little sense - both inherit from Actor, naturally. And that’s precisely why you’d use an interface. Connect 2 (or more) classes that share nothing, and with no casting to boot!
And if you could, when using inheritance, the need to use interfaces is completely meaningless,
No. Just no. What is making you say that? If you have 2 unrelated classes (character & weapon, and their respective children) that know nothing about one another, you can connect them with an Interface. Now any child of Character can talk to any child of Weapon. Same for for both base classes.
since you only need to cast the parent actor of both
If you cast to the parent, you cannot talk to the child… so, no, you’re incorrect.
To me it all sounds a bit as you’ve been avoiding interfaces and relying on other, less efficient and more convoluted means of communication and now that your mind is set, there’s no going back.
In the end, I’m not here to convince anybody but to clarify. Yes, interfaces make perfect sense and if you want a character to talk to a weapon, it’s pretty good case scenario. Effortless and no casting is required.
@ DanielG1939 Apologies for hijacking your thread.