Marco Polo Character Control

Hello, I was trying to follow this step, but not sure exactly how this works. It was done for this then done for myThirdPersonController. I'm stuck in figuring out how to make the scripts available. I followed this the best I could, and it didn't work for me. Hope someone can help me with this.

http://doc.exitgames.com/photon-cloud/M ... c317517599

Fight for Control

Checking the progress with two clients, we notice that all monsters are moved by our key input and the camera won't behave. We cloned the monster including all components that handle input and camera.

There are countless ways to solve this. One simple way is to disable the CharacterControl and CharacterCamera components of the “monsterprefab” (!) and enable them only for “our” monster instance. Instantiate returns the GameObject it created, so this is no big deal. Aside from one handicap: Both scripts are written in UnityScript and our C# code does not know them yet.

To make any script of one language available to the scripts of another language, you can move it to a “Plugins” folder in your project. So rename the "Scripts" folder from the Monster package to "Plugins" and move it to the root of the project (drag & drop in the editor).

After instantiating our monster, we can now grab the components CharacterControl and CharacterCamera and activate both (for our monster only).

void OnJoinedRoom()
{
GameObject monster = PhotonNetwork.Instantiate("monsterprefab", Vector3.zero, Quaternion.identity, 0);
CharacterControl controller = monster.GetComponent<CharacterControl>();
controller.enabled = true;
CharacterCamera camera = monster.GetComponent<CharacterCamera>();
camera.enabled = true;
}

Thanks!

Comments

  • Please provide some info about the problems you have. Copy and pasting text from the tutorial doesn't tell us where you're stuck.
  • Sorry, I'm trying to get GetComponent for CharacterControl and CharacterCamera to compile. Says type or namespace can't be found.

    void OnJoinedRoom()
    {
    GameObject monster = PhotonNetwork.Instantiate("monsterprefab", Vector3.zero, Quaternion.identity, 0);
    CharacterControl controller = monster.GetComponent<CharacterControl>();
    controller.enabled = true;
    CharacterCamera camera = monster.GetComponent<CharacterCamera>();
    camera.enabled = true;
    }

    I did this step, but I think I'm missing something. Like how to use it in a C# script.
    To make any script of one language available to the scripts of another language, you can move it to a “Plugins” folder in your project. So rename the "Scripts" folder from the Monster package to "Plugins" and move it to the root of the project (drag & drop in the editor).
  • So you are struggling doing this in JS/UnityScript?
    In that case, CharacterControl might be a CS script, which must go into the plugins folder to be available in JS.

    Maybe you could do the examples in C#, then switch to JS? Actually, C# is not a lot harder and has benefits, too.
    At least I will have a hard time supporting you in JS.
  • I am doing this in C# and want to keep it that way for sure. Although based off the tutorial, I was confused in what is going on. The CharacterControl they made is a JS script. Can I move that into a plugins folder to be available in C#?
  • Yes, to make a JS script available to C#, put it a plugins folder in the root of the project.
    In worst case, the PUN package has a final version of the Marco Polo tutorial and there I only used C#, if I remember correctly (to avoid exactly the moving-around of files).
  • Thanks, that worked! I was putting the plugins folder in Marco Polo folder instead of Assets folder.
  • FutureFireplace
    edited May 2016
    At http://doc.photonengine.com/en-us/pun/current/tutorials/tutorial-marco-polo it claims that: "To make any script of one language available to the scripts of another language, you can move it to a “Plugins” folder in your project. So rename the "Scripts" folder from the Monster package to "Plugins" and move it to the root of the project (drag & drop in the editor)."

    When trying to do so, accordingly, it all breaks down -> as there is already a 'Plugins' in the root that contains essential scripts/files/classes:



    What should I do in order to follow the tutorial properly, and can you fix this in some way (fix it for my case at least, although I do foresee this to be a general problem)?
  • If there already is a Plugins folder, copy the content of one folder into the Assets\Plugins folder.
    The basic idea is that the scripts of PUN's "plugin" get compiled in a first step, before code in another language is being compiled.
    http://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html