Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

FPS Kit | Version 2.0

Discussion in 'Assets and Asset Store' started by NSdesignGames, Oct 2, 2012.

  1. ThrillKill

    ThrillKill

    Joined:
    Apr 7, 2014
    Posts:
    80
    When I say referencing I'm talking about referencing the values of other scripts and the PhotonHashtable.

    Code (csharp):
    1.  
    2. ConnectMenu script = target.GetComponent<ConnectMenu>();
    So lets say in your ConnectMenu.cs, when the player clicks on the prefab that was created you can reference this objects values.

    So this tells your ConnectMenu.cs what the name of the room was of the prefab the player clicked on. Since C# is all about objects and references you have to have a script on that prefab to hold UILabel details of that room so you can access it. You can't access the prefab values directly from ConnectMenu without something to reference first.

    so this:
    Code (csharp):
    1. script._ValueJoinSelectedroom.text = roomname.text;
    really means: In ConnectMenu.cs there is a UILabel called _ValueJoinSelectedroom which will become the value of whatever the name of the room thats on the grid so you can join that room.

    by doing this:
    Code (csharp):
    1. PhotonNetwork.JoinRoom (_ValueJoinSelectedroom.text); // Join the selected room
    For: customProperties["MapName"]
    If you recall when you create a map/room. These values are already set

    Code (csharp):
    1.  
    2.     Hashtable setMapName = new Hashtable(); // Setup a hashtable for PhotonNetwork Map settings
    3.      setMapName["MapName"] = allMaps[selectedMap].mapname; // Assigns the selected map name
    4.      setMapName["RoundDuration"] = roundDuration; // Assigns the round duration
    5.      setMapName["GameMode"] = gameMode; // Assigns the game mode
    6.      string[] exposedProps = new string[3]; // Creates a string to carry the information for PhotonNetwork room
    7.      exposedProps[0] = "MapName"; // For the map name
    8.      exposedProps[1] = "RoundDuration"; // For the round duration
    9.      exposedProps[2] = "GameMode"; // For the game mode
    So your just referencing these values from the PhotonHashtable.
    When you gather the rooms/maps that are currently created:
    Code (csharp):
    1. allRooms = PhotonNetwork.GetRoomList(); // Gets the list of rooms available on the PhotonNetwork
    From here:
    Code (csharp):
    1.  
    2.   if(allRooms != null && allRooms.Length > 0){ // Checks there are rooms created          
    3.        foreach(RoomInfo room in allRooms){ // run once for each room that is created
    So when its going through all the rooms/maps that are currently in progress it will add an item on the grid for each one then populate its UILabels from the values it pulls when it does this:
    Code (csharp):
    1.  
    2. GameObject addRoomObj = NGUITools.AddChild(_ValueJoinRoomGrid.gameObject, _ValueJoinroomPrefab); // creates a new Grid Item
    3.          UILabel[] labels = addRoomObj.GetComponentsInChildren<UILabel>(); // Gathers the values of the prefab labels
    4.          foreach (UILabel label in labels) { // Checks each label and assigns the values
    5.            switch (label.name)   { // Switch based on the name of the UILabel
    6.            case "RoomName":
    7.              label.text = room.name; // Name of the room that is created
    8.              break;
    So then this part references the UILabel's of the prefab. You want these: case "RoomName" to match what you called the UILabel on the prefab.

    So yeah that's that. Hope it helps.
     
    Last edited: Aug 6, 2014
    Freznosis likes this.
  2. BL Studios

    BL Studios

    Joined:
    Feb 18, 2014
    Posts:
    11
    @ThriKillI see that you are very good with Ngui, so you see you can help me with something, please.

    I'm replacing the entire GUI of unity to Ngui, but I have problems with the "scoreboard", I have no idea how to instantiate a UILabel with data from each player (kills, death, ping) and that each time one new player , is shown a new UILabel ..

    so you see you can help me thanks.
     
  3. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    @BL Studios You could just place a UILabel in your scene then set the internal value to the string of the UILabel.
    ThrillKill posted about it a while back.


    Example code (not tested)

    Declare
    _________
    Code (csharp):
    1.  
    2. public UILabel teamAScoreLabel;
    3. public UILabel teamBScoreLabel;
    4.  
    Call thread
    _________
    Code (csharp):
    1.  
    2. void Update(){
    3. //blahblah important code
    4. setScore();
    5. }
    6.  
    Show score
    _________
    Code (csharp):
    1.  
    2. setScore(){
    3. if(gameMode == "TDM"){
    4.             teamAScoreLabel.text = team_1.teamName + ": " + team1Score.ToString();
    5.             teamBScoreLabel.text = team_2.teamName + ": " + team2Score.ToString();
    6.             }
    7.             }
    8.  
     
  4. BL Studios

    BL Studios

    Joined:
    Feb 18, 2014
    Posts:
    11
    @ModularBuilds
    thank you very much for the help ..

    but rather I meant the "scoreboard" (the list of players per team ") and instantiate a UILabel for each player that enters the room .. I hope you can help me with this please ... thanks.
     
  5. Amer-ALhwifi

    Amer-ALhwifi

    Joined:
    Jul 4, 2012
    Posts:
    20
    Hello Guys ,

    There is a code that limit frame rate on 60FPS . How can i get access to it ? I want to change it , but actually i didn't find it ! .:(
     
  6. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Search the Unity documentation before you post. It's in the Quality settings.
     
  7. Amer-ALhwifi

    Amer-ALhwifi

    Joined:
    Jul 4, 2012
    Posts:
    20
    Sorrrrrrrrrrrrrry ! I totally forgot to check that ! Thank you so much !

    << I though there was a code Application.targetFrameRate = 60;

    Thanks again!
     
  8. Amer-ALhwifi

    Amer-ALhwifi

    Joined:
    Jul 4, 2012
    Posts:
    20
    Guys ,

    I was working with making a Reloading / Shooting animation to the Remote Player . I'm using the Mecanim Solution which Stan B. gave before - page 31 - .

    Anyway ,
    Code (CSharp):
    1.         if (Input.GetKeyDown(KeyCode.R)){
    2.             mecanimControl.CrossFade(Animations.Reload.name, 0.2f);
    3.             //Send animation name (needed for multiplayer)
    4.             animationSyncHelper = Animations.Reload.name;
    5.  
    Makes no change !

    Any idea ?
     
  9. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    Your problem is Input.GetKeyDown only gets called when you hold the R button, and the animation Idle gets called as soon as you let go of the reload button with the }else{. Test this out by holding the R button the next time you reload.
    What you can do to fix this is something along the lines of..

    Code (csharp):
    1.  
    2. if (Input.GetKey(KeyCode.R)){
    3.             mecanimControl.CrossFade(Animations.Reload.name, 0.2f);
    4.             //Send animation name (needed for multiplayer)
    5.             animationSyncHelper = Animations.Reload.name;
    6.             yield return new WaitForSeconds(Animations.Reload.length);
    7.             }
    8.  
     
  10. Amer-ALhwifi

    Amer-ALhwifi

    Joined:
    Jul 4, 2012
    Posts:
    20
    Thank you for your help sir .

    But i got an error with the code above .
    It said " error CS1624: The body of `CharacterAnimation.Reloading()' cannot be an iterator block because `void' is not an iterator interface type "

    Changing " void " to " IEnumerator" didn't make a change :( .
     
  11. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    Code works fine here?
    Can you post your code so I can look over it?
     
  12. Amer-ALhwifi

    Amer-ALhwifi

    Joined:
    Jul 4, 2012
    Posts:
    20
    Here it is :

    Code (CSharp):
    1. //NSdesignGames @ 2012 - 2014
    2. //FPS Kit | Version 2.0 + Multiplayer
    3.  
    4. using UnityEngine;
    5. using System.Collections;
    6. using System.Collections.Generic;
    7.  
    8. public class CharacterAnimation : MonoBehaviour {
    9.  
    10.     //This script will track of player input and than pass it over Network to remote instance through PlayerNetworkController.cs and than play then play animations remotely
    11.    
    12.     //Use this gameObject to send messages to AnimationSync.cs
    13.     [HideInInspector]
    14.     public string animationSyncHelper;
    15.     [HideInInspector]
    16.     public string animationForHands;
    17.     [HideInInspector]
    18.     public string activeWeapon; //This gameObject.name will tell PlayerNetworkController.cs which third person weapon is active now
    19.     [HideInInspector]
    20.     public string animationType; //Object that will send current animation type to PlayerNetworkController.cs
    21.  
    22.     public WeaponManager weaponManager;
    23.  
    24.     public enum Action {Stand, Crouch, Prone}
    25.     Action action;
    26.     MecanimControl mecanimControl;
    27.     [System.Serializable]
    28.     public class animations{
    29.         //Idle animations
    30.         public AnimationClip jumpPose;
    31.         public AnimationClip stayIdle;
    32.         public AnimationClip crouchIdle;
    33.         public AnimationClip proneIdle;
    34.         //Walk Animations
    35.         public AnimationClip walkFront;
    36.         public AnimationClip walkBack;
    37.         public AnimationClip walkLeft;
    38.         public AnimationClip walkRight;
    39.  
    40.         //Run animations
    41.         public AnimationClip runFront;
    42.         //Crouch animations
    43.         public AnimationClip crouchFront;
    44.         public AnimationClip crouchLeft;
    45.         public AnimationClip crouchRight;
    46.         public AnimationClip crouchBack;
    47.         //Prone Animations
    48.         public AnimationClip proneFront;
    49.         public AnimationClip proneLeft;
    50.         public AnimationClip proneRight;
    51.         public AnimationClip proneBack;
    52.         //Weapon animations
    53.         public AnimationClip pistolIdle;
    54.         public AnimationClip knifeIdle;
    55.         public AnimationClip gunIdle;
    56.         /*var fire : AnimationClip;
    57.         var reload : AnimationClip;*/
    58.         // Mecannim For Jumpping
    59.         public AnimationClip walkjump;
    60.         public AnimationClip runJump;
    61.         public AnimationClip Reload;
    62.         public AnimationClip Fire;
    63.  
    64.  
    65.         }
    66.  
    67.  
    68.  
    69.     WeaponScript weaponscript; // Are we shooting ? Reloading ?
    70.  
    71.     void Awake(){
    72.        
    73.         weaponscript = GetComponent <WeaponScript>(); // Defining WeaponScript
    74.     }
    75.  
    76.  
    77.     public animations Animations;
    78.    
    79.     public List<WeaponScript> twoHandedWeapons = new List<WeaponScript>();
    80.     public List<WeaponScript> pistols = new List<WeaponScript>();
    81.     public List<WeaponScript> knivesNades = new List<WeaponScript>();
    82.    
    83.     FPScontroller fpsController;
    84.    
    85.     void Start () {
    86.         mecanimControl = gameObject.GetComponent<MecanimControl>();
    87.         fpsController = transform.root.GetComponent<FPScontroller>();
    88.         configureAnimations();
    89.         if(weaponManager){
    90.             ThirdPersonWeaponControl();
    91.         }
    92.     }
    93.    
    94.     void LateUpdate () {
    95.         if(weaponManager.SelectedWeapon){
    96.             activeWeapon = weaponManager.SelectedWeapon.weaponName;
    97.         }
    98.         if(!fpsController.crouch && !fpsController.prone){
    99.             action = Action.Stand;
    100.         }else{
    101.             if(fpsController.crouch && !fpsController.prone){
    102.                 action = Action.Crouch;
    103.             }
    104.             if(!fpsController.crouch && fpsController.prone){
    105.                 action = Action.Prone;
    106.             }
    107.             if(fpsController.crouch && fpsController.prone){
    108.                 action = Action.Crouch;
    109.             }
    110.         }
    111.        
    112.         if(action == Action.Stand){
    113.             if(fpsController.grounded){
    114.                 if(fpsController.Walking){
    115.                     if(!fpsController.Running){
    116.                         animationType = "Walking";
    117.                         if(Input.GetAxis("Vertical") != 0) {
    118.                             mecanimControl.CrossFade(Animations.walkFront.name, 0.2f);
    119.                             //Send animation name (needed for multiplayer)
    120.                             animationSyncHelper = Animations.walkFront.name;
    121.                         }
    122.                         else if(Input.GetAxis("Horizontal") != 0 && !Input.GetKey(KeyCode.S)){
    123.                             mecanimControl.CrossFade(Animations.walkLeft.name, 0.2f);
    124.                             //Send animation name (needed for multiplayer)
    125.                             animationSyncHelper = Animations.walkLeft.name;
    126.                         }
    127.                         else if(Input.GetAxis("Horizontal") != 0  && !Input.GetKey(KeyCode.S)){
    128.                             animation.CrossFade(Animations.walkRight.name, 0.2f);
    129.                             //Send animation name (needed for multiplayer)
    130.                             animationSyncHelper = Animations.walkRight.name;
    131.                         }
    132.                         else if(Input.GetAxis("Vertical") != 0){
    133.                             mecanimControl.CrossFade(Animations.walkBack.name, 0.2f);
    134.                             //Send animation name (needed for multiplayer)
    135.                             animationSyncHelper = Animations.walkBack.name;
    136.                         }
    137.                         else if(Input.GetAxis("Vertical") != 0 && Input.GetKey(KeyCode.Space)) {
    138.                             mecanimControl.CrossFade(Animations.walkjump.name, 0.2f);
    139.                             //Send animation name (needed for multiplayer)
    140.                             animationSyncHelper = Animations.walkjump.name;
    141.                         }
    142.  
    143.                     }else{
    144.                         animationType = "Running";
    145.                         if( Input.GetKey(KeyCode.LeftShift) ){
    146.                             mecanimControl.CrossFade(Animations.runFront.name, 0.2f);
    147.                             //Send animation name (needed for multiplayer)
    148.                             animationSyncHelper = Animations.runFront.name;
    149.                         }
    150.                         else if( Input.GetKey(KeyCode.LeftShift) &&Input.GetKey(KeyCode.Space) ){
    151.                             mecanimControl.CrossFade(Animations.runJump.name, 0.2f);
    152.                             //Send animation name (needed for multiplayer)
    153.                             animationSyncHelper = Animations.runJump.name;
    154.                         }
    155.                     }
    156.                 }else{
    157.                     mecanimControl.CrossFade(Animations.stayIdle.name, 0.2f);
    158.                     //Send animation name (needed for multiplayer)
    159.                     animationSyncHelper = Animations.stayIdle.name;
    160.                 }
    161.             }else{
    162.                 mecanimControl.CrossFade(Animations.jumpPose.name, 0.2f);
    163.                 //Send animation name (needed for multiplayer)
    164.                 animationSyncHelper = Animations.jumpPose.name;
    165.             }
    166.         }
    167.         animationType = "Running";
    168.  
    169.         if (Input.GetMouseButton(0) && weaponscript.canFire &&weaponscript.singleFire ){
    170.             mecanimControl.CrossFade(Animations.Fire.name, 0.2f);
    171.             //Send animation name (needed for multiplayer)
    172.             animationSyncHelper = Animations.Fire.name;
    173.  
    174.         }
    175.  
    176.         if(action == Action.Crouch){
    177.             animationType = "Crouch";
    178.             if(fpsController.Walking ){
    179.                 if( Input.GetKey(KeyCode.W) ){
    180.                     mecanimControl.CrossFade(Animations.crouchFront.name, 0.2f);
    181.                     //Send animation name (needed for multiplayer)
    182.                     animationSyncHelper = Animations.crouchFront.name;
    183.                 }
    184.                 else if(Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S)){
    185.                     mecanimControl.CrossFade(Animations.crouchLeft.name, 0.2f);
    186.                     //Send animation name (needed for multiplayer)
    187.                     animationSyncHelper = Animations.crouchLeft.name;
    188.                 }
    189.                 else if( Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.S)){
    190.                     mecanimControl.CrossFade(Animations.crouchRight.name, 0.2f);
    191.                     //Send animation name (needed for multiplayer)
    192.                     animationSyncHelper = Animations.crouchRight.name;
    193.                 }
    194.                 else if(Input.GetKey(KeyCode.S)){
    195.                     mecanimControl.CrossFade(Animations.crouchBack.name, 0.2f);
    196.                     //Send animation name (needed for multiplayer)
    197.                     animationSyncHelper = Animations.crouchBack.name;
    198.                 }
    199.             }else{
    200.                 mecanimControl.CrossFade(Animations.crouchIdle.name, 0.2f);
    201.                 //Send animation name (needed for multiplayer)
    202.                 animationSyncHelper = Animations.crouchIdle.name;
    203.             }
    204.         }
    205.         if(action == Action.Prone){
    206.             animationType = "Prone";
    207.             if(fpsController.Walking ){
    208.                 if( Input.GetKey(KeyCode.W) ){
    209.                     mecanimControl.CrossFade(Animations.proneFront.name, 0.2f);
    210.                     //Send animation name (needed for multiplayer)
    211.                     animationSyncHelper = Animations.proneFront.name;
    212.                 }
    213.                 else if(Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S)){
    214.                     mecanimControl.CrossFade(Animations.proneLeft.name, 0.2f);
    215.                     //Send animation name (needed for multiplayer)
    216.                     animationSyncHelper = Animations.proneLeft.name;
    217.                 }
    218.                 else if( Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.S)){
    219.                     mecanimControl.CrossFade(Animations.proneRight.name, 0.2f);
    220.                     //Send animation name (needed for multiplayer)
    221.                     animationSyncHelper = Animations.proneRight.name;
    222.                 }
    223.                 else if(Input.GetKey(KeyCode.S)){
    224.                     mecanimControl.CrossFade(Animations.proneBack.name, 0.2f);
    225.                     //Send animation name (needed for multiplayer)
    226.                     animationSyncHelper = Animations.proneBack.name;
    227.                 }
    228.             }else{
    229.                 mecanimControl.CrossFade(Animations.proneIdle.name, 0.2f);
    230.                 //Send animation name (needed for multiplayer)
    231.                 animationSyncHelper = Animations.proneIdle.name;
    232.             }
    233.         }
    234.         ThirdPersonWeaponControl();
    235.     }
    236.    
    237.     void ThirdPersonWeaponControl(){
    238.         if(action != Action.Prone){
    239.             if(twoHandedWeapons.Contains(weaponManager.SelectedWeapon)){
    240.                 animationForHands = Animations.gunIdle.name;
    241.             }
    242.             else if(pistols.Contains(weaponManager.SelectedWeapon)){
    243.                 animationForHands = Animations.pistolIdle.name;
    244.             }
    245.             else if(knivesNades.Contains(weaponManager.SelectedWeapon)){
    246.                 animationForHands = Animations.knifeIdle.name;
    247.             }
    248.         }else{
    249.             animationForHands = "Null";
    250.         }
    251.     }
    252.    
    253.     void configureAnimations(){
    254.         //Set animations Wrap Mode and Speed
    255.         if(Animations.stayIdle){
    256.             animation[Animations.stayIdle.name].wrapMode = WrapMode.Loop;
    257.         }
    258.         if(Animations.crouchIdle){
    259.             animation[Animations.crouchIdle.name].wrapMode = WrapMode.Loop;
    260.         }
    261.         if(Animations.proneIdle){
    262.             animation[Animations.proneIdle.name].wrapMode = WrapMode.Loop;
    263.         }
    264.         if(Animations.walkFront){
    265.             animation[Animations.walkFront.name].wrapMode = WrapMode.Loop;
    266.             //animation[Animations.walkFront.name].speed = Animations.walkAnimationsSpeed;
    267.         }
    268.         if(Animations.walkBack){
    269.             animation[Animations.walkBack.name].wrapMode = WrapMode.Loop;
    270.             //animation[Animations.walkBack.name].speed = Animations.walkAnimationsSpeed;
    271.         }
    272.         if(Animations.walkLeft){
    273.             animation[Animations.walkLeft.name].wrapMode = WrapMode.Loop;
    274.             //animation[Animations.walkLeft.name].speed = Animations.walkAnimationsSpeed;
    275.         }
    276.         if(Animations.walkRight){
    277.             animation[Animations.walkRight.name].wrapMode = WrapMode.Loop;
    278.             //animation[Animations.walkRight.name].speed = Animations.walkAnimationsSpeed;
    279.         }
    280.         if(Animations.runFront){
    281.             animation[Animations.runFront.name].wrapMode = WrapMode.Loop;
    282.             //animation[Animations.runFront.name].speed = Animations.runAnimationsSpeed;
    283.         }
    284.         if(Animations.crouchFront){
    285.             animation[Animations.crouchFront.name].wrapMode = WrapMode.Loop;
    286.             //animation[Animations.crouchFront.name].speed = Animations.crouchAnimationsSpeed;
    287.         }
    288.         if(Animations.crouchLeft){
    289.             animation[Animations.crouchLeft.name].wrapMode = WrapMode.Loop;
    290.             //animation[Animations.crouchLeft.name].speed = Animations.crouchAnimationsSpeed;
    291.         }
    292.         if(Animations.crouchRight){
    293.             animation[Animations.crouchRight.name].wrapMode = WrapMode.Loop;
    294.             //animation[Animations.crouchRight.name].speed = Animations.crouchAnimationsSpeed;
    295.         }
    296.         if(Animations.crouchBack){
    297.             animation[Animations.crouchBack.name].wrapMode = WrapMode.Loop;
    298.             //animation[Animations.crouchBack.name].speed = Animations.crouchAnimationsSpeed;
    299.         }
    300.         if(Animations.proneFront){
    301.             animation[Animations.proneFront.name].wrapMode = WrapMode.Loop;
    302.             //animation[Animations.proneFront.name].speed = Animations.proneAnimationsSpeed;
    303.         }
    304.         if(Animations.proneLeft){
    305.             animation[Animations.proneLeft.name].wrapMode = WrapMode.Loop;
    306.             //animation[Animations.proneLeft.name].speed = Animations.proneAnimationsSpeed;
    307.         }
    308.         if(Animations.proneRight){
    309.             animation[Animations.proneRight.name].wrapMode = WrapMode.Loop;
    310.             //animation[Animations.proneRight.name].speed = Animations.proneAnimationsSpeed;
    311.         }
    312.         if(Animations.proneBack){
    313.             animation[Animations.proneBack.name].wrapMode = WrapMode.Loop;
    314.             //animation[Animations.proneBack.name].speed = Animations.proneAnimationsSpeed;
    315.         }
    316.     }
    317.  
    318.     void Reloading (){
    319.         if (Input.GetKey(KeyCode.R)){
    320.             mecanimControl.CrossFade(Animations.Reload.name, 0.2f);
    321.             //Send animation name (needed for multiplayer)
    322.             animationSyncHelper = Animations.Reload.name;
    323.             yield return new WaitForSeconds(Animations.Reload.length);
    324.         }      
    325.  
    326.     }
    327. }
    328.  
    Unfortunately , Every animation that i tried to add didn't work :( . I'm about to use your way after solving this strange problem .

    P.S : I tried to make it under the void " Late update " it's the same error too .

    P.S : Thank you so much !
     
  13. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    Your problem is when you change void to IEnumerator you cannot call the thread regularly, you must use StartCoroutine.

    Code (csharp):
    1.  
    2. //NSdesignGames @ 2012 - 2014
    3. //FPS Kit | Version 2.0 + Multiplayer
    4.  
    5. using UnityEngine;
    6. using System.Collections;
    7. using System.Collections.Generic;
    8.  
    9. public class CharacterAnimation : MonoBehaviour {
    10.  
    11.     //This script will track of player input and than pass it over Network to remote instance through PlayerNetworkController.cs and than play then play animations remotely
    12.  
    13.     //Use this gameObject to send messages to AnimationSync.cs
    14.     [HideInInspector]
    15.     public string animationSyncHelper;
    16.     [HideInInspector]
    17.     public string animationForHands;
    18.     [HideInInspector]
    19.     public string activeWeapon; //This gameObject.name will tell PlayerNetworkController.cs which third person weapon is active now
    20.     [HideInInspector]
    21.     public string animationType; //Object that will send current animation type to PlayerNetworkController.cs
    22.  
    23.     public WeaponManager weaponManager;
    24.  
    25.     public enum Action {Stand, Crouch, Prone}
    26.     Action action;
    27.     MecanimControl mecanimControl;
    28.     [System.Serializable]
    29.     public class animations{
    30.         //Idle animations
    31.         public AnimationClip jumpPose;
    32.         public AnimationClip stayIdle;
    33.         public AnimationClip crouchIdle;
    34.         public AnimationClip proneIdle;
    35.         //Walk Animations
    36.         public AnimationClip walkFront;
    37.         public AnimationClip walkBack;
    38.         public AnimationClip walkLeft;
    39.         public AnimationClip walkRight;
    40.  
    41.         //Run animations
    42.         public AnimationClip runFront;
    43.         //Crouch animations
    44.         public AnimationClip crouchFront;
    45.         public AnimationClip crouchLeft;
    46.         public AnimationClip crouchRight;
    47.         public AnimationClip crouchBack;
    48.         //Prone Animations
    49.         public AnimationClip proneFront;
    50.         public AnimationClip proneLeft;
    51.         public AnimationClip proneRight;
    52.         public AnimationClip proneBack;
    53.         //Weapon animations
    54.         public AnimationClip pistolIdle;
    55.         public AnimationClip knifeIdle;
    56.         public AnimationClip gunIdle;
    57.         /*var fire : AnimationClip;
    58.         var reload : AnimationClip;*/
    59.         // Mecannim For Jumpping
    60.         public AnimationClip walkjump;
    61.         public AnimationClip runJump;
    62.         public AnimationClip Reload;
    63.         public AnimationClip Fire;
    64.  
    65.  
    66.         }
    67.  
    68.  
    69.  
    70.     WeaponScript weaponscript; // Are we shooting ? Reloading ?
    71.  
    72.     void Awake(){
    73.      
    74.         weaponscript = GetComponent <WeaponScript>(); // Defining WeaponScript
    75.     }
    76.  
    77.  
    78.     public animations Animations;
    79.  
    80.     public List<WeaponScript> twoHandedWeapons = new List<WeaponScript>();
    81.     public List<WeaponScript> pistols = new List<WeaponScript>();
    82.     public List<WeaponScript> knivesNades = new List<WeaponScript>();
    83.  
    84.     FPScontroller fpsController;
    85.  
    86.     void Start () {
    87.         mecanimControl = gameObject.GetComponent<MecanimControl>();
    88.         fpsController = transform.root.GetComponent<FPScontroller>();
    89.         configureAnimations();
    90.         if(weaponManager){
    91.             StartCoroutine(ThirdPersonWeaponControl()); //StartCoroutine
    92.         }
    93.     }
    94.  
    95.     void LateUpdate () {
    96.         if(weaponManager.SelectedWeapon){
    97.             activeWeapon = weaponManager.SelectedWeapon.weaponName;
    98.         }
    99.         if(!fpsController.crouch && !fpsController.prone){
    100.             action = Action.Stand;
    101.         }else{
    102.             if(fpsController.crouch && !fpsController.prone){
    103.                 action = Action.Crouch;
    104.             }
    105.             if(!fpsController.crouch && fpsController.prone){
    106.                 action = Action.Prone;
    107.             }
    108.             if(fpsController.crouch && fpsController.prone){
    109.                 action = Action.Crouch;
    110.             }
    111.         }
    112.      
    113.         if(action == Action.Stand){
    114.             if(fpsController.grounded){
    115.                 if(fpsController.Walking){
    116.                     if(!fpsController.Running){
    117.                         animationType = "Walking";
    118.                         if(Input.GetAxis("Vertical") != 0) {
    119.                             mecanimControl.CrossFade(Animations.walkFront.name, 0.2f);
    120.                             //Send animation name (needed for multiplayer)
    121.                             animationSyncHelper = Animations.walkFront.name;
    122.                         }
    123.                         else if(Input.GetAxis("Horizontal") != 0 && !Input.GetKey(KeyCode.S)){
    124.                             mecanimControl.CrossFade(Animations.walkLeft.name, 0.2f);
    125.                             //Send animation name (needed for multiplayer)
    126.                             animationSyncHelper = Animations.walkLeft.name;
    127.                         }
    128.                         else if(Input.GetAxis("Horizontal") != 0  && !Input.GetKey(KeyCode.S)){
    129.                             animation.CrossFade(Animations.walkRight.name, 0.2f);
    130.                             //Send animation name (needed for multiplayer)
    131.                             animationSyncHelper = Animations.walkRight.name;
    132.                         }
    133.                         else if(Input.GetAxis("Vertical") != 0){
    134.                             mecanimControl.CrossFade(Animations.walkBack.name, 0.2f);
    135.                             //Send animation name (needed for multiplayer)
    136.                             animationSyncHelper = Animations.walkBack.name;
    137.                         }
    138.                         else if(Input.GetAxis("Vertical") != 0 && Input.GetKey(KeyCode.Space)) {
    139.                             mecanimControl.CrossFade(Animations.walkjump.name, 0.2f);
    140.                             //Send animation name (needed for multiplayer)
    141.                             animationSyncHelper = Animations.walkjump.name;
    142.                         }
    143.  
    144.                     }else{
    145.                         animationType = "Running";
    146.                         if( Input.GetKey(KeyCode.LeftShift) ){
    147.                             mecanimControl.CrossFade(Animations.runFront.name, 0.2f);
    148.                             //Send animation name (needed for multiplayer)
    149.                             animationSyncHelper = Animations.runFront.name;
    150.                         }
    151.                         else if( Input.GetKey(KeyCode.LeftShift) &&Input.GetKey(KeyCode.Space) ){
    152.                             mecanimControl.CrossFade(Animations.runJump.name, 0.2f);
    153.                             //Send animation name (needed for multiplayer)
    154.                             animationSyncHelper = Animations.runJump.name;
    155.                         }
    156.                     }
    157.                 }else{
    158.                     mecanimControl.CrossFade(Animations.stayIdle.name, 0.2f);
    159.                     //Send animation name (needed for multiplayer)
    160.                     animationSyncHelper = Animations.stayIdle.name;
    161.                 }
    162.             }else{
    163.                 mecanimControl.CrossFade(Animations.jumpPose.name, 0.2f);
    164.                 //Send animation name (needed for multiplayer)
    165.                 animationSyncHelper = Animations.jumpPose.name;
    166.             }
    167.         }
    168.         animationType = "Running";
    169.  
    170.         if (Input.GetMouseButton(0) && weaponscript.canFire &&weaponscript.singleFire ){
    171.             mecanimControl.CrossFade(Animations.Fire.name, 0.2f);
    172.             //Send animation name (needed for multiplayer)
    173.             animationSyncHelper = Animations.Fire.name;
    174.  
    175.         }
    176.  
    177.         if(action == Action.Crouch){
    178.             animationType = "Crouch";
    179.             if(fpsController.Walking ){
    180.                 if( Input.GetKey(KeyCode.W) ){
    181.                     mecanimControl.CrossFade(Animations.crouchFront.name, 0.2f);
    182.                     //Send animation name (needed for multiplayer)
    183.                     animationSyncHelper = Animations.crouchFront.name;
    184.                 }
    185.                 else if(Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S)){
    186.                     mecanimControl.CrossFade(Animations.crouchLeft.name, 0.2f);
    187.                     //Send animation name (needed for multiplayer)
    188.                     animationSyncHelper = Animations.crouchLeft.name;
    189.                 }
    190.                 else if( Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.S)){
    191.                     mecanimControl.CrossFade(Animations.crouchRight.name, 0.2f);
    192.                     //Send animation name (needed for multiplayer)
    193.                     animationSyncHelper = Animations.crouchRight.name;
    194.                 }
    195.                 else if(Input.GetKey(KeyCode.S)){
    196.                     mecanimControl.CrossFade(Animations.crouchBack.name, 0.2f);
    197.                     //Send animation name (needed for multiplayer)
    198.                     animationSyncHelper = Animations.crouchBack.name;
    199.                 }
    200.             }else{
    201.                 mecanimControl.CrossFade(Animations.crouchIdle.name, 0.2f);
    202.                 //Send animation name (needed for multiplayer)
    203.                 animationSyncHelper = Animations.crouchIdle.name;
    204.             }
    205.         }
    206.         if(action == Action.Prone){
    207.             animationType = "Prone";
    208.             if(fpsController.Walking ){
    209.                 if( Input.GetKey(KeyCode.W) ){
    210.                     mecanimControl.CrossFade(Animations.proneFront.name, 0.2f);
    211.                     //Send animation name (needed for multiplayer)
    212.                     animationSyncHelper = Animations.proneFront.name;
    213.                 }
    214.                 else if(Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.S)){
    215.                     mecanimControl.CrossFade(Animations.proneLeft.name, 0.2f);
    216.                     //Send animation name (needed for multiplayer)
    217.                     animationSyncHelper = Animations.proneLeft.name;
    218.                 }
    219.                 else if( Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.S)){
    220.                     mecanimControl.CrossFade(Animations.proneRight.name, 0.2f);
    221.                     //Send animation name (needed for multiplayer)
    222.                     animationSyncHelper = Animations.proneRight.name;
    223.                 }
    224.                 else if(Input.GetKey(KeyCode.S)){
    225.                     mecanimControl.CrossFade(Animations.proneBack.name, 0.2f);
    226.                     //Send animation name (needed for multiplayer)
    227.                     animationSyncHelper = Animations.proneBack.name;
    228.                 }
    229.             }else{
    230.                 mecanimControl.CrossFade(Animations.proneIdle.name, 0.2f);
    231.                 //Send animation name (needed for multiplayer)
    232.                 animationSyncHelper = Animations.proneIdle.name;
    233.             }
    234.         }
    235.         StartCoroutine(ThirdPersonWeaponControl());
    236.     }
    237.  
    238.     IEnumerator ThirdPersonWeaponControl(){
    239.         if(action != Action.Prone){
    240.             if(twoHandedWeapons.Contains(weaponManager.SelectedWeapon)){
    241.                 animationForHands = Animations.gunIdle.name;
    242.             }
    243.             else if(pistols.Contains(weaponManager.SelectedWeapon)){
    244.                 animationForHands = Animations.pistolIdle.name;
    245.             }
    246.             else if(knivesNades.Contains(weaponManager.SelectedWeapon)){
    247.                 animationForHands = Animations.knifeIdle.name;
    248.             }
    249.         }else{
    250.             animationForHands = "Null";
    251.         }
    252.     }
    253.  
    254.     void configureAnimations(){
    255.         //Set animations Wrap Mode and Speed
    256.         if(Animations.stayIdle){
    257.             animation[Animations.stayIdle.name].wrapMode = WrapMode.Loop;
    258.         }
    259.         if(Animations.crouchIdle){
    260.             animation[Animations.crouchIdle.name].wrapMode = WrapMode.Loop;
    261.         }
    262.         if(Animations.proneIdle){
    263.             animation[Animations.proneIdle.name].wrapMode = WrapMode.Loop;
    264.         }
    265.         if(Animations.walkFront){
    266.             animation[Animations.walkFront.name].wrapMode = WrapMode.Loop;
    267.             //animation[Animations.walkFront.name].speed = Animations.walkAnimationsSpeed;
    268.         }
    269.         if(Animations.walkBack){
    270.             animation[Animations.walkBack.name].wrapMode = WrapMode.Loop;
    271.             //animation[Animations.walkBack.name].speed = Animations.walkAnimationsSpeed;
    272.         }
    273.         if(Animations.walkLeft){
    274.             animation[Animations.walkLeft.name].wrapMode = WrapMode.Loop;
    275.             //animation[Animations.walkLeft.name].speed = Animations.walkAnimationsSpeed;
    276.         }
    277.         if(Animations.walkRight){
    278.             animation[Animations.walkRight.name].wrapMode = WrapMode.Loop;
    279.             //animation[Animations.walkRight.name].speed = Animations.walkAnimationsSpeed;
    280.         }
    281.         if(Animations.runFront){
    282.             animation[Animations.runFront.name].wrapMode = WrapMode.Loop;
    283.             //animation[Animations.runFront.name].speed = Animations.runAnimationsSpeed;
    284.         }
    285.         if(Animations.crouchFront){
    286.             animation[Animations.crouchFront.name].wrapMode = WrapMode.Loop;
    287.             //animation[Animations.crouchFront.name].speed = Animations.crouchAnimationsSpeed;
    288.         }
    289.         if(Animations.crouchLeft){
    290.             animation[Animations.crouchLeft.name].wrapMode = WrapMode.Loop;
    291.             //animation[Animations.crouchLeft.name].speed = Animations.crouchAnimationsSpeed;
    292.         }
    293.         if(Animations.crouchRight){
    294.             animation[Animations.crouchRight.name].wrapMode = WrapMode.Loop;
    295.             //animation[Animations.crouchRight.name].speed = Animations.crouchAnimationsSpeed;
    296.         }
    297.         if(Animations.crouchBack){
    298.             animation[Animations.crouchBack.name].wrapMode = WrapMode.Loop;
    299.             //animation[Animations.crouchBack.name].speed = Animations.crouchAnimationsSpeed;
    300.         }
    301.         if(Animations.proneFront){
    302.             animation[Animations.proneFront.name].wrapMode = WrapMode.Loop;
    303.             //animation[Animations.proneFront.name].speed = Animations.proneAnimationsSpeed;
    304.         }
    305.         if(Animations.proneLeft){
    306.             animation[Animations.proneLeft.name].wrapMode = WrapMode.Loop;
    307.             //animation[Animations.proneLeft.name].speed = Animations.proneAnimationsSpeed;
    308.         }
    309.         if(Animations.proneRight){
    310.             animation[Animations.proneRight.name].wrapMode = WrapMode.Loop;
    311.             //animation[Animations.proneRight.name].speed = Animations.proneAnimationsSpeed;
    312.         }
    313.         if(Animations.proneBack){
    314.             animation[Animations.proneBack.name].wrapMode = WrapMode.Loop;
    315.             //animation[Animations.proneBack.name].speed = Animations.proneAnimationsSpeed;
    316.         }
    317.     }
    318.  
    319.     void Reloading (){
    320.         if (Input.GetKey(KeyCode.R)){
    321.             mecanimControl.CrossFade(Animations.Reload.name, 0.2f);
    322.             //Send animation name (needed for multiplayer)
    323.             animationSyncHelper = Animations.Reload.name;
    324.             yield return new WaitForSeconds(Animations.Reload.length);
    325.         }    
    326.  
    327.     }
    328. }
    329.  
    Also, I see you have your void thread, you should move that code into your Prone, Crouch, etc ifs
     
    Last edited: Aug 12, 2014
  14. ThrillKill

    ThrillKill

    Joined:
    Apr 7, 2014
    Posts:
    80
    Your too kind. I would have said the problem lies with not knowing BASIC C#.
     
  15. ThrillKill

    ThrillKill

    Joined:
    Apr 7, 2014
    Posts:
    80
    If your C# is solid NGUI isn't that hard to figure out. No different then learning something like Photon etc. Didn't hurt I read a book on it. Its by a company personally I feel they just throw out books for the sake of it so I'm not giving any mentions but google will point you if your so inclined.

    Anyways I didn't spend a lot of time on this TBH. I know there's probally a better way, there usually is but anyways.

    I created a UIPlane and it gets populated from the values into the UI labels just like the process before when your pulling room information just change that to match the player info. Since I have max 10 people per side or 20 for teamdeathmatch I created all the labels 10 per side. Did the same for all gamemode's for whatever it was showing for that type of battle. Then its just turn on and off when button pressed. The UI Labels are blank empty so if there's no player there's nothing there. You would do the same for the inGAME player HUD for NGUI ammo health sliders whatever which being a FPS you can have it so the player can turn off all or whatever GUI parts they don't want to see.

    The Atlas is your friend. Using this will limit your drawcalls big time if you plan to have it so people can play from mobile devices. That's my biggest reason for the switch to all NGUI. If only there was an Atlas to hold all the textures, materials prefabs etc....crazy talk
     
  16. Essekey

    Essekey

    Joined:
    Nov 6, 2013
    Posts:
    15
  17. yoash

    yoash

    Joined:
    Sep 3, 2013
    Posts:
    36
    Hi guys,

    I am looking for someone to implement a feature for me.

    This is a paid job- if you can add this feature I will pay you.

    The feature is a leader board keeping track of which players have the most kills. The creator of this asset has one here on his site: http://warmerise.com/pages/top

    I already have a register/login asset working.. I just need a kills leaderboard for the website. I can buy any assets off the store if you need to use that to get it going, and I will pay you via paypal for your help. If you can do this please PM me.
     
  18. Essekey

    Essekey

    Joined:
    Nov 6, 2013
    Posts:
    15
  19. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    Hi ThrillKill
    I want use Fps kit with " photon server "
    so i need remove photon networking then recode with server logic for your Fps kit again right ?
    can you guide me about it ?
     
  20. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    If you are asking this question it might be a sign this task is too big for you, start on smaller things first and work your way up.


    The asset store page has 4 step instructions, why haven't you looked there? And there is also documentation on the asset.

     
  21. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    Hi there! So I have a question if anyone might be able to help. I have been instantiating the weapon pickups through photon, in an attempt to have the weapon pickups in my level networked. They are spawning fine, but when they are spawned, they are no longer able to be picked up. I can walk up to the weapons, and the gui will appear prompting me to pick the weapon up, but when i press the key assigned to pick the weapon up, it does not pick the weapon up. It does throw my old weapon to the ground, but the instantiated pickup will not work.

    here's how I am instantiating the weapon pickup :


    Code (CSharp):
    1. GameObject spawnObject = PhotonNetwork.InstantiateSceneObject(_gameObject.name, spawnLocation.position, _gameObject.transform.rotation, 0, null) as GameObject;

    I AM getting an error in the WeaponPickup.cs script at the point where I am trying to pick up the instantiated gun.

    NullReferenceException: Object reference not set to an instance of an object
    WeaponPickUp.Update () (at Assets/FPS Kit 2.0 C#/_CustomAssets/Scripts/WeaponSystem/WeaponPickUp.cs:77)

    here's the line that's throwing the error :

    Code (CSharp):
    1. StartCoroutine(weapManager.SwitchWeapons(weapManager.allWeapons[weapManager.index].gameObject, newWeapon.gameObject));


    anyone know how I can get instantiated weapon pickups to work? Much thanks!
     
  22. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298


    The name of the weapon you want to pick up doesn't match the name in your weaponmanager.

    Say we have RPG on the ground, and in the weaponmanager the weapon name says "Rocket Launcher" if that name doesnt match the weapon prefab on the ground name it wont replace your weapon.

    So make sure RPG -> RPG , Deagle -> Deagle, AWP -> AWP, etc etc for all weapons
     
  23. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214


    The names do match.... BUT when they are instantiated, they become a clone of that object. So for instance a pickup called RPG, now becomes RPG(clone)

    I thought it was because of the names not matching.


    My question is now, how can I instantiate that object without it having being named (clone), which all instantiated objects become?


    picking up non instantiated objects in a multiplayer shooter is somewhat lame.
     
  24. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298

    Code (csharp):
    1.  
    2.  
    3. GameObject RPG = PhotonNetwork.Instantiate("RPG", Vector3.Zero, Quaternion.identity, 0);
    4. RPG.name = "RPG";
    5.  
    6.  
     
  25. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    Thank you.

    I do have one more brain bender. Since I am not using the script to spawn the RPG, or one specific item alone.... for instance I am spawning all of my pickups in my game (health, food) not just guns....

    Can I somehow in the instantiate line remove "(clone)" instead of hard naming the item? This way will work, but I will have to write a seperate instantiate script for each gun.


    is there a more efficient way of doing it all in the same script?


    and thank you very much good sir :)
     
  26. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    Code (csharp):
    1.  
    2. InstantiatedObject.name.Replace("(Clone)", "");
    3.  
     
  27. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    I think I may have thought of a better way to do this :

    Code (CSharp):
    1.  GameObject spawn = PhotonNetwork.InstantiateSceneObject(gunSpawn.name, transform.position, Quaternion.identity, 0, null) as GameObject;
    2.                 spawn.transform.parent = transform;
    3.                 spawn.name = spawn.name.Replace("(Clone)", "");

    this should thus just remove (clone) from the end
     
  28. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    I have one more question. and this isn't me asking for code, more than it is asking maybe for input on how to go about thinking of how it would be done. I try not to be as noobish here.

    so the question:

    I am using the ballistic knife as the "default" weapon the player starts with.. (actually for my case i removed the knife model and it's just the players "fists"). What I am wanting to do, is add a property to the ballistic knife, or fists in my case, to make them "un-dropable" even through my weapon manager is set to replace weapons instead of adding them.

    So the idea is, I only want the player to be able to carry one gun at a time, but as it is set up now, when the player finds a gun and goes to pick it up, the player also throws out his ballistic knife, or fists on the ground in order to pick up the weapon.

    What might be the best method of setting the knife / fists to always stay on the player, but any additional weapon after that has to be dropped if you want to pick up a different one?

    So i guess the player would have a maximum of two weapons in the weapon manager, but I want the "default" weapon to always be there.
     
  29. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    Set a bool in pickup weapon canSwitch;
    Set a reference WeaponScript ws;
    Make an if statement

    if(ws.GunType == WeaponScript.gunType.KNIFE){
    canSwitch = false;
    }
     
  30. Senor_Cucumber

    Senor_Cucumber

    Joined:
    May 6, 2014
    Posts:
    1
    Does anyone know why I cant click on any of the buttons when i build the bunker scene? I cant click anything, like It shows up that i clicked it but nothing happens.
     
  31. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    thanks again. So that does indeed prevent the knife from being dropped. I still have to think of how the player can only pick up one gun in addition to the knife, and start with no weapon in that slot?

    I could set the weapon pickup type to add instead of replace, but then the player will be able to just keep adding weapons to his character, and he wouldn't be dropping them. Would there be a way to set a maximum number of added weapons on top of the knife?

    I know I could have the pickup type set to replace, and have the player start with 2 weapons, the knife, and say one of the guns that is replaceable..... but I don't actually want the player to start with guns, they will all be found. and you can't start with an empty slot as a weapon, which would be nice, but doesn't seem to be possible.
     
  32. Amer-ALhwifi

    Amer-ALhwifi

    Joined:
    Jul 4, 2012
    Posts:
    20
    Editing Main Menu to make
    choices ( Join Game ) & ( Host game )


    Example
    https://www.dropbox.com/s/9pnnj3xoki1jiuc/Screenshot 2014-09-03 03.56.26.png?dl=0
    https://www.dropbox.com/s/ub0wbkbyqqm0qsc/Screenshot 2014-09-03 03.56.40.png?dl=0


    ConnectMenu.cs

    Add : ( I'm not sure if it's in their or I've added it , so check that )
    Code (CSharp):
    1.     bool showRooms = false;
    2.  
    Find :
    Code (CSharp):
    1.     void OnGUI () {
    2.  
    Add this :
    Code (CSharp):
    1. GUILayout.Space(500);
    2.  
    3. if(GUILayout.Button("Join Game", GUILayout.Width(250), GUILayout.Height(60))){
    4.        
    5.             showRooms = true;
    6.             createRoom = false;
    7.  
    8.         }
    9. if(GUILayout.Button("Create Game", GUILayout.Width(250), GUILayout.Height(60))){
    10.        
    11.             createRoom = true;
    12.             showRooms = true;
    13.  
    14.         }
    15.  
    16. if(GUILayout.Button("Quit", GUILayout.Width(350), GUILayout.Height(80))){
    17.             Application.Quit();
    18.         }
    Replace :
    Code (CSharp):
    1.     void ShowConnectMenu(){
    2.  
    3.         GUILayout.Space (50);
    4.         if(!createRoom){
    5.             //DIsplay all available rooms and Join selected room
    6.             scroll = GUILayout.BeginScrollView(scroll, GUILayout.Width(700), GUILayout.Height(600));{
    7.                 if (showRooms){
    8.  
    9.                 if(allRooms != null && allRooms.Length > 0){
    10.                     foreach(RoomInfo room in allRooms){
    11.                         if(allRooms.Length > 0){
    12.                             GUILayout.BeginHorizontal("box");
    13.                                 //Room name
    14.                             GUILayout.Label(room.name, GUILayout.Width(180));
    15.                                 //Map name
    16.                                 GUILayout.Label((string)room.customProperties["MapName"], GUILayout.Width(180));
    17.                                 //Player count
    18.                                 GUILayout.Label(room.playerCount + " / " + room.maxPlayers, GUILayout.Width(100));
    19.                                 GUILayout.FlexibleSpace();
    20.                             if(GUILayout.Button("Join Room", GUILayout.Width(160),GUILayout.Height(40))){
    21.                                     //Join a room
    22.                                     PhotonNetwork.JoinRoom(room.name);
    23.                                     PhotonNetwork.playerName = playerName;
    24.                                     connectingToRoom = true;
    25.  
    26.                                     //Save player name
    27.                                     CheckPlayerNameAndRoom();
    28.                                     PlayerPrefs.SetString("PlayerName", playerName);
    29.                                 }
    30.                             GUILayout.EndHorizontal();
    31.                         }
    32.                     }
    33.  
    34.                 }else{
    35.                     GUILayout.Label("No Rooms Created! ");
    36.                 }
    37.             GUILayout.EndScrollView();
    38.                 }
    39.  
    40.             GUILayout.Space(5);
    41.        
    42.        
    43.             GUILayout.BeginHorizontal();
    44.             GUILayout.Label("Player Name: ");
    45.             playerName = GUILayout.TextField (playerName, 15, GUILayout.Height(25));
    46.             GUILayout.EndHorizontal();
    47.             }
    48.        
    49.             //Go to room creation menu
    50.             GUILayout.FlexibleSpace();
    51.             GUILayout.BeginHorizontal();
    52.                 GUILayout.FlexibleSpace();
    53.             if(GUILayout.Button("Back", GUILayout.Width(250), GUILayout.Height(60))){
    54.                 createRoom = false;
    55.                 showRooms = false;
    56.             }
    57.  
    58.                     //Save player name
    59.                     CheckPlayerNameAndRoom();
    60.                     PlayerPrefs.SetString("PlayerName", playerName);
    61.  
    62.             GUILayout.EndHorizontal();
    63.        
    64.         }else{
    65.             //Create new room***************************************************************************
    66.        
    67.             //Room name
    68.             if ( createRoom){
    69.             GUILayout.BeginHorizontal();
    70.                 GUILayout.Label("Room Name: ", GUILayout.Width(150));
    71.             // To change the maximum letters change 10 to the new one .
    72.                 newRoomName = GUILayout.TextField (newRoomName, 15, GUILayout.Height(25));
    73.             GUILayout.EndHorizontal();
    74.        
    75.             GUILayout.Space(5);
    76.        
    77.             GUILayout.BeginHorizontal();
    78.                 GUILayout.Label("Max Players: ", GUILayout.Width(150));
    79.                 for(int i = 0; i < maxPlayersOptions.Count; i++){
    80.                     if(maxPlayers == maxPlayersOptions[i]){
    81.                         //Selected number is green
    82.                         GUI.color = Color.green;
    83.                     }else{
    84.                         GUI.color = Color.white;
    85.                     }
    86.                     if(GUILayout.Button(maxPlayersOptions[i].ToString(), GUILayout.Width(60), GUILayout.Height(30))){
    87.                         maxPlayers = maxPlayersOptions[i];
    88.                     }
    89.                 }
    90.                 GUI.color = Color.white;
    91.             GUILayout.EndHorizontal();
    92.        
    93.             GUILayout.Space(5);
    94.        
    95.             //Select Game Mode *****************************************************************
    96.             GUILayout.BeginHorizontal();
    97.                 GUILayout.Label("Game Mode: ", GUILayout.Width(150));
    98.        
    99.                 if(gameMode == "TDM"){
    100.                     GUI.color = Color.green;
    101.                 }
    102.                 if(GUILayout.Button("TeamDeathmatch", GUILayout.Width(160), GUILayout.Height(30))){
    103.                     gameMode = "TDM";
    104.                 }
    105.        
    106.                 GUI.color = Color.white;
    107.        
    108.                 if(gameMode == "DM"){
    109.                     GUI.color = Color.green;
    110.                 }
    111.                 if(GUILayout.Button("Deathmatch", GUILayout.Width(160), GUILayout.Height(30))){
    112.                     gameMode = "DM";
    113.                 }
    114.             GUILayout.EndHorizontal();
    115.             //*******************************************************************************
    116.             GUI.color = Color.white;
    117.        
    118.             GUILayout.Space(5);
    119.        
    120.             GUILayout.BeginHorizontal();
    121.                 mapScroll = GUILayout.BeginScrollView(mapScroll, false, true, GUILayout.Width(400), GUILayout.Height(400));
    122.                     for(int i = 0; i < allMaps.Count; i++){
    123.                         if(selectedMap == i){
    124.                             //Selected map is green
    125.                             GUI.color = Color.green;
    126.                         }else{
    127.                             GUI.color = Color.white;
    128.                         }
    129.                         if(GUILayout.Button(allMaps[i].mapName, GUILayout.Height(50))){
    130.                             selectedMap = i;
    131.                         }
    132.                     }
    133.                     GUI.color = Color.white;
    134.                 GUILayout.EndScrollView();
    135.                 GUILayout.Space(0);
    136.             //####################################### ACTIVATE THIS TO ENABLE MAP IMAGE PREVIEW ###########################################
    137.                 //Show map preview image
    138.             //    if(allMaps[selectedMap].mapPreview != null){
    139.             //        GUILayout.Label(allMaps[selectedMap].mapPreview, GUILayout.Width(1080), GUILayout.Height(1080));
    140.             //    }
    141.             GUILayout.EndHorizontal();
    142.        
    143.             GUILayout.FlexibleSpace();
    144.          
    145.        
    146.             GUILayout.BeginHorizontal();
    147.                 //Return to Lobby
    148.                 if(GUILayout.Button("BACK", GUILayout.Width(250), GUILayout.Height(60))){
    149.                     createRoom = false;
    150.                     showRooms = false;
    151.                 }
    152.        
    153.                 GUILayout.FlexibleSpace();
    154.        
    155.                 //Create our room **********************************************************
    156.                 if(GUILayout.Button("Continue", GUILayout.Width(250), GUILayout.Height(60))){
    157.                     CheckPlayerNameAndRoom();
    158.                     PhotonNetwork.player.name = playerName;
    159.                     Hashtable setMapName = new Hashtable();
    160.                     setMapName["MapName"] = allMaps[selectedMap].mapName;
    161.                     setMapName["RoundDuration"] = roundDuration;
    162.                     setMapName["GameMode"] = gameMode;
    163.                     string[] exposedProps = new string[3];
    164.                     exposedProps[0] = "MapName";
    165.                     exposedProps[1] = "RoundDuration";
    166.                     exposedProps[2] = "GameMode";
    167.                     //Create new Room
    168.                     PhotonNetwork.CreateRoom(newRoomName, true, true, maxPlayers, setMapName, exposedProps);
    169.                 }
    170.             GUILayout.EndHorizontal();
    171.  
    172.             //****************************************************************************************
    173.         }
    174.     }

    Note : It's a very basic modification , but i think maybe someone will need it :).
    P.S : I've disabled the map image preview , if you want it activate it back by removing " // " .

    - I'm using my own Gui Skin , so the result will be a little bit different :)
     
  33. Amer-ALhwifi

    Amer-ALhwifi

    Joined:
    Jul 4, 2012
    Posts:
    20
    Also , I'm working on to get a message " locally " when you killed another player / get killed by another player .
    Example :

    You have Killed PlayerB
    You were killed by PlayerA

    But till now , i have no luck to configure it . Any idea will be highly appreciated !
     
  34. Amer-ALhwifi

    Amer-ALhwifi

    Joined:
    Jul 4, 2012
    Posts:
    20
    Player Run Animation ( Original code by : Stan B. )

    Stan B. has posted his solution for running animation , i got some errors when i used it . so i edit it :) .

    Result :
    https://www.dropbox.com/s/yzeente3lzazqlh/Unity 2014-09-03 19-38-57-99.png?dl=0


    WeaponAnimation.cs

    - Add :
    Code (CSharp):
    1.     public string Run = "Run";
    2.     public string RunEnds = "RunEnds";
    3.  
    - Add :
    Code (CSharp):
    1.     public void PlayerRun(){
    2.         GetComponent<Animation>().Rewind(Run);
    3.         GetComponent<Animation>().Play(Run);
    4.     }
    5.    
    6.     public void RunStop(){
    7.         GetComponent<Animation>().Rewind(RunEnds);
    8.         GetComponent<Animation>().Play(RunEnds);
    9.     }
    10.  
    2- WeaponScript.cs

    -Add :
    Code (CSharp):
    1.     private bool weRun;
    2.  
    - Add to InputUpdate()
    Code (CSharp):
    1. if(motor.Running &&(!weRun) && !isReload){
    2.             weRun = true;
    3.             canFire = false;
    4.             canAim = false;
    5.             isReload = false;
    6.             weaponAnimation.PlayerRun();
    7.         }
    8.         else if(!motor.Running && weRun){
    9.             weRun = false;
    10.             canAim = true;
    11.             canFire = true;
    12.             weaponAnimation.RunStop();
    13.         }

    //That's it !
    :)
     
  35. Reiner

    Reiner

    Joined:
    Dec 2, 2012
    Posts:
    214
  36. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    How i can set limit choice team
    i don't want player pick so much in a team!

     
  37. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Unfortunately for you, I think the answer is learn how to program, then dig into the code and take a crack at writing it yourself.
     
  38. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    Yes because i am not programer so this is trouble with me!
    current i need a programer to edit something in code of FPS kit
    Anyone can do it . i will pay for him !
    please contact with me to talk about detail work !
    email : letienthanh1990@gmail.com
    Thank you!
     
  39. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    If somebody else is going to be doing scripting work, then what role would you be fulfilling?
     
  40. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    no! this guy not just fix that error , he will work to project in the end !
     
  41. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    That's not what I asked.
    I didn't ask what he/she would be doing, I asked what you would be doing. Because surely you aren't going to hire someone to make your game for you, and then turn around and sell it without putting in any work? Surely you realize that isn't a good deal for anyone - if they're putting in all the work, they might as well just work on their own game and make ALL of the profits from the game.
     
  42. thanhle

    thanhle

    Joined:
    May 2, 2013
    Posts:
    162
    oh yes ! i just finding programer , my job is 3d artist , i will work everything about graphics
     
    Last edited: Sep 7, 2014
  43. yoash

    yoash

    Joined:
    Sep 3, 2013
    Posts:
    36
    Anyone got a "Bot" prefab? Something that could be dropped into a level, use a nav mesh to walk around and try to kill any human or other bot players? Then when the bot is killed, he respawns at one of the spawn points?

    I will pay for this if anyone has one to sell.
     
  44. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    if I wanted to call, from another script, picking up a paticular weapon?

    for instance i want to call the weapon switching function to switch to, the mp5 (first weapon in the array).

    I am calling this in a crafting script, so weapons will be crafted instead of picked up.

    any help appreciated, and thanks!

    for instance, from another c# script

    WeaponPickUp pickupscript;


    void Start() {
    pickupscript = GameObject.FindObjectWithTag ("Player").GetComponent<WeaponPickUp> ();

    }


    if (check for something being crafted here) {
    pickupscript.playerWeapons[1]

    }



    would this be the correct way to switch weapons (weapon in slot 1 in weapon manager) via script?
     
    Last edited: Sep 11, 2014
  45. programmrzinc

    programmrzinc

    Joined:
    May 29, 2011
    Posts:
    79
    I have a glitch, when the match ends, It just hangs at the "Team1 Won...Restarting" I have been trying to isolate the issue, but it comes like, one in ten times. Is there others who have this problem, and is there a fix?
     
  46. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    anyone privy as to switching weapons using script instead of pickups?
     
  47. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    Also, here's what i've been doing with the kit, survival horror game called Age of Survival :



    another new video showing the airdrop system I just implemented in :



    airdrop begins at about 4:50 if you want to skip to it.



    Anyways highly modified fps kit 2.0 here :) Hope to keep modifying it further, next goal is to get the weapons switched by calling a switching function after an item has been crafted and used.

    and of course switching out the weapon models with some nicer looking ones will be coming in the future as well.

    the last big plan once all of the features are mostly finalized would be to switch from the photon cloud architecture to the photon server.


    early alpha of the game will be playable very soon! http://ageofsurvivalgame.com
     
  48. yoash

    yoash

    Joined:
    Sep 3, 2013
    Posts:
    36
    Anyone have a script/tutroial for killing a player when they touch a certain object?
    The one on the first post doesn't work anymore.
     
  49. Rakarnov

    Rakarnov

    Joined:
    Sep 13, 2014
    Posts:
    1
    hi i am getting an error like this
    While game builder
     

    Attached Files:

  50. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    so this is almost working to add a weapon through script

    Code (CSharp):
    1. WeaponPickUp pickupscript;
    2.  
    3.  
    4. void Start() {
    5. pickupscript = GameObject.FindObjectWithTag ("Player").GetComponent<WeaponPickUp> ();
    6.  
    7. }
    8.  
    9.  
    10. if (check for something being crafted here) {
    11. pickupscript.playerWeapons[1]
    12.  
    13. }
    what that does is switch to that particular weapon though on activation instead of adding it. So this switches to the first weapon already in the players currently picked up weapons.


    hmm. anyone know how to get a little closer to replacing the weapon that's already there on activate, instead of switching?

    so goal is to activate the inventory item, and "pick up" an mp5 which is the first weapon in the weapon manager, and replace the player's current weapon (knife) with that.