- Home /
Java-Multiple inheritance in Networking
I'm having trouble trying to inherit some classes of UnityEngine.Networking
Java doesn't have multiple inheritance and I'm getting errors about multiple network managers if I try to put .NetworkServer and .NetworkBehaviour in different scripts.
I'm fairly new to inheritance and extend in Unity. Apart from coding in C, are there any other solutions or workarounds?
C# works very similarly to Java. It does not have multiple inheritance (other than interfaces, sort of). But I'm not understanding the question... Can you provide some sample code?
How can I get it so I can use functions from both NetworkBehaviour and NetworkServer
import UnityEngine.Networking;
class Client$$anonymous$$ove extends NetworkBehaviour {
if (!NetworkBehaviour.isLocalPlayer) {
NetworkServer.Spawn(bulletPrefab);//
You can't derive from two classes. What you probably want are variables to store references of those classes, rather than deriving from them directly. You want encapsulation, not inheritance.
Your answer
Follow this Question
Related Questions
how to use the listen port in this case? 0 Answers
Internal error while attempting to connect to master server 0 Answers
BCE0049 error with network script 0 Answers
Difficulty instantiating to a custom class 2 Answers
An OS design issue: File types associated with their appropriate programs 1 Answer