Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Minimap icon showing when player is shooting not working

Discussion in 'Multiplayer' started by Vexer, Jun 9, 2018.

  1. Vexer

    Vexer

    Joined:
    Feb 24, 2016
    Posts:
    187
    Hey guys i'm trying to make a minimap where if you shoot the enemy's will see your icon appear on their minimap how do i do that i have this code right now but now it works like this: if i shoot i can see the enemy's icon appear on my map

    Code:
    Code (csharp):
    1.  
    2. if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire)
    3.             {
    4.                 nextTimeToFire = Time.time + 1f / fireRate;
    5.                 StartCoroutine(minimapwaiter());
    6.             }
    7.  
    8. IEnumerator minimapwaiter()
    9.     {
    10.         MinimapIcon.enabled = true;
    11.  
    12.         //Wait for 4 seconds
    13.         yield return new WaitForSeconds(2f);
    14.  
    15.         MinimapIcon.enabled = false;
    16.  
    17.     }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You're going to want the server to tell all the clients to do this, not just do it locally like you're doing.
     
    Vexer likes this.
  3. Vexer

    Vexer

    Joined:
    Feb 24, 2016
    Posts:
    187
    Hey can you please have a look at my script for some reason my player doesn't animate (Not even the host/Local) i've tried everything please let me know what iam doing wrong:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.Networking;
    4. using System.Collections;
    5. using UnityEngine.UI;
    6.  
    7. public class Gun : NetworkBehaviour {
    8.     public Camera fpsCam;
    9.     public ParticleSystem muzzleFlash;
    10.  
    11.     //Assault class shoot sounds:
    12.     public AudioClip akshot;
    13.     public AudioClip m1911shot;
    14.     public AudioClip knifeattack;
    15.  
    16.     //Scout class shoot sounds:
    17.     public AudioClip thompsonshot;
    18.     public AudioClip waltherpkkshot;
    19.  
    20.     //Support class shoot sounds:
    21.     public AudioClip benellim4shot;
    22.     public AudioClip revolvershot;
    23.  
    24.     //Recon class shoot sounds:
    25.     public AudioClip remingtonm24shot;
    26.     public AudioClip m9shot;
    27.  
    28.     //Reload sound clips:
    29.     public AudioClip Akreloadsound;
    30.     public AudioClip M1911reloadsound;
    31.  
    32.     public float damage = 10f;
    33.     public float range = 100f;
    34.     public float fireRate = 3.5f;
    35.  
    36.     private float nextTimeToFire = 0f;
    37.  
    38.     public AudioClip hitsound;
    39.  
    40.     public GameObject MuzzleFlash;
    41.  
    42.     public AudioSource audioSource;
    43.     public AudioSource audioSource2;
    44.     float speed = 0.2f;
    45.     public GameObject crosshair;
    46.     public GameObject hitmarker;
    47.  
    48.     public int minDmgHead = 45;
    49.     public int maxDmgHead = 70;
    50.     public int minDmgTorso = 15;
    51.     public int maxDmgTorso = 25;
    52.     public int minDmgLeg = 5;
    53.     public int maxDmgLeg = 10;
    54.  
    55.     public bool Idle;
    56.  
    57.     public HandleWeapons handleWeapons;
    58.     public HandleWeaponAnimations handleweaponAnimations;
    59.  
    60.     [SyncVar] public int AkBulletsShot;
    61.     [SyncVar] public int M1911BulletsShot;
    62.     [SyncVar] public int ThompsonBulletsShot;
    63.     [SyncVar] public int WaltherPKKBulletsShot;
    64.     [SyncVar] public int BenelliM4BulletsShot;
    65.     [SyncVar] public int RevolverBulletsShot;
    66.     [SyncVar] public int RemingtonM24BulletsShot;
    67.     [SyncVar] public int M9BulletsShot;
    68.  
    69.     public int MaxBullets;
    70.  
    71.     public int AkMaxAmmo = 120;
    72.     public int AkAmmo = 30;
    73.  
    74.     public int M1911MaxAmmo = 48;
    75.     public int M1911Ammo = 8;
    76.  
    77.     public int ThompsonMaxAmmo = 225;
    78.     public int ThompsonAmmo = 45;
    79.  
    80.     public int WaltherPKKMaxAmmo = 60;
    81.     public int WaltherPKKAmmo = 10;
    82.  
    83.     public int BenelliM4MaxAmmo = 40;
    84.     public int BenelliM4Ammo = 8;
    85.  
    86.     public int RevolverMaxAmmo = 30;
    87.     public int RevolverAmmo = 6;
    88.  
    89.     public int RemingtonM24MaxAmmo = 42;
    90.     public int RemingtonM24Ammo = 6;
    91.  
    92.     public int M9MaxAmmo = 75;
    93.     public int M9Ammo = 15;
    94.  
    95.     public bool IsReloading;
    96.  
    97.     void Start()
    98.     {
    99.         gameObject.GetComponent <NetworkAnimator> ().SetParameterAutoSend(0, true);
    100.         hitmarker.SetActive(false);
    101.         if (!isLocalPlayer)
    102.             return;
    103.         crosshair.SetActive(true);
    104.     }
    105.  
    106.     // Update is called once per frame
    107.     void Update()
    108.     {
    109.         if (isLocalPlayer)
    110.         {
    111.  
    112.             //Assault class if input:
    113.             if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Assault == true && handleWeapons.SelectedWeapon == 1 && IsReloading == false)
    114.             {
    115.  
    116.                 fireRate = 9;
    117.                 nextTimeToFire = Time.time + 1f / fireRate;
    118.                 audioSource.clip = akshot;
    119.                 audioSource.Play();
    120.                 CmdShoot();
    121.             }
    122.  
    123.             else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Assault == true && handleWeapons.SelectedWeapon == 2)
    124.             {
    125.                 fireRate = 1;
    126.                 nextTimeToFire = Time.time + 1f / fireRate;
    127.                 audioSource.clip = knifeattack;
    128.                 audioSource.Play();
    129.                 CmdShoot();
    130.             }
    131.  
    132.             else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Assault == true && handleWeapons.SelectedWeapon == 3 && IsReloading == false)
    133.             {
    134.                 fireRate = 3.5f;
    135.                 nextTimeToFire = Time.time + 1f / fireRate;
    136.                 audioSource.clip = m1911shot;
    137.                 audioSource.Play();
    138.                 CmdShoot();
    139.             }
    140.  
    141.             //Scout class if input:
    142.             else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Scout == true && handleWeapons.SelectedWeapon == 1 && IsReloading == false)
    143.             {
    144.  
    145.                 fireRate = 12;
    146.                 nextTimeToFire = Time.time + 1f / fireRate;
    147.                 audioSource.clip = thompsonshot;
    148.                 audioSource.Play();
    149.                 CmdShoot();
    150.             }
    151.  
    152.             else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Scout == true && handleWeapons.SelectedWeapon == 2)
    153.             {
    154.                 fireRate = 1;
    155.                 nextTimeToFire = Time.time + 1f / fireRate;
    156.                 audioSource.clip = knifeattack;
    157.                 audioSource.Play();
    158.                 CmdShoot();
    159.             }
    160.  
    161.             else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Scout == true && handleWeapons.SelectedWeapon == 3 && IsReloading == false)
    162.             {
    163.                 fireRate = 3.5f;
    164.                 nextTimeToFire = Time.time + 1f / fireRate;
    165.                 audioSource.clip = waltherpkkshot;
    166.                 audioSource.Play();
    167.                 CmdShoot();
    168.             }
    169.  
    170.             //Support class if input:
    171.             else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Support == true && handleWeapons.SelectedWeapon == 1 && IsReloading == false)
    172.             {
    173.  
    174.                 fireRate = 1;
    175.                 nextTimeToFire = Time.time + 1f / fireRate;
    176.                 audioSource.clip = benellim4shot;
    177.                 audioSource.Play();
    178.                 CmdShoot();
    179.             }
    180.  
    181.             else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Support == true && handleWeapons.SelectedWeapon == 2)
    182.             {
    183.                 fireRate = 1;
    184.                 nextTimeToFire = Time.time + 1f / fireRate;
    185.                 audioSource.clip = knifeattack;
    186.                 audioSource.Play();
    187.                 CmdShoot();
    188.             }
    189.  
    190.            else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Support == true && handleWeapons.SelectedWeapon == 3 && IsReloading == false)
    191.             {
    192.                 fireRate = 2.75f;
    193.                 nextTimeToFire = Time.time + 1f / fireRate;
    194.                 audioSource.clip = revolvershot;
    195.                 audioSource.Play();
    196.                 CmdShoot();
    197.             }
    198.  
    199.             //Recon class if input:
    200.            else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Recon == true && handleWeapons.SelectedWeapon == 1 && IsReloading == false)
    201.             {
    202.  
    203.                 fireRate = 1;
    204.                 nextTimeToFire = Time.time + 1f / fireRate;
    205.                 audioSource.clip = remingtonm24shot;
    206.                 audioSource.Play();
    207.                 CmdShoot();
    208.             }
    209.  
    210.             else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Recon == true && handleWeapons.SelectedWeapon == 2)
    211.             {
    212.                 fireRate = 1;
    213.                 nextTimeToFire = Time.time + 1f / fireRate;
    214.                 audioSource.clip = knifeattack;
    215.                 audioSource.Play();
    216.                 CmdShoot();
    217.             }
    218.  
    219.            else if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && handleWeapons.Recon == true && handleWeapons.SelectedWeapon == 3 && IsReloading == false)
    220.             {
    221.                 fireRate = 3.5f;
    222.                 nextTimeToFire = Time.time + 1f / fireRate;
    223.                 audioSource.clip = m9shot;
    224.                 audioSource.Play();
    225.                 CmdShoot();
    226.             }
    227.         }
    228.     }
    229.  
    230.     IEnumerator waiter()
    231.     {
    232.         hitmarker.SetActive(true);
    233.         crosshair.SetActive(false);
    234.  
    235.         //Wait for 4 seconds
    236.         yield return new WaitForSeconds(0.2f);
    237.  
    238.         hitmarker.SetActive(false);
    239.         crosshair.SetActive(true);
    240.  
    241.     }
    242.  
    243.     [Command]
    244.     void CmdMuzzleFlash()
    245.     {
    246.         RpcMuzzleFlash();
    247.     }
    248.  
    249.     [ClientRpc]
    250.     void RpcMuzzleFlash()
    251.     {
    252.         if (isLocalPlayer)
    253.             return;
    254.         muzzleFlash.Play();
    255.     }
    256.  
    257.     [Command]
    258.     void CmdAkShootSound()
    259.     {
    260.         RpcAkShootSound();
    261.     }
    262.  
    263.     [ClientRpc]
    264.     void RpcAkShootSound()
    265.     {
    266.         if (isLocalPlayer)
    267.             return;
    268.         audioSource.clip = akshot;
    269.         audioSource.Play();
    270.     }
    271.  
    272.     [Command]
    273.     void CmdKnifeAttackSound()
    274.     {
    275.         RpcKnifeAttackSound();
    276.     }
    277.  
    278.     [ClientRpc]
    279.     void RpcKnifeAttackSound()
    280.     {
    281.         if (isLocalPlayer)
    282.             return;
    283.         audioSource.clip = knifeattack;
    284.         audioSource.Play();
    285.     }
    286.  
    287.     [Command]
    288.     void CmdM1911ShootSound()
    289.     {
    290.         RpcM1911ShootSound();
    291.     }
    292.  
    293.     [ClientRpc]
    294.     void RpcM1911ShootSound()
    295.     {
    296.         if (isLocalPlayer)
    297.             return;
    298.         audioSource.clip = m1911shot;
    299.         audioSource.Play();
    300.     }
    301.  
    302.     [Command]
    303.     void CmdThompsonShootSound()
    304.     {
    305.         RpcThompsonShootSound();
    306.     }
    307.  
    308.     [ClientRpc]
    309.     void RpcThompsonShootSound()
    310.     {
    311.         if (isLocalPlayer)
    312.             return;
    313.         audioSource.clip = thompsonshot;
    314.         audioSource.Play();
    315.     }
    316.  
    317.     [Command]
    318.     void CmdWaltherPKKShootSound()
    319.     {
    320.         RpcWaltherPKKShootSound();
    321.     }
    322.  
    323.     [ClientRpc]
    324.     void RpcWaltherPKKShootSound()
    325.     {
    326.         if (isLocalPlayer)
    327.             return;
    328.         audioSource.clip = waltherpkkshot;
    329.         audioSource.Play();
    330.     }
    331.  
    332.     [Command]
    333.     void CmdBenelliM4ShootSound()
    334.     {
    335.         RpcBenelliM4ShootSound();
    336.     }
    337.  
    338.     [ClientRpc]
    339.     void RpcBenelliM4ShootSound()
    340.     {
    341.         if (isLocalPlayer)
    342.             return;
    343.         audioSource.clip = benellim4shot;
    344.         audioSource.Play();
    345.     }
    346.  
    347.     [Command]
    348.     void CmdRevolverShootSound()
    349.     {
    350.         RpcRevolverShootSound();
    351.     }
    352.  
    353.     [ClientRpc]
    354.     void RpcRevolverShootSound()
    355.     {
    356.         if (isLocalPlayer)
    357.             return;
    358.         audioSource.clip = revolvershot;
    359.         audioSource.Play();
    360.     }
    361.  
    362.     [Command]
    363.     void CmdRemingtonM24ShootSound()
    364.     {
    365.         RpcRemingtonM24ShootSound();
    366.     }
    367.  
    368.     [ClientRpc]
    369.     void RpcRemingtonM24ShootSound()
    370.     {
    371.         if (isLocalPlayer)
    372.             return;
    373.         audioSource.clip = remingtonm24shot;
    374.         audioSource.Play();
    375.     }
    376.  
    377.     [Command]
    378.     void CmdM9ShootSound()
    379.     {
    380.         RpcM9ShootSound();
    381.     }
    382.  
    383.     [ClientRpc]
    384.     void RpcM9ShootSound()
    385.     {
    386.         if (isLocalPlayer)
    387.             return;
    388.         audioSource.clip = m9shot;
    389.         audioSource.Play();
    390.     }
    391.  
    392.     [Command]
    393.     void CmdHitSound()
    394.     {
    395.         RpcHitSound();
    396.     }
    397.  
    398.     [ClientRpc]
    399.     void RpcHitSound()
    400.     {
    401.         if (!isLocalPlayer)
    402.             return;
    403.     }
    404.  
    405.     [Command]
    406.     void CmdHitMarker()
    407.     {
    408.         RpcHitMarker();
    409.     }
    410.  
    411.     [ClientRpc]
    412.     void RpcHitMarker()
    413.     {
    414.         if (!isLocalPlayer)
    415.             return;
    416.         StartCoroutine(waiter());
    417.  
    418.     }
    419.  
    420.     [Command]
    421.     void CmdShoot()
    422.     {
    423.         //AkAmmo
    424.         if (handleWeapons.Assault == true && handleWeapons.SelectedWeapon == 1)
    425.         {
    426.             if (AkAmmo == 0 && AkMaxAmmo >= 1)
    427.             {
    428.                 StartCoroutine(AkNoAmmo());
    429.             }
    430.  
    431.             if (AkAmmo < 0)
    432.             {
    433.                 AkAmmo = 0;
    434.             }
    435.  
    436.             if (AkMaxAmmo < 0)
    437.             {
    438.                 AkMaxAmmo = 0;
    439.             }
    440.  
    441.             if (AkMaxAmmo == 0 && AkAmmo == 0)
    442.             {
    443.                 range = 0f;
    444.                 audioSource.enabled = false;
    445.             }
    446.         }
    447.         //M1911AMMO
    448.         if (handleWeapons.Assault == true && handleWeapons.SelectedWeapon == 3)
    449.         {
    450.             if (M1911Ammo == 0 && M1911MaxAmmo >= 1)
    451.             {
    452.                 StartCoroutine(M1911NoAmmo());
    453.             }
    454.  
    455.             if (M1911Ammo < 0)
    456.             {
    457.                 M1911Ammo = 0;
    458.             }
    459.  
    460.             if (M1911MaxAmmo < 0)
    461.             {
    462.                 M1911MaxAmmo = 0;
    463.             }
    464.  
    465.             if (M1911MaxAmmo == 0 && M1911Ammo == 0)
    466.             {
    467.                 range = 0f;
    468.                 audioSource.enabled = false;
    469.             }
    470.         }
    471.         Debug.Log("IM SHOOTING!!!");
    472.  
    473.         RaycastHit hit;
    474.         if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
    475.         {
    476.             if(handleWeapons.Assault == true)
    477.             {
    478.                 if (handleWeapons.SelectedWeapon == 1)
    479.                 {
    480.                     AkBulletsShot += 1;
    481.                     AkAmmo -= 1;
    482.                 }
    483.  
    484.                 else if (handleWeapons.SelectedWeapon == 3)
    485.                 {
    486.                     M1911BulletsShot += 1;
    487.                     M1911Ammo -= 1;
    488.                 }
    489.             }
    490.  
    491.             Debug.Log(hit.transform.name);
    492.  
    493.             Health health = hit.transform.GetComponent<Health>();
    494.  
    495.  
    496.             if (health != null)
    497.             {
    498.                 CmdHitSound();
    499.                 CmdHitMarker();
    500.  
    501.                 if (hit.collider.tag == "Head")
    502.                 {
    503.                     health.CmdTakeDamage(Random.Range(minDmgHead, maxDmgHead));
    504.                 }
    505.  
    506.                 else if (hit.collider.tag == "Torso")
    507.                 {
    508.                     health.CmdTakeDamage(Random.Range(minDmgTorso, maxDmgTorso));
    509.                 }
    510.  
    511.                 else if (hit.collider.tag == "Leg")
    512.                 {
    513.                     health.CmdTakeDamage(Random.Range(minDmgLeg, maxDmgLeg));
    514.                 }
    515.             }
    516.         }
    517.     }
    518.  
    519.     IEnumerator AkNoAmmo()
    520.     {
    521.         IsReloading = true;
    522.         handleweaponAnimations.anim.SetBool("IsReloading", IsReloading);
    523.         handleweaponAnimations.anim.SetBool("IsReloading", true);
    524.         range = 0f;
    525.         audioSource2.clip = Akreloadsound;
    526.         audioSource2.Play();
    527.         //Wait for 2 seconds
    528.         yield return new WaitForSeconds(3f);
    529.         AkAmmo += AkBulletsShot;
    530.         AkMaxAmmo -= AkBulletsShot;
    531.         AkBulletsShot = 0;
    532.         range = 100f;
    533.         IsReloading = false;
    534.         handleweaponAnimations.anim.SetBool("IsReloading", false);
    535.     }
    536.  
    537.     IEnumerator M1911NoAmmo()
    538.     {
    539.         IsReloading = true;
    540.         range = 0f;
    541.         audioSource2.clip = M1911reloadsound;
    542.         audioSource2.Play();
    543.         //Wait for 2 seconds
    544.         yield return new WaitForSeconds(3f);
    545.         M1911Ammo += M1911BulletsShot;
    546.         M1911MaxAmmo -= M1911BulletsShot;
    547.         M1911BulletsShot = 0;
    548.         range = 100f;
    549.         IsReloading = false;
    550.     }
    551. }
    552.  
    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.Networking;
    6.  
    7.  
    8. public class HandleWeaponAnimations : NetworkBehaviour {
    9.  
    10.     public HandleWeapons handleWeapons;
    11.     public Gun gun;
    12.     public Animator anim;
    13.  
    14.     //All the weapon animators:
    15.     public RuntimeAnimatorController AkAnim;
    16.     public RuntimeAnimatorController M1911Anim;
    17.     public RuntimeAnimatorController KnifeAnim;
    18.     public RuntimeAnimatorController ThompsonAnim;
    19.     public RuntimeAnimatorController WaltherPKKAnim;
    20.     public RuntimeAnimatorController BenelliM4Anim;
    21.     public RuntimeAnimatorController RevolverAnim;
    22.     public RuntimeAnimatorController RemingtonM24Anim;
    23.     public RuntimeAnimatorController M9Anim;
    24.  
    25.     //All the weapon avatars for animations:
    26.     public Avatar Akavatar;
    27.     public Avatar M1911avatar;
    28.     public Avatar Knifeavatar;
    29.     public Avatar Thompsonavatar;
    30.     public Avatar WaltherPKKavatar;
    31.     public Avatar BenelliM4avatar;
    32.     public Avatar Revolveravatar;
    33.     public Avatar RemingtonM24avatar;
    34.     public Avatar M9avatar;
    35.  
    36.     //This decides what knife attack animation should play:
    37.     public int AttackValue;
    38.  
    39.     public int maxAttackValue = 4;
    40.     public int minAttackValue = 1;
    41.  
    42.     public bool Attack1;
    43.     public bool Attack2;
    44.     public bool Attack3;
    45.  
    46.     //These are all the aim bools for the guns:
    47.     public bool AkIsAiming;
    48.     public bool M1911IsAiming;
    49.  
    50.     private float nextTimeToFire = 0f;
    51.     public float fireRate = 3.5f;
    52.  
    53.     // Use this for initialization
    54.     void Start() {
    55.     }
    56.  
    57.     // Update is called once per frame
    58.     void Update()
    59.     {
    60.         if (isLocalPlayer)
    61.         {
    62.             nextTimeToFire = Time.time + 1f / fireRate;
    63.  
    64.             //If you are using the "Assault class" set the animations for the class:
    65.             if (handleWeapons.Assault == true)
    66.             {
    67.                 CmdSetAnimators();
    68.             }
    69.  
    70.             //If you are using the "Scout class" set the animations for the class:
    71.            else if(handleWeapons.Scout == true)
    72.             {
    73.                 CmdSetScoutAnimators();
    74.             }
    75.  
    76.             //If you are using the "Support class" set the animations for the class:
    77.            else if (handleWeapons.Support == true)
    78.             {
    79.                 CmdSetSupportAnimators();
    80.             }
    81.  
    82.             //If you are using the "Recon class" set the animations for the class:
    83.             else if(handleWeapons.Recon == true)
    84.             {
    85.                 CmdSetReconAnimators();
    86.             }
    87.  
    88.         }
    89.     }
    90.  
    91.     [Command]
    92.     void CmdSetAttackValue()
    93.     {
    94.         RpcSetAttackValue();
    95.     }
    96.  
    97.     [ClientRpc]
    98.     void RpcSetAttackValue()
    99.     {
    100.         AttackValue = (Random.Range(minAttackValue, maxAttackValue));
    101.     }
    102.  
    103.     //The "Support class" animations:
    104.     [Command]
    105.     void CmdSetSupportAnimators()
    106.     {
    107.         RpcSetSupportAnimators();
    108.     }
    109.  
    110.     [ClientRpc]
    111.     void RpcSetSupportAnimators()
    112.     {
    113.         if (handleWeapons.SelectedWeapon == 1)
    114.         {
    115.             CmdSetBenelliM4Anim();
    116.         }
    117.         if (handleWeapons.SelectedWeapon == 2)
    118.         {
    119.             CmdSetKnifeAnim();
    120.         }
    121.         if (handleWeapons.SelectedWeapon == 3)
    122.         {
    123.             CmdSetRevolverAnim();
    124.         }
    125.     }
    126.  
    127.     //The "Recon class" animations:
    128.     [Command]
    129.     void CmdSetReconAnimators()
    130.     {
    131.         RpcSetReconAnimators();
    132.     }
    133.  
    134.     [ClientRpc]
    135.     void RpcSetReconAnimators()
    136.     {
    137.         if (handleWeapons.SelectedWeapon == 1)
    138.         {
    139.             CmdSetRemingtonM24Anim();
    140.         }
    141.         if (handleWeapons.SelectedWeapon == 2)
    142.         {
    143.             CmdSetKnifeAnim();
    144.         }
    145.         if (handleWeapons.SelectedWeapon == 3)
    146.         {
    147.             CmdSetM9Anim();
    148.         }
    149.     }
    150.  
    151.     //The "Scout class" animations:
    152.     [Command]
    153.     void CmdSetScoutAnimators()
    154.     {
    155.         RpcSetScoutAnimators();
    156.     }
    157.  
    158.     [ClientRpc]
    159.     void RpcSetScoutAnimators()
    160.     {
    161.         if (handleWeapons.SelectedWeapon == 1)
    162.         {
    163.             CmdSetThompsonAnim();
    164.         }
    165.         if (handleWeapons.SelectedWeapon == 2)
    166.         {
    167.             CmdSetKnifeAnim();
    168.         }
    169.         if (handleWeapons.SelectedWeapon == 3)
    170.         {
    171.             CmdSetWaltherPKKAnim();
    172.         }
    173.     }
    174.  
    175.     //The "Assault class" animations:
    176.     [Command]
    177.     void CmdSetAnimators()
    178.     {
    179.         RpcSetAnimators();
    180.     }
    181.  
    182.     [ClientRpc]
    183.     void RpcSetAnimators()
    184.     {
    185.         if (handleWeapons.SelectedWeapon == 1)
    186.         {
    187.             CmdSetAkAnim();
    188.         }
    189.         if (handleWeapons.SelectedWeapon == 2)
    190.         {
    191.             CmdSetKnifeAnim();
    192.         }
    193.         if (handleWeapons.SelectedWeapon == 3)
    194.         {
    195.             CmdSetM1911Anim();
    196.         }
    197.     }
    198.  
    199.     //The RemingtonM24 animations:
    200.     [Command]
    201.     void CmdSetRemingtonM24Anim()
    202.     {
    203.         RpcSetRemingtonM24Anim();
    204.     }
    205.  
    206.     [ClientRpc]
    207.     void RpcSetRemingtonM24Anim()
    208.     {
    209.         handleWeapons.anim.runtimeAnimatorController = RemingtonM24Anim;
    210.         handleWeapons.anim.avatar = RemingtonM24avatar;
    211.         anim.runtimeAnimatorController = RemingtonM24Anim;
    212.         anim.avatar = RemingtonM24avatar;
    213.     }
    214.  
    215.     //The M9 animations:
    216.     [Command]
    217.     void CmdSetM9Anim()
    218.     {
    219.         RpcSetM9Anim();
    220.     }
    221.  
    222.     [ClientRpc]
    223.     void RpcSetM9Anim()
    224.     {
    225.         handleWeapons.anim.runtimeAnimatorController = M9Anim;
    226.         handleWeapons.anim.avatar = M9avatar;
    227.         anim.runtimeAnimatorController = M9Anim;
    228.         anim.avatar = M9avatar;
    229.     }
    230.  
    231.     //The BenelliM4 animations:
    232.     [Command]
    233.     void CmdSetBenelliM4Anim()
    234.     {
    235.         RpcSetBenelliM4Anim();
    236.     }
    237.  
    238.     [ClientRpc]
    239.     void RpcSetBenelliM4Anim()
    240.     {
    241.         handleWeapons.anim.runtimeAnimatorController = BenelliM4Anim;
    242.         handleWeapons.anim.avatar = BenelliM4avatar;
    243.         anim.runtimeAnimatorController = BenelliM4Anim;
    244.         anim.avatar = BenelliM4avatar;
    245.     }
    246.  
    247.     //The Revolver animations:
    248.     [Command]
    249.     void CmdSetRevolverAnim()
    250.     {
    251.         RpcSetRevolverAnim();
    252.     }
    253.  
    254.     [ClientRpc]
    255.     void RpcSetRevolverAnim()
    256.     {
    257.         handleWeapons.anim.runtimeAnimatorController = RevolverAnim;
    258.         handleWeapons.anim.avatar = Revolveravatar;
    259.         anim.runtimeAnimatorController = RevolverAnim;
    260.         anim.avatar = Revolveravatar;
    261.     }
    262.  
    263.     //The Ak animations:
    264.     [Command]
    265.     void CmdSetAkAnim()
    266.     {
    267.         RpcSetAkAnim();
    268.     }
    269.  
    270.     [ClientRpc]
    271.     void RpcSetAkAnim()
    272.     {
    273.         handleWeapons.anim.runtimeAnimatorController = AkAnim;
    274.         handleWeapons.anim.avatar = Akavatar;
    275.         anim.runtimeAnimatorController = AkAnim;
    276.         anim.avatar = Akavatar;
    277.     }
    278.  
    279.     //The M1911 animations:
    280.     [Command]
    281.     void CmdSetM1911Anim()
    282.     {
    283.         RpcSetM1911Anim();
    284.     }
    285.  
    286.     [ClientRpc]
    287.     void RpcSetM1911Anim()
    288.     {
    289.         handleWeapons.anim.runtimeAnimatorController = M1911Anim;
    290.         handleWeapons.anim.avatar = M1911avatar;
    291.         anim.runtimeAnimatorController = M1911Anim;
    292.         anim.avatar = M1911avatar;
    293.     }
    294.  
    295.     //The Knife animations:
    296.     [Command]
    297.     void CmdSetKnifeAnim()
    298.     {
    299.         RpcSetKnifeAnim();
    300.     }
    301.  
    302.     [ClientRpc]
    303.     void RpcSetKnifeAnim()
    304.     {
    305.         handleWeapons.anim.runtimeAnimatorController = KnifeAnim;
    306.         handleWeapons.anim.avatar = Knifeavatar;
    307.         anim.runtimeAnimatorController = KnifeAnim;
    308.         anim.avatar = Knifeavatar;
    309.     }
    310.  
    311.     //The Thompson animations:
    312.     [Command]
    313.     void CmdSetThompsonAnim()
    314.     {
    315.         RpcSetThompsonAnim();
    316.     }
    317.  
    318.     [ClientRpc]
    319.     void RpcSetThompsonAnim()
    320.     {
    321.         handleWeapons.anim.runtimeAnimatorController = ThompsonAnim;
    322.         handleWeapons.anim.avatar = Thompsonavatar;
    323.         anim.runtimeAnimatorController = ThompsonAnim;
    324.         anim.avatar = Thompsonavatar;
    325.     }
    326.  
    327.     //The WaltherPKK animations:
    328.     [Command]
    329.     void CmdSetWaltherPKKAnim()
    330.     {
    331.         RpcSetWaltherPKKAnim();
    332.     }
    333.  
    334.     [ClientRpc]
    335.     void RpcSetWaltherPKKAnim()
    336.     {
    337.         handleWeapons.anim.runtimeAnimatorController = WaltherPKKAnim;
    338.         handleWeapons.anim.avatar = WaltherPKKavatar;
    339.         anim.runtimeAnimatorController = WaltherPKKAnim;
    340.         anim.avatar = WaltherPKKavatar;
    341.     }
    342.  
    343.     //The S***ty aim and attack animations (that are not working):
    344.     [Command]
    345.     void CmdM1911Aim()
    346.     {
    347.         RpcM1911Aim();
    348.     }
    349.  
    350.     [ClientRpc]
    351.     void RpcM1911Aim()
    352.     {
    353.         M1911IsAiming = true;
    354.         anim.SetBool("M1911IsAiming", M1911IsAiming);
    355.         anim.SetBool("M1911IsAiming", true);
    356.     }
    357.  
    358.     [Command]
    359.     void Cmdm1911NotAim()
    360.     {
    361.         RpcM1911NotAim();
    362.     }
    363.  
    364.     [ClientRpc]
    365.     void RpcM1911NotAim()
    366.     {
    367.         M1911IsAiming = false;
    368.         anim.SetBool("M1911IsAiming", false);
    369.     }
    370.  
    371.     [Command]
    372.     void CmdAkAim()
    373.     {
    374.         RpcAkAim();
    375.     }
    376.  
    377.     [ClientRpc]
    378.     void RpcAkAim()
    379.     {
    380.         AkIsAiming = true;
    381.         anim.SetBool("AkIsAiming", AkIsAiming);
    382.         anim.SetBool("AkIsAiming", true);
    383.     }
    384.  
    385.     [Command]
    386.     void CmdKnifeAttack1()
    387.     {
    388.         RpcKnifeAttack1();
    389.     }
    390.  
    391.     [ClientRpc]
    392.     void RpcKnifeAttack1()
    393.     {
    394.         Attack1 = true;
    395.         anim.SetBool("Attack 1", true);
    396.         anim.SetBool("Attack 1", Attack1);
    397.     }
    398.  
    399.     [Command]
    400.     void CmdKnifeNotAttack()
    401.     {
    402.         RpcKnifeNotAttack();
    403.     }
    404.  
    405.     [ClientRpc]
    406.     void RpcKnifeNotAttack()
    407.     {
    408.         Attack1 = false;
    409.         Attack2 = false;
    410.         Attack3 = false;
    411.         anim.SetBool("Attack 1", false);
    412.         anim.SetBool("Attack 2", false);
    413.         anim.SetBool("Attack 3", false);
    414.     }
    415.  
    416.     [Command]
    417.     void CmdKnifeAttack2()
    418.     {
    419.         RpcKnifeAttack2();
    420.     }
    421.  
    422.     [ClientRpc]
    423.     void RpcKnifeAttack2()
    424.     {
    425.         Attack2 = true;
    426.         anim.SetBool("Attack 2", true);
    427.         anim.SetBool("Attack 2", Attack2);
    428.     }
    429.  
    430.     [Command]
    431.     void CmdKnifeAttack3()
    432.     {
    433.         RpcKnifeAttack3();
    434.     }
    435.  
    436.     [ClientRpc]
    437.     void RpcKnifeAttack3()
    438.     {
    439.         Attack3 = true;
    440.         anim.SetBool("Attack 3", true);
    441.         anim.SetBool("Attack 3", Attack3);
    442.     }
    443.  
    444.     [Command]
    445.     void CmdAkNotAim()
    446.     {
    447.         RpcAkNotAim();
    448.     }
    449.  
    450.     [ClientRpc]
    451.     void RpcAkNotAim()
    452.     {
    453.         AkIsAiming = false;
    454.         anim.SetBool("AkIsAiming", false);
    455.     }
    456.  
    457. }
    458.  
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'm the wrong person to ask about NetworkAnimators, as I've never used them. Perhaps someone else can help.