1. I'm currently working on a plugin and came across the idea being able to spawn objects that are not normally available in the game. I have tried several methods of doing this but all have failed.

    Is this even possible? If anybody has a clue on how to do this that would be greatly appreciated.

    Thanks!
     
  2. Wulf

    Wulf Community Admin

    What specifically are you trying to spawn? I don't think you'd be able to spawn anything that doesn't already exist in both the client and server, and there's most likely no way for the client to actually know it exists, only the server.
     
  3. That was my first thought. I came to the conclusion that I would only be able to spawn gameobjects that come with the Unity engine or game. I'd like to just be able to spawn primitive objects such as cubes.

    Code:
    GameObject.CreatePrimitive(PrimitiveType.Cube);
     
  4. Wulf

    Wulf Community Admin

    That may spawn it on the server, but it's likely that the client will never actually see it.
     
  5. Are you aware of if there is any way to let the client know of these objects and not just the server?
     
  6. Wulf

    Wulf Community Admin

    I'm not really familiar with how the client tells what is there, so probably not the best one to ask. ;)

    I'm assuming the'd need to be sent to the client, but without them actually being used by the game generally, then there's likely nothing setup to send them.
     
  7. Another forum member, Kodfod, said that he was trying to do something similar and was able to get collision between the cube and player to work but the player could not see the cube itself. He currently hasn't told me how he did it.
     
  8. Wulf

    Wulf Community Admin

    Yeah, that was what I was thinking would happen.
     
  9. I'll keep this thread updated if I discover anything.

    Do you know how to use RPC in a plugin?
     
  10. Wulf

    Wulf Community Admin

    There are many RPCs, so you'd have to be more specific.
     
  11. Can you give some examples? I haven't really looked into RPCs, I just know they exist.
     
  12. Wulf

    Wulf Community Admin

    There are quite a few, I'd recommend looking through the Assembly-CSharp.dll.
     
  13. Well I found NetworkEntityManagerPlayerServer that has an RPC method which is why I brought this question up. Is that what I should be looking for?
     
  14. How we spawn entities on the client and server (so both know about each other) is through NetworkManager.Instance.Instantiate. However, there are a few requirements for that to work:

    • Your object must have a uLink.NetworkView component attached on both proxy and server versions
    • Your server object must have a NetworkInstantiateConfig component attached. This tells the game about what object the client should spawn to represent this server object, and handles network lodding/pooling
    • You must add the server object network view to the array NetworkObjectPool.Instance.NetworkPrefabObjects
    Only then will NetworkManager.Instance.Instantiate work correctly. Note that if you don't want to have different server/client objects, you can just leave the approriate fields blank in NetworkInstantiateConfig.

    I'm not entirely sure if this will work at runtime. Let me do a quick experiment to find out.

    Edit: Having a play around, I can't see an easy way to do this. I'll keep having a poke around though. The biggest problem is that both client and server have to know about an object to instantiate it, and there's currently no method for propagating that information from server to client.

    This is definitely something we want to support though!
     
    Last edited by a moderator: Jan 13, 2016