Capture the point

How do i make it so that when i use these scripts they would work in multiplayer? right now the color change isnt visible in different clients

2660796–187606–CaptureController.js (2.42 KB)
2660796–187607–FlagCapture.js (535 Bytes)

You have nothing wrong with your capturecontroler - you just need to atache the script to player 1, 2 and so on. Also what do you mean by the color change isnt visible in different clients

what multiplayer framework are you using?

He dosent have one right now @LeflyRighty

the capturecontroller script manages the capturing of the point it goes to the empty gameobject. the player is the one who interacts with the script but the script doesnt go on to the player. i mean the flag starts grey for both of the players. but when i capture the point as a red tagged player then the flag turns red for me but not for my build. my build’s flag color is still grey. how can i make it so that the flag is red for my build also?

for me you mean the game but not in the editor?

If you want - I could colab via skype or unity messenging service.

yes. but its the same in the opposite also

you need to change the properties so that it shows in the editor and and game view then.?.?

you dont get it. when anyone captures the point only the guy who captures it sees the change. Now i want to know how to make it that everyone sees what the only guy saw. i think it has something to do with rpc

once again, what multiplayer framework are you using? there is nothing in either of those scripts which does anything with multiple clients. If you are making a multiplayer game you need to implement some sort of framework to handle the clients, something like uNet or Proton…

im using uNet

ok, might I suggest changing to using c# rather than unityscript then? the documentation and support of uNet is pretty much only in c#… :frowning:

I’ve only touched on uNet briefly but I believe you should start here: http://docs.unity3d.com/Manual/UNetStateSync.html

I’m trying to use c# but the capture controller was the only script available and i dont know how to translate js to c#

it’s mostly syntax tweaks, and knowing that unityscript automatically declares a class per script you write in js, so in c# you need to do the class declaration explicitly

//// unityscript top of file ////
#pragma strict


//// c# top of file ////
using UnityEngine; // need this
using System.Collections; // don't always need this but it's in the default template

