Hey guys!
I’m using uLink, using a authorotative server for my “game”, and I’m getting errors in the console. What I’m trying to achieve is making a script to Instatiate objects from the server side!
I based my script on this one that uLink provides to instatiante players on server start
using uLink;
using UnityEngine;
using System.Collections;
public class Spawner : uLink.MonoBehaviour {
//************************************************************************************************
// Owner is the actual player using the client Scene. It has animations + camera.
// OwnerInit.cs connects the owner to the camera.
//
// Proxy is what appears on the the opponent players computers, It has animations but no camera connection.
//
// Creator is instansiated in the server and it has no camera. It has the animation script, but it has been
// deactivated. Just turn it on if you really do want to see animations on the server.
//************************************************************************************************
public GameObject proxyPrefab = null;
public GameObject ownerPrefab = null;
public GameObject creatorPrefab = null;
public GameObject spawnLocation = null;
void uLink_OnPlayerConnected(uLink.NetworkPlayer player){
string loginName;
if(!player.loginData.TryRead<string>(out loginName)) loginName = "Nameless";
//Instantiates an avatar for the player connecting to the server
//The player will be the "owner" of this object. Read the manual chapter 7 for more
//info about object roles: Creator, Owner and Proxy.
uLink.Network.Instantiate(player, proxyPrefab, ownerPrefab, creatorPrefab, spawnLocation.transform.position, spawnLocation.transform.rotation, 0, loginName);
}
}
And this is the script that I wrote so far, but keep getting errors.
using uLink;
using UnityEngine;
using System.Collections;
public class CrateSpawner : uLink.MonoBehaviour {
public GameObject ownerCrate = null;
public GameObject proxyCrate = null;
public GameObject creatorCrate = null;
public GameObject spawnCrateLocation = null;
// Use this for initialization
void Start () {
uLink.Network.Instantiate (ownerCrate, proxyCrate, creatorCrate, spawnCrateLocation.transform.position, spawnCrateLocation.transform.rotation, 0);
}
// Update is called once per frame
void Update () {
}
}
These are the errors that appear on the console:
Assets/Scripts/CrateSpawner.cs(15,31): error CS1502: The best overloaded method match for `uLink.Network.Instantiate(UnityEngine.GameObject, UnityEngine.GameObject, UnityEngine.Vector3, UnityEngine.Quaternion, uLink.NetworkGroup, params object)’ has some invalid arguments
Assets/Scripts/CrateSpawner.cs(15,31): error CS1503: Argument #3' cannot convert
UnityEngine.GameObject’ expression to type `UnityEngine.Vector3’
I’ve tryed different stuff in the code and searched all over the internet with no luck, so I hope some of you guys can help me!
Thank you!