• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Forte259 · Feb 15, 2014 at 08:32 PM · instantiateobjectspawnserverulink

Problem with Intantiate using uLink!

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!

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Evilcool · Apr 11, 2015 at 06:54 PM

I think this error happends when you try to send an object over the network that can't be serialized, just from experience I don't see anything weird in the script maybe the error is else where.

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by LegendaryG · Apr 18, 2015 at 08:35 PM

uLink.Network.Instantiate(player, proxyPrefab, ownerPrefab, creatorPrefab, spawnLocation.transform.position, spawnLocation.transform.rotation, 0, loginName);

uLink.Network.Instantiate (ownerCrate, proxyCrate, creatorCrate, spawnCrateLocation.transform.position, spawnCrateLocation.transform.rotation, 0);

uLink.Network.Instantiate(UnityEngine.GameObject, UnityEngine.GameObject, UnityEngine.Vector3, UnityEngine.Quaternion, uLink.NetworkGroup, params object[]) Argument #3' cannot convert UnityEngine.GameObject' expression to type UnityEngine.Vector3'

In Cratespawner, try changing the 3rd argument to a Vector3. uLink.Instatiate() has like 34 different ways you can use it, so try another way

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.

For more information, please read our full announcement.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Spawning different random objects at the same position? 2 Answers

How to spawn different object from Prefabs folder 0 Answers

Client/Server Network Instantiate Problems/Client Can't Connect 0 Answers

Give object velocity based on spawn object rotation? 2 Answers

Spawning objects at points within another object? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges