Author Topic: Network is server logic and network instantiate  (Read 8145 times)


  • Playmaker Newbie
  • *
  • Posts: 2
Network is server logic and network instantiate
« on: March 27, 2011, 02:49:05 PM »

maybe a check of ownership too on network objects would be cool too

« Last Edit: March 27, 2011, 02:52:56 PM by DJAZLAR »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: Network is server logic and network instantiate
« Reply #1 on: April 01, 2011, 08:51:40 AM »
I need to spend more time with unity's networking. Right now I'm not sure I'd know how to test it properly! Do you have simple test projects?


  • Playmaker Newbie
  • *
  • Posts: 2
Re: Network is server logic and network instantiate
« Reply #2 on: April 02, 2011, 05:15:37 PM »
Hi Alex,

one simple action could have check boxes for these various actions.
basically the network instantiate works the same as instantiate it works like a buffered rpc and creates a universal gameObject in the scene, and whoever calls the command becomes the owner of the gameObject.
With unity networking only the owner can move the object in the game.
So if i spawned a ship as an example i could fly it and everyone in the network would see it.
if someone else spawned one then i could still fly it but when i took off noone else in the game would see the movement as i dont have the ownership of the gameObject so updates dont workand everyone else would see it where it was last moved by the owner.

an example of RPC implementation is below

Code: [Select]
private var lastPosition : Vector3;
private var lastRotation : Quaternion;
public var owner : NetworkPlayer;

var newPos : Vector3;
var newRot : Quaternion;

function Update(){

///if u only wanted the server itself to check for movement you could add the line underneath or you could add a function OnserverInitialised before the function update like this "function OnServerInitialized(){" and that function is only run on server only also as u see below "if (Network.isClient) {"
////if (Network.isServer) {
///if (Network.isClient) {
if(Vector3.Distance(transform.position, lastPosition)>=0.05){
lastPosition=transform.position;   ////check for movements

networkView.RPC("SetPosition", RPCMode.Others, transform.position, transform.rotation); ////This is the RPC call to Others in the network basically every object containing this script will recieve this msg and then look at the @RPC where the function called SetPosition is then executed

function SetPosition(newPos : Vector3, newRot : Quaternion){

transform.rotation = newRot;


unity networking is starting to make a lot of sense to me now and im sure this would help you a little in some understanding of the basics.
the most important feature of networking is if (networkView.isMine){    usage as below if u put this on a player the gameObject is only spawned at your characters position and noone else in the network game yet if u miss that line out it then spawns a copy of the object at your position for every client.

Code: [Select]
var missile : Transform;

if (networkView.isMine){
Network.Instantiate(missile,transform.position, transform.rotation, 0);

I aint the best for networking but i have learned a lot of the implementations and how to use them now

« Last Edit: April 02, 2011, 05:44:52 PM by DJAZLAR »


  • Junior Playmaker
  • **
  • Posts: 88
Re: Network is server logic and network instantiate
« Reply #3 on: April 04, 2011, 08:32:05 AM »
networking with playmaker would be awesome, i couldn't find it on the roadmap anymore, is it still planned?