// Start is called before the first frame update
    void Start()
    {
        firstPerson_View    = transform.Find("FPS View").transform;
        characterController = GetComponent <CharacterController>();
        speed     = walkSpeed;
        is_Moving = false;

        rayDistance = characterController.height * 0.5f + characterController.radius;
        default_ControllerHeight = characterController.height;
        default_CamPos           = firstPerson_View.localPosition;

        playerAnimation = GetComponent <FPSPlayerAnimations>();
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        firstPerson_View = transform.Find("FPS View").transform;
        charController   = GetComponent <CharacterController> ();
        speed            = walkSpeed;
        is_Moving        = false;

        rayDistance = charController.height * 0.5f + charController.radius;
        default_ControllerHeight = charController.height;
        default_CamPos           = firstPerson_View.localPosition;

        playerAnimation = GetComponent <FPSPlayerAnimations> ();
        weapon_manage.weapons [0].SetActive(true);
        current_Weapon = weapon_manage.weapons [0].GetComponent <FPSWeapon> ();

        handsWeapon_Manager.weapons [0].SetActive(true);
        current_Hands_Weapon = handsWeapon_Manager.weapons [0].GetComponent <FPSHandsWeapon> ();

        if (isLocalPlayer)
        {
            playerHolder.layer = LayerMask.NameToLayer("Player");
            foreach (Transform child in playerHolder.transform)
            {
                child.gameObject.layer = LayerMask.NameToLayer("Player");
            }
            for (int i = 0; i < weapons_FPS.Length; i++)
            {
                weapons_FPS [i].layer = LayerMask.NameToLayer("Player");
            }

            weaponsHolder.layer = LayerMask.NameToLayer("Enemy");

            foreach (Transform child in weaponsHolder.transform)
            {
                child.gameObject.layer = LayerMask.NameToLayer("Enemy");
            }
        }

        if (!isLocalPlayer)
        {
            playerHolder.layer = LayerMask.NameToLayer("Enemy");
            foreach (Transform child in playerHolder.transform)
            {
                child.gameObject.layer = LayerMask.NameToLayer("Enemy");
            }
            for (int i = 0; i < weapons_FPS.Length; i++)
            {
                weapons_FPS [i].layer = LayerMask.NameToLayer("Enemy");
            }

            weaponsHolder.layer = LayerMask.NameToLayer("Player");

            foreach (Transform child in weaponsHolder.transform)
            {
                child.gameObject.layer = LayerMask.NameToLayer("Player");
            }
        }

        if (!isLocalPlayer)
        {
            for (int i = 0; i < mouseLook.Length; i++)
            {
                mouseLook [i].enabled = false;
            }
        }
        mainCam = transform.Find("FPS View").Find("FPS Camera").GetComponent <Camera> ();
        mainCam.gameObject.SetActive(false);

        if (!isLocalPlayer)
        {
            for (int i = 0; i < PlayerRender.materials.Length; i++)
            {
                PlayerRender.materials [i].color = playerColors [i];
            }
        }
    }
Ejemplo n.º 3
0
    void Start () {
        // Find is not optimal
        firstPerson_View = transform.Find ("FPS View").transform;
        charController = GetComponent<CharacterController> ();
        speed = walkSpeed;
        isMoving = false;

        rayDistance = charController.height * 0.5f + charController.radius;
        default_ControllerHeight = charController.height;
        default_CameraPosition = firstPerson_View.localPosition;

        playerAnimations = GetComponent<FPSPlayerAnimations> ();

        weaponManager.weapons[0].SetActive (true);
        currentWeapon = weaponManager.weapons[0].GetComponent<FPSWeapon> ();

        handsWeaponManager.weapons[0].SetActive (true);
        currentHandsWeapon = handsWeaponManager.weapons[0].GetComponent<FPSHandsWeapon> ();

        if (isLocalPlayer) {
            playerHolder.layer = LayerMask.NameToLayer ("Player");

            foreach (Transform child in playerHolder.transform) {
                child.gameObject.layer = LayerMask.NameToLayer ("Player");
            }

            for (int i = 0; i < weaponsFPS.Length; i++) {
                weaponsFPS[i].layer = LayerMask.NameToLayer ("Player");
            }

            weaponsHolder.layer = LayerMask.NameToLayer ("Enemy");

            foreach (Transform child in weaponsHolder.transform) {
                child.gameObject.layer = LayerMask.NameToLayer ("Enemy");
            }
        }

        if (!isLocalPlayer) {
            playerHolder.layer = LayerMask.NameToLayer ("Enemy");

            foreach (Transform child in playerHolder.transform) {
                child.gameObject.layer = LayerMask.NameToLayer ("Enemy");
            }

            for (int i = 0; i < weaponsFPS.Length; i++) {
                weaponsFPS[i].layer = LayerMask.NameToLayer ("Enemy");
            }

            weaponsHolder.layer = LayerMask.NameToLayer ("Player");

            foreach (Transform child in weaponsHolder.transform) {
                child.gameObject.layer = LayerMask.NameToLayer ("Player");
            }
        }

        if (!isLocalPlayer) {
            for (int i = 0; i < mouseLook.Length; i++) {
                mouseLook[i].enabled = false;
            }
        }

        // Deactivates all FPS Cameras
        mainCam = transform.Find ("FPS View").Find ("FPS Camera").GetComponent<Camera> ();
        mainCam.gameObject.SetActive (false);

        if (!isLocalPlayer) {
            for (int i = 0; i < playerRenderer1.materials.Length; i++) {
                //playerRenderer1.materials[i].color = playerColors[i];
                //playerRenderer2.materials[i].color = playerColors[i];
                //playerRenderer3.materials[i].color = playerColors[i];

                // Players on server are set to delta skin
                playerRenderer1.material = delta;
                playerRenderer2.material = delta;
                playerRenderer3.material = delta;
            }
        } else {
            // Local player is set to swat skin
            playerRenderer1.material = swat;
            playerRenderer2.material = swat;
            playerRenderer3.material = swat;
        }

    }
