Adding Monsters Cloud Documents

Options
[Deleted User]
edited February 2012 in Photon Server
I am having difficulty with the Adding Monsters portion of the documentation for the Cloud.
I downloaded the same monster that you used in the example.

The line is: GameObject monster = PhotonNetwork.Instantiate("monsterprefab", Vector3.zero, Quaternion.identity, 0);

Here is how I typed it in the code Editor of Unity
//Joining a room
void OnJoinedRoom() {
GameObject monster = PhotonNetwork.Instantiate("monsterprefab", Vector3.zero, Quaternion.identity, 0);
}
The error Im getting and unable to chase down is:

Assets/Photon Unity Networking/Marco Polo/RandomMatchmaker.cs(30,44): error CS1502: The best overloaded method match for `PhotonNetwork.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion, int)' has some invalid arguments

Assets/Photon Unity Networking/Marco Polo/RandomMatchmaker.cs(30,44): error CS1503: Argument `#1' cannot convert `string' expression to type `UnityEngine.Object'

Thank you for your help!

Comments

  • dreamora
    Options
    you must provide a reference to the prefab to instantiate, you can't provide the name
  • Tobias
    Options
    Merries: dreamora is right.
    The explanation for this is: I am using a newer PUN version which allows you to pass a string to Instantiate.
    Add a public GameObject variable to the script, add the reference (drag & drop the prefab) and use that in Instantiate.

    PUN 1.9 is in the door but not yet out. I had to upload the doc to have the url for a newletter that's coming, too.
  • I'm also following this tutorial and am having trouble following this step in the Smooth Moves section:
    Create a “NetworkCharacter” C# script in the Marco Polo folder. Add it to the “monsterprefab” and make it the observed component of the PhotonView (drag & drop).

    I'm not able to make a script the observed component, is this because I am using an earlier version of PUN?

    Thanks
  • dreamora
    Options
    you likely did not try it the right way.
    you need to add the behaviour to the game object and then drag the 'title' of the behaviour into the observed slot
  • Thanks dreamora, that was indeed the issue.
  • Tobias
    Options
    Update:
    PUN v1.9 is out and you can now pass a prefab as string name like in the example.
    Here's the link to what we talk about here:
    http://doc.exitgames.com/v3/photonunity ... lotutorial