Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

fpsarmedunity

Premium Member
  • Content Count

    139
  • Joined

  • Last visited

  • Days Won

    2

fpsarmedunity last won the day on October 25 2016

fpsarmedunity had the most liked content!

Community Reputation

12 Good

About fpsarmedunity

  • Rank
    Member
  • Birthday 11/20/1950

Profile Information

  • Gender
    Male
  • Location:
    World

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. fpsarmedunity

    Pickup Grenade issue FPSKIT

    anyone could try to help me?' i added this code into weaponmanager script like old 1.3.5 but result doesnt change Vector3 pos = transform.parent.position; Vector3 dir = transform.TransformDirection(Vector3.forward); if (Physics.Raycast(pos, dir, out hit, dis, layerMaskWeapon)) { WeaponIndex pre = hit.transform.GetComponent<WeaponIndex>(); setElement = pre.setWeapon; if (!showWepGui) { if (weaponsInUse[0] != weaponsInGame[setElement] && weaponsInUse[1] != weaponsInGame[setElement]) { equipped = false; noteUI.text = "Press key <color=#88FF6AFF> << E >> </color> to pickup weapon"; } else { equipped = true; noteUI.text = "Weapon is already equipped"; } showWepGui = true; } if (canSwitch && !equipped) { if (Input.GetKeyDown("e")) { DropWeapon(weaponToDrop); StartCoroutine(DeselectWeapon()); weaponsInUse[weaponToSelect] = weaponsInGame[setElement]; if (setElement == 6) { Pickup pickupGOW1 = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW1.amount); } Destroy(hit.transform.gameObject); } else { if (setElement == 6) { if (Input.GetKeyDown("e")) { Pickup pickupGOW = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW.amount); Destroy(hit.collider.transform.parent.gameObject); } } } } } else { if (showWepGui) { noteUI.text = ""; showWepGui = false; } } specifically added these lines into it if (setElement == 6) { Pickup pickupGOW1 = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW1.amount); } Destroy(hit.transform.gameObject); } else { if (setElement == 6) { if (Input.GetKeyDown("e")) { Pickup pickupGOW = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW.amount); Destroy(hit.collider.transform.parent.gameObject); } like the grenade into fpskit 1.3.5 and added the void void addStickGrenades(int amount) { GrenadeScript stickGrenade = weaponsInGame[6].gameObject.transform.GetComponent<GrenadeScript>(); stickGrenade.grenadeCount += amount; stickGrenade.DrawWeapon(); } this in fpskit 1.3.5 work like a charm but i cannot manage to get it work into 1.6
  2. fpsarmedunity

    Pickup Grenade issue FPSKIT

    yes i know i must to add something in this part of code but rally cannot figure what...eheheh if (Physics.Raycast(pos, dir, out hit, dis, layerMaskWeapon)) { // Pickup pickupGO = hit.transform.GetComponent<Pickup>(); WeaponIndex pre = hit.transform.GetComponent<WeaponIndex>(); setElement = pre.setWeapon; if (!showWepGui) { //Pickup pickupGO = hit.transform.GetComponent<Pickup>(); if (weaponsInUse[0] != weaponsInGame[setElement] && weaponsInUse[1] != weaponsInGame[setElement]) { //Pickup pickupGO = hit.transform.GetComponent<Pickup>(); equipped = false; //noteUI.text = "Press key <color=#88FF6AFF> << E >> </color> to pickup weapon"; //textFromPickupScript = "Press key <color=#88FF6AFF> << E >> </color> to pick up " + pickupGO.itemDatabaseName; //notes = ""; noteUI.text = "Press key to <color=#88FF6AFF> << E >> </color> to pickup " + hit.transform.name; //noteUI.text = "Press key <color=#88FF6AFF> << E >> </color> to pickup weapon"; } else { equipped = true; //noteUI.text = "Weapon is already equipped"; noteUI.text = hit.transform.name + " is already equipped"; //noteUI.text = "Weapon is already equipped"; } showWepGui = true; } if (Input.GetKeyDown(KeyCode.E)) if (inWater) if (Inventory.instance.CheckForEmptySlot()) { for (int i = 0; i < weaponsInGame.Length; i++) if (weaponsInGame[i].transform.GetComponent<WeaponIndex>().setWeapon == hit.transform.GetComponent<WeaponIndex>().setWeapon) for (int m = 0; m < Inventory_ItemDatabase.instance.itemsDatabase.Count; m++) if (Inventory_ItemDatabase.instance.itemsDatabase[m].itemName == weaponsInGame[i].transform.name) { Inventory.instance.AddItem(Inventory_ItemDatabase.instance.itemsDatabase[m].itemID); Destroy(hit.transform.gameObject); aSource.PlayOneShot(pickupSound, 0.3f); } } if (canSwitch && !equipped) { if (Input.GetKeyDown("e")) { /*DropWeapon(weaponToDrop); StartCoroutine(DeselectWeapon()); weaponsInUse[weaponToSelect] = weaponsInGame[setElement]; Destroy(hit.transform.gameObject);*/ if (Inventory.instance.CheckForEmptySlot()) { if (WeaponCurrentlySelected()) { switch (weaponToSelect) { case 0: StartCoroutine(SwitchWeaponFromGround(3, hit.transform)); break; case 1: StartCoroutine(SwitchWeaponFromGround(4, hit.transform)); break; } } else if (!WeaponCurrentlySelected()) { weaponsInUse[weaponToSelect] = weaponsInGame[setElement]; StartCoroutine(SelectWeapon(weaponToSelect)); /* //GreNADES if (setElement == 8) { Pickup pickupGOW1 = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW1.amount); } // eND gRENADES */ switch (weaponToSelect) { case 0: for (int i = 0; i < Inventory_ItemDatabase.instance.itemsDatabase.Count; i++) if (Inventory_ItemDatabase.instance.itemsDatabase[i].itemName == weaponsInUse[weaponToSelect].transform.name) Inventory.instance.equippedItems[3] = Inventory_ItemDatabase.instance.itemsDatabase[i]; if (Inventory.instance.currentlyHeldItem != null) Inventory.instance.UnHoldItem(); break; case 1: for (int i = 0; i < Inventory_ItemDatabase.instance.itemsDatabase.Count; i++) if (Inventory_ItemDatabase.instance.itemsDatabase[i].itemName == weaponsInUse[weaponToSelect].transform.name) Inventory.instance.equippedItems[4] = Inventory_ItemDatabase.instance.itemsDatabase[i]; if (Inventory.instance.currentlyHeldItem != null) Inventory.instance.UnHoldItem(); break; } Destroy(hit.transform.gameObject); Inventory.instance.UnSelectSlot(); Inventory.instance.UnHighlightSelectedSlot(Inventory.instance.SelectedSlot + 1); Inventory.instance.HideActionButtons(); if (Inventory_UI.instance.selectedConsumablePopup.transform.GetComponent<Animator>().GetBool("Showing")) { Inventory_Animations.instance.PlayInventoryAnimation(Inventory_UI.instance.selectedConsumablePopup.transform, "Inventory_ConsumablePopup_Hide"); Inventory_UI.instance.selectedConsumablePopup.transform.GetComponent<Animator>().SetBool("Showing", false); } } } else if (Inventory.instance.CheckForEmptySlot() == false) { if (WeaponCurrentlySelected()) { switch (weaponToSelect) { case 0: StartCoroutine(DropAndSwitchFromGround(3, hit.transform)); break; case 1: StartCoroutine(DropAndSwitchFromGround(4, hit.transform)); break; } } else if (!WeaponCurrentlySelected()) { weaponsInUse[weaponToSelect] = weaponsInGame[setElement]; StartCoroutine(SelectWeapon(weaponToSelect)); /* // Grenades start if (setElement == 8) { if (Input.GetKeyDown("e")) { Pickup pickupGOW = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW.amount); Destroy(hit.collider.transform.parent.gameObject); } } // greandes end */ switch (weaponToSelect) { case 0: for (int i = 0; i < Inventory_ItemDatabase.instance.itemsDatabase.Count; i++) if (Inventory_ItemDatabase.instance.itemsDatabase[i].itemName == weaponsInUse[weaponToSelect].transform.name) Inventory.instance.equippedItems[3] = Inventory_ItemDatabase.instance.itemsDatabase[i]; if (Inventory.instance.currentlyHeldItem != null) Inventory.instance.UnHoldItem(); break; case 1: for (int i = 0; i < Inventory_ItemDatabase.instance.itemsDatabase.Count; i++) if (Inventory_ItemDatabase.instance.itemsDatabase[i].itemName == weaponsInUse[weaponToSelect].transform.name) Inventory.instance.equippedItems[4] = Inventory_ItemDatabase.instance.itemsDatabase[i]; if (Inventory.instance.currentlyHeldItem != null) Inventory.instance.UnHoldItem(); break; } Destroy(hit.transform.gameObject); Inventory.instance.UnSelectSlot(); Inventory.instance.UnHighlightSelectedSlot(Inventory.instance.SelectedSlot + 1); Inventory.instance.HideActionButtons(); if (Inventory_UI.instance.selectedConsumablePopup.transform.GetComponent<Animator>().GetBool("Showing")) { Inventory_Animations.instance.PlayInventoryAnimation(Inventory_UI.instance.selectedConsumablePopup.transform, "Inventory_ConsumablePopup_Hide"); Inventory_UI.instance.selectedConsumablePopup.transform.GetComponent<Animator>().SetBool("Showing", false); } } } } } } else { if (showWepGui) { noteUI.text = ""; showWepGui = false; }
  3. fpsarmedunity

    Pickup Grenade issue FPSKIT

    yes grenade index is 8.. but i'm not figuring to correclty find the exact call for wepaon pickup
  4. fpsarmedunity

    Pickup Grenade issue FPSKIT

    sorry double post
  5. fpsarmedunity

    Pickup Grenade issue FPSKIT

    Hi to al i'm experimenting with my fpskit template and thaks to OMA and TheMars I added many cool stuffs like inventory system, parkour, damange trigger system, simple static ranged ai, survival system (hunger, thirst, stamina, cold, radiation ect), and so on.. Now I'm managing to add throwables like wepaons and spears ect.. and I integrated the Grenadescript from old Fpskit and all works fine.. player can pickup grenades, throw them, items are correcly added to inventory and and dropped from it ect... My only issue the ammo pickup after player picked up weapon.. i try to explain better when player approach the weapon it can pickup the weapon and grenade goes into a weapon slot like other weapons ..but if player try to take another grenade ..since grenade is a weapon itself i got the message "weapon already equipped) like the video..waht i want to know is if is there a way i can make player pickup many grenades sewunatially and these t obe added to the total grenade count any help is appreciated https://youtu.be/gfsHsOr9Goo
  6. Hi, how can i do if i want to set a specific weapon if a condition happen if fpskt 1.6? e.g. I want player automatically set his weapon to element "0" (no wepaon) if grenade count from WeaponScriptNew is zero so in Weapon Script New i added simply if (grenadeCount == 0) { wepManager.weaponToSelect = wepManager.weaponsInGame[0]; } but i got this error Cannot implicitly convert type `UnityEngine.GameObject' to `int'
  7. fpsarmedunity

    help with granade script port fpskit

    No one can help me my only BIG issue is that if player pickup a grenade and after tries to pickup another grenade i got the messeage "weapon already equipped" and obviusly this is not supposed to work this way.. So i wathced the code into fpskt 1.3.5 converted in c# some years ago and found the lines of coed i need to add in weapon manager { if (!equipped && Input.GetKeyDown("e")) { DropWeapon(weaponToDrop); DeselectWeapon(); weaponsInUse[weaponToSelect] = weaponsInGame[setElement]; if (setElement == 8) { Pickup pickupGOW1 = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW1.amount);  } Destroy(hit.collider.transform.parent.gameObject); } else { if (setElement == 8) { if (Input.GetKeyDown("e")) {  Pickup pickupGOW = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW.amount); Destroy(hit.collider.transform.parent.gameObject); } } } } and this void addStickGrenades(int amount) { GrenadeScript stickGrenade = weaponsInGame[8].gameObject.transform.GetComponent<GrenadeScript>(); stickGrenade.grenadeCount += amount; stickGrenade.DrawWeapon(); } and accordly added the "StickGrenades" field in my pickup script this way using UnityEngine; using System.Collections; //FPS KIT [www.armedunity.com] public enum PickupType { Health, Magazines, Projectiles, StickGrenades } public class Pickup : MonoBehaviour { public PickupType pickupType = PickupType.Health; public int amount = 3; public string AmmoInfo = ""; } if(canSwitch){ if(!equipped && Input.GetKeyDown ("e")){ DropWeapon(weaponToDrop); DeselectWeapon(); weaponsInUse[weaponToSelect] = weaponsInGame[setElement]; if(setElement == 8){ var pickupGOW1 : Pickup = hit.transform.GetComponent("Pickup"); addStickGrenades(pickupGOW1.amount); } if(setElement == 28){ var pickupGOW2 : Pickup = hit.transform.GetComponent("Pickup"); addStickGrenades2(pickupGOW2.amount); } if(setElement == 30){ var pickupGOW3 : Pickup = hit.transform.GetComponent("Pickup"); addStickGrenades3(pickupGOW3.amount); } if(setElement == 36){ var pickupGOW4 : Pickup = hit.transform.GetComponent("Pickup"); addStickGrenades4(pickupGOW4.amount); } Destroy(hit.collider.transform.parent.gameObject); }else{ if(setElement == 8){ if(Input.GetKeyDown ("e")){ var pickupGOW : Pickup = hit.transform.GetComponent("Pickup"); addStickGrenades(pickupGOW.amount); Destroy(hit.collider.transform.parent.gameObject); } } if(setElement == 28){ if(Input.GetKeyDown ("e")){ var pickupGOW22 : Pickup = hit.transform.GetComponent("Pickup"); addStickGrenades2(pickupGOW22.amount); Destroy(hit.collider.transform.parent.gameObject); } } if(setElement == 30){ if(Input.GetKeyDown ("e")){ var pickupGOW33 : Pickup = hit.transform.GetComponent("Pickup"); addStickGrenades3(pickupGOW33.amount); Destroy(hit.collider.transform.parent.gameObject); } } if(setElement == 36){ if(Input.GetKeyDown ("e")){ var pickupGOW44 : Pickup = hit.transform.GetComponent("Pickup"); addStickGrenades4(pickupGOW44.amount); Destroy(hit.collider.transform.parent.gameObject); } } } } function addStickGrenades(amount : int){ yield WaitForSeconds(.5); var stickGrenade : GrenadeScript = weaponsInGame[8].gameObject.transform.GetComponent("GrenadeScript"); stickGrenade.grenadeCount += amount; stickGrenade.DrawWeapon(); } function addStickGrenades2(amount : int){ yield WaitForSeconds(.5); var mortarGrenade : MortarScript = weaponsInGame[28].gameObject.transform.GetComponent("MortarScript"); mortarGrenade.mortarCount += amount; mortarGrenade.DrawWeapon(); } function addStickGrenades3(amount : int){ yield WaitForSeconds(.5); var minaGrenade : MinaScript = weaponsInGame[30].gameObject.transform.GetComponent("MinaScript"); minaGrenade.minaCount += amount; minaGrenade.DrawWeapon(); } function addStickGrenades4(amount : int){ yield WaitForSeconds(.5); var molotovGrenade : MolotovScript = weaponsInGame[36].gameObject.transform.GetComponent("MolotovScript"); molotovGrenade.molotovCount += amount; molotovGrenade.DrawWeapon(); } and all works fine in this project... here y modified weapon manager scirpt using UnityEngine; using System.Collections; using UnityEngine.UI; public class WeaponManager : MonoBehaviour { //FPS KIT [www.armedunity.com] private GameObject[] weaponsInUse = new GameObject[2]; public GameObject[] weaponsInGame; public Rigidbody[] worldModels; public RaycastHit hit; private float dis = 3.0f; public LayerMask layerMaskWeapon; public LayerMask layerMaskAmmo; public Transform dropPosition; private float switchWeaponTime = 0.25f; public bool canSwitch = true; private bool equipped = false; [HideInInspector] public bool showWepGui = false; [HideInInspector] public bool showAmmoGui = false; [HideInInspector] public int weaponToSelect; [HideInInspector] public int setElement; [HideInInspector] public int weaponToDrop; [HideInInspector] public float crosshairSize; public AudioClip pickupSound; public AudioSource aSource; public HealthScript hs; private string textFromPickupScript = ""; private string notes = ""; private string note = "Press key <color=#88FF6AFF> << E >> </color> to pick up Ammo"; private string wrongType = "Select appropriate weapon to pick up"; public int selectWepSlot1 = 0; public int selectWepSlot2 = 0; Text noteUI; void Start() { noteUI = CanvasManager.instance.note; CanvasManager.instance.SetWeapon(this); for (int h = 0; h < worldModels.Length; h++) { weaponsInGame[h].SetActive(false); } weaponsInUse[0] = weaponsInGame[selectWepSlot1]; weaponsInUse[1] = weaponsInGame[selectWepSlot2]; weaponToSelect = 0; StartCoroutine(DeselectWeapon()); } void Update() { if (Cursor.lockState == CursorLockMode.None) return; if (Input.GetKeyDown("1") && weaponsInUse.Length >= 1 && canSwitch && weaponToSelect != 0) { StartCoroutine(DeselectWeapon()); weaponToSelect = 0; } else if (Input.GetKeyDown("2") && weaponsInUse.Length >= 2 && canSwitch && weaponToSelect != 1) { StartCoroutine(DeselectWeapon()); weaponToSelect = 1; } if (Input.GetAxis("Mouse ScrollWheel") > 0 && canSwitch) { weaponToSelect++; if (weaponToSelect > (weaponsInUse.Length - 1)) { weaponToSelect = 0; } StartCoroutine(DeselectWeapon()); } if (Input.GetAxis("Mouse ScrollWheel") < 0 && canSwitch) { weaponToSelect--; if (weaponToSelect < 0) { weaponToSelect = weaponsInUse.Length - 1; } StartCoroutine(DeselectWeapon()); } Vector3 pos = transform.parent.position; Vector3 dir = transform.TransformDirection(Vector3.forward); if (Physics.Raycast(pos, dir, out hit, dis, layerMaskWeapon)) { WeaponIndex pre = hit.transform.GetComponent<WeaponIndex>(); setElement = pre.setWeapon; if (!showWepGui) { if (weaponsInUse[0] != weaponsInGame[setElement] && weaponsInUse[1] != weaponsInGame[setElement]) { equipped = false; noteUI.text = "Press key <color=#88FF6AFF> << E >> </color> to pickup weapon"; } else { equipped = true; noteUI.text = "Weapon is already equipped"; } showWepGui = true; } if (canSwitch && !equipped) { if (Input.GetKeyDown("e")) { DropWeapon(weaponToDrop); StartCoroutine(DeselectWeapon()); weaponsInUse[weaponToSelect] = weaponsInGame[setElement]; // Grenade Integration Start if (setElement == 6) { Pickup pickupGOW1 = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW1.amount); } Destroy(hit.transform.gameObject); //Grenade Integration end } else { if (setElement == 6) { if (Input.GetKeyDown("e")) { Pickup pickupGOW = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW.amount); Destroy(hit.collider.transform.parent.gameObject); } } } } } else { if (showWepGui) { noteUI.text = ""; showWepGui = false; } } if (Physics.Raycast(pos, dir, out hit, dis, layerMaskAmmo)) { if (hit.transform.CompareTag("Ammo")) { Pickup pickupGO = hit.transform.GetComponent<Pickup>(); //bullets/magazines if (pickupGO.pickupType == PickupType.Magazines) { WeaponScriptNEW mags = weaponsInUse[weaponToSelect].transform.GetComponent<WeaponScriptNEW>(); if (mags == null) { textFromPickupScript = ""; return; } if (mags.firstMode != fireMode.launcher) { notes = ""; textFromPickupScript = note; if (Input.GetKeyDown("e")) { if (mags.ammoMode == Ammo.Magazines) mags.magazines += pickupGO.amount; else mags.magazines += pickupGO.amount * mags.bulletsPerMag; CanvasManager.instance.UpdateMags(mags.magazines); aSource.PlayOneShot(pickupSound, 0.3f); Destroy(hit.transform.gameObject); } } else { textFromPickupScript = pickupGO.AmmoInfo; notes = wrongType; } } //projectiles/rockets if (pickupGO.pickupType == PickupType.Projectiles) { WeaponScriptNEW projectile = weaponsInUse[weaponToSelect].transform.GetComponent<WeaponScriptNEW>(); if (projectile == null) { textFromPickupScript = ""; return; } if (projectile.secondMode == fireMode.launcher || projectile.firstMode == fireMode.launcher) { notes = ""; textFromPickupScript = note; if (Input.GetKeyDown("e")) { projectile.projectiles += pickupGO.amount; CanvasManager.instance.UpdateProjectileUI(projectile.projectiles); aSource.PlayOneShot(pickupSound, 0.3f); Destroy(hit.transform.gameObject); } } else { textFromPickupScript = pickupGO.AmmoInfo; notes = wrongType; } } //health if (pickupGO.pickupType == PickupType.Health) { textFromPickupScript = pickupGO.AmmoInfo; notes = ""; if (Input.GetKeyDown("e")) { hs.Medic(pickupGO.amount); aSource.PlayOneShot(pickupSound, 0.3f); Destroy(hit.transform.gameObject); } } } if(!showAmmoGui) { noteUI.text = notes + "\n" + textFromPickupScript; showAmmoGui = true; } } else { if(showAmmoGui) { noteUI.text = ""; showAmmoGui = false; } } } // Grenade Integration Start void addStickGrenades(int amount) { GrenadeScript stickGrenade = weaponsInGame[6].gameObject.transform.GetComponent<GrenadeScript>(); stickGrenade.grenadeCount += amount; stickGrenade.DrawWeapon(); } // Grenade Integration End IEnumerator DeselectWeapon() { canSwitch = false; for (int i = 0; i < weaponsInUse.Length; i++) { if(weaponsInUse[i].GetComponent<WeaponScriptNEW>() != null) weaponsInUse[i].GetComponent<WeaponScriptNEW>().Deselect(); weaponsInUse[i].gameObject.SetActive(false); } yield return new WaitForSeconds(switchWeaponTime); SelectWeapon(weaponToSelect); yield return new WaitForSeconds(switchWeaponTime); canSwitch = true; } void SelectWeapon(int i) { weaponsInUse[i].gameObject.SetActive(true); weaponsInUse[i].SendMessage("DrawWeapon", SendMessageOptions.DontRequireReceiver); WeaponIndex temp = weaponsInUse[i].transform.GetComponent<WeaponIndex>(); weaponToDrop = temp.setWeapon; } void DropWeapon(int index) { if (index == 0) return; for (int i = 0; i < worldModels.Length; i++) { if (i == index) { Rigidbody drop = Instantiate(worldModels[i], dropPosition.transform.position, dropPosition.transform.rotation) as Rigidbody; drop.AddRelativeForce(0, 250, Random.Range(100, 200)); drop.AddTorque(-transform.up * 40); } } } public void EnterWater() { canSwitch = false; for (int i = 0; i < weaponsInUse.Length; i++) { if(weaponsInUse[i].GetComponent<WeaponScriptNEW>() != null) weaponsInUse[i].GetComponent<WeaponScriptNEW>().Deselect(); weaponsInUse[i].gameObject.SetActive(false); } } public void ExitWater() { canSwitch = true; SelectWeapon(weaponToSelect); } } So i wathced the code into your fpskt 1.3.5 you converted in c# some years ago and found the lines of coed i need to add in weapon manager { if (!equipped && Input.GetKeyDown("e")) { DropWeapon(weaponToDrop); DeselectWeapon(); weaponsInUse[weaponToSelect] = weaponsInGame[setElement]; if (setElement == 8) { Pickup pickupGOW1 = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW1.amount);  } Destroy(hit.collider.transform.parent.gameObject); } else { if (setElement == 8) { if (Input.GetKeyDown("e")) {  Pickup pickupGOW = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW.amount); Destroy(hit.collider.transform.parent.gameObject); } } } } void addStickGrenades(int amount) { GrenadeScript stickGrenade = weaponsInGame[8].gameObject.transform.GetComponent<GrenadeScript>(); stickGrenade.grenadeCount += amount; stickGrenade.DrawWeapon(); } and accordly added the "StickGrenades" field in my pickup script this way using UnityEngine; using System.Collections; //FPS KIT [www.armedunity.com] public enum PickupType { Health, Magazines, Projectiles, StickGrenades } public class Pickup : MonoBehaviour { public PickupType pickupType = PickupType.Health; public int amount = 3; public string AmmoInfo = ""; } and now i got some results since player can pickup the correct grenade amount specified into pickup scirpt but i have always the old issue related to the "weapon already equipped" i saw in a old fpskit project i found on internet (but it was JS) named ultimate survivor 2016 that this system works correcly since developer added several type of greandes/throwables and the code is the same but JS obviusly can please someone try to help me.. i cound pay if necessary.. bests
  8. fpsarmedunity

    help with granade script port fpskit

    yes i figuret it after i asked lol.. btw now correct animations and acorrect referernces are assigned and i dont console any error , weapon is correcly picked up and i' able to drop it too ect. anims plays correcly and all works fine.. my only problem is due to the fact that if player take one grenade gameobject and after try to ppicked up others grenades player get message that weapon is already equipped... even if player consumed all grenades it has... i modified the wpeaon manager script to tell if there is a grenade equipeed (SetElement 6) player can take the amount of ammo specified into pickup scritp but something went wrong and player is not able to take othr grenades after first.. using UnityEngine; using System.Collections; using UnityEngine.UI; public class WeaponManager : MonoBehaviour { //FPS KIT [www.armedunity.com] private GameObject[] weaponsInUse = new GameObject[2]; public GameObject[] weaponsInGame; public Rigidbody[] worldModels; public RaycastHit hit; private float dis = 3.0f; public LayerMask layerMaskWeapon; public LayerMask layerMaskAmmo; public Transform dropPosition; private float switchWeaponTime = 0.25f; public bool canSwitch = true; private bool equipped = false; [HideInInspector] public bool showWepGui = false; [HideInInspector] public bool showAmmoGui = false; [HideInInspector] public int weaponToSelect; [HideInInspector] public int setElement; [HideInInspector] public int weaponToDrop; [HideInInspector] public float crosshairSize; public AudioClip pickupSound; public AudioSource aSource; public HealthScript hs; private string textFromPickupScript = ""; private string notes = ""; private string note = "Press key <color=#88FF6AFF> << E >> </color> to pick up Ammo"; private string wrongType = "Select appropriate weapon to pick up"; public int selectWepSlot1 = 0; public int selectWepSlot2 = 0; Text noteUI; void Start() { noteUI = CanvasManager.instance.note; CanvasManager.instance.SetWeapon(this); for (int h = 0; h < worldModels.Length; h++) { weaponsInGame[h].SetActive(false); } weaponsInUse[0] = weaponsInGame[selectWepSlot1]; weaponsInUse[1] = weaponsInGame[selectWepSlot2]; weaponToSelect = 0; StartCoroutine(DeselectWeapon()); } void Update() { if (Cursor.lockState == CursorLockMode.None) return; if (Input.GetKeyDown("1") && weaponsInUse.Length >= 1 && canSwitch && weaponToSelect != 0) { StartCoroutine(DeselectWeapon()); weaponToSelect = 0; } else if (Input.GetKeyDown("2") && weaponsInUse.Length >= 2 && canSwitch && weaponToSelect != 1) { StartCoroutine(DeselectWeapon()); weaponToSelect = 1; } if (Input.GetAxis("Mouse ScrollWheel") > 0 && canSwitch) { weaponToSelect++; if (weaponToSelect > (weaponsInUse.Length - 1)) { weaponToSelect = 0; } StartCoroutine(DeselectWeapon()); } if (Input.GetAxis("Mouse ScrollWheel") < 0 && canSwitch) { weaponToSelect--; if (weaponToSelect < 0) { weaponToSelect = weaponsInUse.Length - 1; } StartCoroutine(DeselectWeapon()); } Vector3 pos = transform.parent.position; Vector3 dir = transform.TransformDirection(Vector3.forward); if (Physics.Raycast(pos, dir, out hit, dis, layerMaskWeapon)) { WeaponIndex pre = hit.transform.GetComponent<WeaponIndex>(); setElement = pre.setWeapon; if (!showWepGui) { if (weaponsInUse[0] != weaponsInGame[setElement] && weaponsInUse[1] != weaponsInGame[setElement]) { equipped = false; noteUI.text = "Press key <color=#88FF6AFF> << E >> </color> to pickup weapon"; } else { equipped = true; noteUI.text = "Weapon is already equipped"; } showWepGui = true; } if (canSwitch && !equipped) { if (Input.GetKeyDown("e")) { DropWeapon(weaponToDrop); StartCoroutine(DeselectWeapon()); weaponsInUse[weaponToSelect] = weaponsInGame[setElement]; // Grenade Integration Start if (setElement == 6) { Pickup pickupGOW1 = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW1.amount); } Destroy(hit.transform.gameObject); //Grenade Integration end } else { if (setElement == 6) { if (Input.GetKeyDown("e")) { Pickup pickupGOW = hit.transform.GetComponent<Pickup>(); addStickGrenades(pickupGOW.amount); Destroy(hit.collider.transform.parent.gameObject); } } } } } else { if (showWepGui) { noteUI.text = ""; showWepGui = false; } } if (Physics.Raycast(pos, dir, out hit, dis, layerMaskAmmo)) { if (hit.transform.CompareTag("Ammo")) { Pickup pickupGO = hit.transform.GetComponent<Pickup>(); //bullets/magazines if (pickupGO.pickupType == PickupType.Magazines) { WeaponScriptNEW mags = weaponsInUse[weaponToSelect].transform.GetComponent<WeaponScriptNEW>(); if (mags == null) { textFromPickupScript = ""; return; } if (mags.firstMode != fireMode.launcher) { notes = ""; textFromPickupScript = note; if (Input.GetKeyDown("e")) { if (mags.ammoMode == Ammo.Magazines) mags.magazines += pickupGO.amount; else mags.magazines += pickupGO.amount * mags.bulletsPerMag; CanvasManager.instance.UpdateMags(mags.magazines); aSource.PlayOneShot(pickupSound, 0.3f); Destroy(hit.transform.gameObject); } } else { textFromPickupScript = pickupGO.AmmoInfo; notes = wrongType; } } //projectiles/rockets if (pickupGO.pickupType == PickupType.Projectiles) { WeaponScriptNEW projectile = weaponsInUse[weaponToSelect].transform.GetComponent<WeaponScriptNEW>(); if (projectile == null) { textFromPickupScript = ""; return; } if (projectile.secondMode == fireMode.launcher || projectile.firstMode == fireMode.launcher) { notes = ""; textFromPickupScript = note; if (Input.GetKeyDown("e")) { projectile.projectiles += pickupGO.amount; CanvasManager.instance.UpdateProjectileUI(projectile.projectiles); aSource.PlayOneShot(pickupSound, 0.3f); Destroy(hit.transform.gameObject); } } else { textFromPickupScript = pickupGO.AmmoInfo; notes = wrongType; } } //health if (pickupGO.pickupType == PickupType.Health) { textFromPickupScript = pickupGO.AmmoInfo; notes = ""; if (Input.GetKeyDown("e")) { hs.Medic(pickupGO.amount); aSource.PlayOneShot(pickupSound, 0.3f); Destroy(hit.transform.gameObject); } } } if(!showAmmoGui) { noteUI.text = notes + "\n" + textFromPickupScript; showAmmoGui = true; } } else { if(showAmmoGui) { noteUI.text = ""; showAmmoGui = false; } } } // Grenade Integration Start void addStickGrenades(int amount) { GrenadeScript stickGrenade = weaponsInGame[6].gameObject.transform.GetComponent<GrenadeScript>(); stickGrenade.grenadeCount += amount; stickGrenade.DrawWeapon(); } // Grenade Integration End IEnumerator DeselectWeapon() { canSwitch = false; for (int i = 0; i < weaponsInUse.Length; i++) { if(weaponsInUse[i].GetComponent<WeaponScriptNEW>() != null) weaponsInUse[i].GetComponent<WeaponScriptNEW>().Deselect(); weaponsInUse[i].gameObject.SetActive(false); } yield return new WaitForSeconds(switchWeaponTime); SelectWeapon(weaponToSelect); yield return new WaitForSeconds(switchWeaponTime); canSwitch = true; } void SelectWeapon(int i) { weaponsInUse[i].gameObject.SetActive(true); weaponsInUse[i].SendMessage("DrawWeapon", SendMessageOptions.DontRequireReceiver); WeaponIndex temp = weaponsInUse[i].transform.GetComponent<WeaponIndex>(); weaponToDrop = temp.setWeapon; } void DropWeapon(int index) { if (index == 0) return; for (int i = 0; i < worldModels.Length; i++) { if (i == index) { Rigidbody drop = Instantiate(worldModels[i], dropPosition.transform.position, dropPosition.transform.rotation) as Rigidbody; drop.AddRelativeForce(0, 250, Random.Range(100, 200)); drop.AddTorque(-transform.up * 40); } } } public void EnterWater() { canSwitch = false; for (int i = 0; i < weaponsInUse.Length; i++) { if(weaponsInUse[i].GetComponent<WeaponScriptNEW>() != null) weaponsInUse[i].GetComponent<WeaponScriptNEW>().Deselect(); weaponsInUse[i].gameObject.SetActive(false); } } public void ExitWater() { canSwitch = true; SelectWeapon(weaponToSelect); } }
  9. fpsarmedunity

    help with granade script port fpskit

    Hi I'm trying to import the grenade script from fpskit 1.3.5 c# version to my template based on fpskit 1.6 i successefully ported the melee script andall works fine (even thanks to TheMars2011 help) but now with GrenadeScript i have some issue since weapon i correcly picked up and drawn onscreen but animations doesnt play and i get an erro on console related to this line of code weaponAnim.GetComponent<Animation>()[grenadePull].wrapMode = WrapMode.ClampForever; NullReferenceException: Object reference not set to an instance of an object GrenadeScriptOrig.Start () (at Assets/FPSKIT135/Meshes/grenadeOLDstyle/GrenadeScriptOrig.cs:39) here the script using UnityEngine; using System.Collections; public class GrenadeScriptOrig : MonoBehaviour { //ANIMATIONS public GameObject weaponAnim; public string idleAnim = "Idle"; public string DrawAnimation = "DrawAXE"; public string grenadeThrow = "GrenadeThrow"; public string grenadePull = "GrenadePull"; public AudioClip soundDraw; //GRENADE public int grenadeCount = 3; public float throwForce = 15.0f; public float powerIncreaseSpeed = 80.0f; private float powerBarFullWidth = 100.0f; private float thePower = 0.0f; private bool increasing = false; private bool throwingGrenade = false; public Rigidbody grenade; public Transform spawnPos; public Renderer grenadeRenderer; //CROSSHAIR public Texture2D crosshair; //GUI public GUISkin mySkin; public bool selected = false; void Start() { weaponAnim.GetComponent<Animation>()[grenadePull].wrapMode = WrapMode.ClampForever; } void Update() { if (selected) { if (grenadeCount > 0 && !throwingGrenade) { if (Input.GetButtonDown("Fire")) { if (thePower < 5) { weaponAnim.GetComponent<Animation>().Stop(); weaponAnim.GetComponent<Animation>()[grenadePull].speed = 1.0f; weaponAnim.GetComponent<Animation>().CrossFade(grenadePull); increasing = true; } } if (Input.GetButtonUp("Fire")) { increasing = false; if (thePower > powerBarFullWidth / 2) { StartCoroutine(ThrowGrenade(thePower)); } else { weaponAnim.GetComponent<Animation>()[grenadePull].speed = -1.0f; weaponAnim.GetComponent<Animation>().CrossFade(grenadePull); } } if (thePower < 0) { thePower = 0; } if (increasing) { thePower += Time.deltaTime * powerIncreaseSpeed; thePower = Mathf.Clamp(thePower, 0, powerBarFullWidth); } else { if (thePower > 0) thePower -= Time.deltaTime * powerIncreaseSpeed * 2; } } } } void OnGUI() { GUI.skin = mySkin; GUIStyle style1 = mySkin.customStyles[0]; GUI.Label(new Rect(Screen.width - 200, Screen.height - 35, 200, 80), "Grenades : "); GUI.Label(new Rect(Screen.width - 110, Screen.height - 35, 200, 80), "" + grenadeCount, style1); GUI.Label(new Rect(Screen.width - 200, Screen.height - 65, 200, 80), "Throwing Power : "); GUI.Label(new Rect(Screen.width - 70, Screen.height - 65, 200, 80), "" + thePower.ToString("F0") + "%", style1); if (crosshair != null) { float w = crosshair.width / 2; float h = crosshair.height / 2; Rect position = new Rect((Screen.width - w) / 2, (Screen.height - h) / 2, w, h); GUI.DrawTexture(position, crosshair); } } IEnumerator ThrowGrenade(float power) { if (throwingGrenade || grenadeCount <= 0) yield break; throwingGrenade = true; weaponAnim.GetComponent<Animation>()[grenadeThrow].speed = weaponAnim.GetComponent<Animation>()[grenadeThrow].clip.length / 0.4f; weaponAnim.GetComponent<Animation>().Play(grenadeThrow); yield return new WaitForSeconds(0.2f); grenadeRenderer.enabled = false; Rigidbody instantGrenade = Instantiate(grenade, spawnPos.position, spawnPos.rotation) as Rigidbody; Vector3 fwd = spawnPos.forward; instantGrenade.AddForce(fwd * power * throwForce); //Physics.IgnoreCollision(instantGrenade.collider, transform.root.collider); //Physics.IgnoreCollision(instantGrenade.collider, gameObject.FindWithTag("Player").transform.root.collider); grenadeCount--; yield return new WaitForSeconds(1.0f); grenadeRenderer.enabled = true; throwingGrenade = false; StartCoroutine(DrawWeapon()); } public IEnumerator DrawWeapon() { thePower = 0; grenadeRenderer.enabled = true; increasing = false; //draw = true; if (grenadeCount > 0) { GetComponent<AudioSource>().clip = soundDraw; GetComponent<AudioSource>().Play(); weaponAnim.GetComponent<Animation>()[DrawAnimation].speed = weaponAnim.GetComponent<Animation>()[DrawAnimation].clip.length / 0.9f; weaponAnim.GetComponent<Animation>().Play(DrawAnimation); yield return new WaitForSeconds(0.6f); } selected = true; } public void Deselect() { selected = false; } } any hint about that?
  10. fpsarmedunity

    Unity Bundle

    ufps ultimate inventory pro and flow canvas for 1 dollars... purchased...
  11. fpsarmedunity

    fps kit 1.6 unequip animation not play

    nope i think it's a design choise and fpskit doesnt play unequip anim but switch instantly..afaik btw is there a ways we can add this functionality?? itried to add a coroutine and adding hide anims in to WeaponsScritpNew.cs but doesnt work with tihs errro message on test game after i pickup and deseslect wepaon(fireaxe) Coroutine couldn't be started because the the game object 'FireAxe' is inactive! private void PlayAnimationName(string AnimationName, float AnimationSpeed) { weaponAnim[AnimationName].speed = AnimationSpeed; weaponAnim.Rewind(AnimationName); weaponAnim.Play(AnimationName, PlayMode.StopAll); } public void Deselect() { //selected = false; //bursting = false; //aiming = true; canvas.crossAlpha.alpha = 0f; //if (aimMode == Aim.Sniper) scopeTexture.color = new Color(1, 1, 1, 0f); //mainCamera.fieldOfView = camFOV; //transform.localPosition = hipPosition; //if (rocket != null && wepManager.allAmmunition[ammunitionTypeLauncher].amountOfAmmo > 0) //{ // rocket.enabled = true; //} StartCoroutine(DeselectEvent()); } IEnumerator DeselectEvent() { if (!selected) yield break; selected = false; mainCamera.fieldOfView = camFOV; //transform.GetChild(0).localPosition = hipPosition; transform.localPosition = hipPosition; if (rocket != null && wepManager.allAmmunition[ammunitionTypeLauncher].amountOfAmmo > 0) { rocket.enabled = true; } if (weaponAnim.gameObject.activeSelf) { PlayAnimationName(hideAnim, hideAnimSpeed); } yield return new WaitUntil(() => !weaponAnim.isPlaying); weaponAnim.gameObject.SetActive(false); }
  12. fpsarmedunity

    fps kit 1.6 unequip animation not play

    Hi i'm trying to add osme custon wpeaon to my fps kit template but i noticed a weird thing that happen even with stock weapons.. basically even if i set a correct animation on the "Switch" field on the WeaponScriptNew.cs inside the inspector the animation is not played when weapon is unequipped and weapon simply disapper form scene and equip animation for the new selected weapon is correcly played......and i noticed that this happen even for stock weapons but i didtnt notice this before... is this the behaviour kit has to work for or i missed something?
  13. fpsarmedunity

    stop image effect to play after a certain time

    nevermind solved with a coroutine on fpscontroller scritp btw could i do if i would to add a fade/dissolve attribute to this shader?
  14. Hi I purchased Camera filers pack form ssset store https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/camera-filter-pack-18433 is a set of filter that can be used like image effects the use is very simpe.. place the image effect scirpt on camera ad after call it form scirpt... I fugured how to set the waterdrop effect when player exit form underwater easily but my problem is that effect continue obviusly to play since it not has a timer to stop it so i would to know a simple way to can stop script form play after a ceratin time to stop waterdrop effect ..and a solution that can be used in a generic way to set a time for effect to be played-- do you think is there a simple way to acheive that? here the scirpt waterdrop scrotp as sample using UnityEngine; using System.Collections; [ExecuteInEditMode] [AddComponentMenu ("Camera Filter Pack/AAA/WaterDrop")] public class CameraFilterPack_AAA_WaterDrop : MonoBehaviour { #region Variables public Shader SCShader; private float TimeX = 1.0f; [Range(8, 64)] public float Distortion = 8.0f; [Range(0, 7)] public float SizeX = 1.0f; [Range(0, 7)] public float SizeY = 0.5f; [Range(0, 10)] public float Speed = 1f; private Material SCMaterial; private Texture2D Texture2; #endregion #region Properties Material material { get { if(SCMaterial == null) { SCMaterial = new Material(SCShader); SCMaterial.hideFlags = HideFlags.HideAndDontSave; } return SCMaterial; } } #endregion void Start () { Texture2 = Resources.Load ("CameraFilterPack_WaterDrop") as Texture2D; SCShader = Shader.Find("CameraFilterPack/AAA_WaterDrop"); if(!SystemInfo.supportsImageEffects) { enabled = false; return; } } void OnRenderImage (RenderTexture sourceTexture, RenderTexture destTexture) { if(SCShader != null) { TimeX+=Time.deltaTime; if (TimeX>100) TimeX=0; material.SetFloat("_TimeX", TimeX); material.SetFloat("_Distortion", Distortion); material.SetFloat("_SizeX", SizeX); material.SetFloat("_SizeY", SizeY); material.SetFloat("_Speed", Speed); material.SetTexture("_MainTex2", Texture2); Graphics.Blit(sourceTexture, destTexture, material); } else { Graphics.Blit(sourceTexture, destTexture); } } void Update () { #if UNITY_EDITOR if (Application.isPlaying!=true) { SCShader = Shader.Find("CameraFilterPack/AAA_WaterDrop"); Texture2 = Resources.Load ("CameraFilterPack_WaterDrop") as Texture2D; } #endif } void OnDisable () { if(SCMaterial) { DestroyImmediate(SCMaterial); } } }
  15. fpsarmedunity

    fpskit 1.6 referring to player clone

    many thanks to all of you for your time and effort..and even criticism LOL thanks to you i managed to figure how to correcly work with player spawn and even with classic player in hierarchy... lilltle steps ahead.. and new learned sftuffs.. LOL
×