Ejemplo n.º 4
0
    void Start()
    {
        firstPerson_view  = transform.Find("FPS VIEW").transform;
        charController    = GetComponent <CharacterController> ();
        speed             = walkSpeed;
        is_moving         = false;
        isShooting.value  = 1;
        reloadNoification = GameObject.Find("ReloadNotification");
        reloadNoification.GetComponent <Animator>().enabled = false;
        reloadNoification.transform.localScale = Vector3.zero;
        rayDistance = charController.height * 0.5f + charController.radius;
        default_controllerHeight = charController.height;
        default_CamPos           = firstPerson_view.localPosition;
        playerAnimations         = GetComponent <FPSPlayerAnimations>();
        weapon_Manager.weapons[0].SetActive(true);
        current_Weapon = weapon_Manager.weapons[0].GetComponent <FPSWeapon>();
        handsWeapon_Manager.weapons[0].SetActive(true);
        if (isFpsActive)
        {
            current_hands_Weapon = handsWeapon_Manager.weapons[0].GetComponent <FPSHandsWeapon> ();
        }



        // if(isLocalPlayer) {
        //     playerHolder.layer = LayerMask.NameToLayer ("Player");

        //     foreach (Transform child in playerHolder.transform) {
        //         child.gameObject.layer = LayerMask.NameToLayer ("Player");
        //     }
        //     for(int i = 0; i < weapons_FPS.Length; i++) {
        //         weapons_FPS [i].layer = LayerMask.NameToLayer("Player");
        //     }
        //     weaponsHolder.layer = LayerMask.NameToLayer ("Enemy");

        //     foreach(Transform child in weaponsHolder.transform) {
        //         child.gameObject.layer = LayerMask.NameToLayer("Enemy");
        //     }

        // }
        // if(!isLocalPlayer) {
        //     playerHolder.layer = LayerMask.NameToLayer ("Enemy");

        //     foreach (Transform child in playerHolder.transform) {
        //         child.gameObject.layer = LayerMask.NameToLayer ("Enemy");
        //     }
        //     for(int i = 0; i < weapons_FPS.Length; i++) {
        //         weapons_FPS [i].layer = LayerMask.NameToLayer("Enemy");
        //     }
        //     weaponsHolder.layer = LayerMask.NameToLayer ("Player");

        //     foreach(Transform child in weaponsHolder.transform) {
        //         child.gameObject.layer = LayerMask.NameToLayer("Player");
        //     }
        // }

        if (!isLocalPlayer)
        {
            for (int i = 0; i < mouseLooks.Length; i++)
            {
                mouseLooks[i].enabled = false;
            }
        }
        mainCam = transform.Find("FPS VIEW").Find("FPS Camera").GetComponent <Camera>();
        mainCam.gameObject.SetActive(false);

        if (!isLocalPlayer)
        {
            tag = "Enemy";
            for (int i = 0; i < playererRendered.materials.Length; i++)
            {
                /// RANDOM SKIN IN FUTURE;
            }
        }
    }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        firstPersonView = transform.Find("FPS View").transform;

        charController = GetComponent <CharacterController> ();

        speed = walkSpeed;

        isMoving = false;

        rayDistance = charController.height * 0.5f + charController.radius;

        defaultControllerHeight = charController.height;

        defaultCamPos = firstPersonView.localPosition;

        playerAnimations = GetComponent <FPSPlayerAnimations> ();

        weaponsManager.weapons [0].SetActive(true);

        currentWeapon = weaponsManager.weapons [0].GetComponent <FPSWeapon> ();

        handsWeaponsManager.weapons [0].SetActive(true);

        currentHandsWeapon = handsWeaponsManager.weapons [0].GetComponent <FPSHandsWeapon> ();

        // Change the view based on whether or not the current player
        // is a local player or a remote player
        if (isLocalPlayer)
        {
            playerHolder.layer = LayerMask.NameToLayer("Player");

            foreach (Transform child in playerHolder.transform)
            {
                child.gameObject.layer = LayerMask.NameToLayer("Player");
            }

            for (int i = 0; i < weaponsFPS.Length; i++)
            {
                weaponsFPS [i].layer = LayerMask.NameToLayer("Player");
            }

            weaponsHolder.layer = LayerMask.NameToLayer("Enemy");

            foreach (Transform child in weaponsHolder.transform)
            {
                child.gameObject.layer = LayerMask.NameToLayer("Enemy");
            }
        }
        else
        {
            playerHolder.layer = LayerMask.NameToLayer("Enemy");

            foreach (Transform child in playerHolder.transform)
            {
                child.gameObject.layer = LayerMask.NameToLayer("Enemy");
            }

            for (int i = 0; i < weaponsFPS.Length; i++)
            {
                weaponsFPS [i].layer = LayerMask.NameToLayer("Enemy");
            }

            weaponsHolder.layer = LayerMask.NameToLayer("Player");

            foreach (Transform child in weaponsHolder.transform)
            {
                child.gameObject.layer = LayerMask.NameToLayer("Player");
            }
        }

        if (!isLocalPlayer)
        {
            for (int i = 0; i < mouseLook.Length; i++)
            {
                mouseLook [i].enabled = false;
            }
        }

        mainCam = transform.Find("FPS View").Find("FPS Camera").GetComponent <Camera> ();
        mainCam.gameObject.SetActive(false);
    }