// class matches file name if you inherit from MonoBehaviour, if it's uNet this should be NetworkBehaviour
public class CaptureController : MonoBehaviour
{



//// unityscript variable declaration and initialisation ////
var blueTeam : boolean = false;
[accessor(default public)] var [name] : [type] = [default value];
// c# variable declaration and initialisation
public boolean blueTeam = false
[accessor(default private)][type][name] = [default value];

//// unityscript function ////
function Start()
{
[accessor(unity hook function so its irrelevant because "magic", default public)] function [functionname](<paramenters>) : [return type, nothing => leave off]

//// c# function ////
void Start()
{
[accessor(unity hook function so its irrelevant because "magic"), default private][return type, nothing => "void"][functionname](<paramenters>)


//// unityscript getcomponent ////
flagRed.GetComponent(MeshRenderer).enabled = false;

// c# getcomponent I prefer to use the generic form for typing
flagRed.GetComponent<MeshRenderer>().enabled = false;
// unityscript can also do generics, note the . before the <
flagRed.GetComponent.<MeshRenderer>().enabled = false;





// probably want to go with canvas since it's going to have a lot better support with uNet integration, it's the future
function OnGUI()
{
    GUI.Box(Rect(10, 10, 300, 25),"Red Cap" + " " + redcapturePerc.ToString("0") + " " + "Blue Cap" + " " + bluecapturePerc.ToString("0"));
}

when you typed c# top of file you mean [requirecomponent of?] what about unityscript top of file? first time hearing that

as in " the text at the top of the file" unityscript you just have the strict compiler instruction, in c# you need the “using” directives and the class declaration. But yes, things like “RequireComponent” go between the “usings” and the class declaration. Edited to make the “sections” stand out from the general “comments” a little bit :slight_smile:

I’ll try to translate it into c# somehow… im probably gonna make some errors though

using UnityEngine; // need this
using System.Collections; // don't always need this but it's in the default template

// class matches file name if you inherit from MonoBehaviour, if it's uNet this should be NetworkBehaviour
             // script name is CapController so this has to be CapController also?
public class CapController : MonoBehaviour // ill make this NetworkBehaviour when i get done with MonoBehaviour
{
    //I'll try singleplayer first

    //Team variables think this is also correct
    public bool blueTeam = false;
    public bool redTeam = false;

    //capture percentage default value | i think this is correct
    private float redcaptureperc = 0;
    private float bluecaptureperc = 0;

    //flag variables  how do i declare them as gameobjects?
    public bool flagRed;
    public bool flagBlue;
    public bool flagNeutral;

    //How do i declare particles in c# are they still mists?
    //red particle to do
    //blue particle to do
    //neutral particile to do



    //[accessor(default private)][type] | i dont know what this is
    //[name] = [default value]; | or this.. but i think its something to do with classes right?

    //// c# function ////
    void Start()
    { //why is GetComponent in error here? | bool does not contain a definition for GetComponent
        flagNeutral.GetComponent<MeshRenderer>().enabled = true;
        //neutralparticle.getcomponent<Renderer>().enabled = true; | to do
    }
    //[accessor(unity hook function so its irrelevant because "magic"), default private][return type, nothing => "void"] what is this?
    //[functionname](<paramenters>)
    void Update()
    {
        if (blueTeam == true)
        {
            bluecaptureperc += Time.deltaTime * 20;
            redcaptureperc -= Time.deltaTime * 20;
        }

        if (redTeam == true)
        {
            redcaptureperc += Time.deltaTime * 20;
            bluecaptureperc -= Time.deltaTime * 20;
        }

        if (redTeam == true && blueTeam == true)
        {
            redcaptureperc = redcaptureperc;
            bluecaptureperc = bluecaptureperc;
        }

        if (redcaptureperc >= 100)
        {
            redcaptureperc = 100;
            flagRed.GetComponent<MeshRenderer>().enabled = true;      // bool does not contain a definition for GetComponent???
            flagBlue.GetComponent<MeshRenderer>().enabled = false;    // bool does not contain a definition for GetComponent???
            flagNeutral.GetComponent<MeshRenderer>().enabled = false; // bool does not contain a definition for GetComponent???

            //redparticle.GetComponent<Renderer>.enabled = true;
            //blueparticle.GetComponent<Renderer>.enabled = false;
            //neutralparticle.GetComponent<Renderer>.enabled = false; | still dont know how to declare the particle system is it public bool [ParticleSystem] [particlesystemname]?
        }

        if (bluecaptureperc >= 100)
        {
            bluecaptureperc = 100;
            flagRed.GetComponent<MeshRenderer>().enabled = false;
            flagBlue.GetComponent<MeshRenderer>().enabled = true;
            flagNeutral.GetComponent<MeshRenderer>().enabled = false; //| still the same error..

            //particleRed.GetComponent<Renderer>().enabled = false;
            //particleBlue.GetComponent<Renderer>().enabled = true;
            //particleNeutral.GetComponent<Renderer>().enabled = false;
        }

        if (redcaptureperc <= 50 && bluecaptureperc <= 51)
        {
            flagRed.GetComponent<MeshRenderer>().enabled = false;
            flagBlue.GetComponent<MeshRenderer>().enabled = false;
            flagNeutral.GetComponent<MeshRenderer>().enabled = true;   // still the same error...

            // particleRed.GetComponent<Renderer>().enabled = false;
            // particleBlue.GetComponent<Renderer>().enabled = false;
            // particleNeutral.GetComponent<Renderer>().enabled = true;
        }

        if (redcaptureperc <= 0)
        {
            redcaptureperc = 0;
        }

        if (bluecaptureperc <= 0)
        {
            bluecaptureperc = 0;
        }

    }
}





// probably want to go with canvas since it's going to have a lot better support with uNet integration, it's the future

//How do i declare canvas? void OnCanvas?()
/*
function OnGUI()
    {
        GUI.Box(Rect(10, 10, 300, 25), "Red Cap" + " " + redcaptureperc.ToString("0") + " " + "Blue Cap" + " " + bluecaptureperc.ToString("0"));
    }/*


    // How good did i do? 11 errors. not bad right?..right?

EDIT: should i add requirecomponent of the unityscript FlagCapture?
EDIT2: this is kind of wrong since i cant add the gameobjects to the inspector now what should i do? [SerializeField]?

Having alot more trouble with the FlagCapture convertion im actually stuck… ill finish for today.