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.

ExoticalX7

Member
  • Content count

    33
  • Joined

  • Last visited

Community Reputation

2 Neutral

About ExoticalX7

  • Rank
    Member
  • Birthday 01/02/1999

Profile Information

  • Gender
    Male
  • Location:
    United States
  1. Script Freezing unity help!

    ok I fixed it. thanks for the help guys <3
  2. Script Freezing unity help!

    ok ill try
  3. Script Freezing unity help!

    yes i did start unity about a while ago. i know the basics but i dont know why this is happening
  4. Script Freezing unity help!

    I made the script off of brackys and moded it to my gun script
  5. Script Freezing unity help!

    Its a C#
  6. Script Freezing unity help!

    so i have made this script and whenever i use it, it freezes my unity and i cant use unity so i have to restart my computer, help please try the script your self on a gun; its a gun script using UnityEngine; using UnityEngine.UI; using System.Collections; public class Gun2 : MonoBehaviour { [Header("Gun Data")] public float damage = 10f; public float range = 100f; public float impactForce = 30f; public float fireRate = 15f; public float shootTime = 0.1f; public float ShootDelay = 0.01f; public float ShootAnimTime; public float AcuracyReturn; public GameObject Muzzle; public Transform MuzzleReset; [Space] [Header("Ammo & Reloading")] public int AmmoInClip; public int AmmoClips; public int MaxAmmo; public bool OutOfAmmo; [Space] public float reloadTime; [Space] [Header("Scoping")] public float scopedFOV; public float normalFOV; [Space] [Header("Gun Objects")] public Text AmmoText; public GameObject NoAmmoText; [Space] public ParticleSystem muzzleflash; public GameObject impactEffect; [Space] public GameObject Hitmarker; public float HitmarkerTimeOnScreen; [Space] [Header("Animator")] public Animator _Animator; private bool isScoped; [Space] [Header("GunSounds")] public AudioSource _AudioSource; public AudioClip ShootSound; public AudioClip OutOfAmmoShoot; public AudioClip SuppressedFireSound; public AudioClip ReloadSound; [Space] [Header("Other")] public Camera fpsCam; public bool isReloading; void Start() { Muzzle.transform.Rotate(0f, 0f, 0f); _Animator.SetBool("Idle", true); NoAmmoText.SetActive(false); } void OnEnable() { isReloading = false; _Animator.SetBool("Reloading", false); _Animator.SetBool("AimToIdle", true); _Animator.SetBool("Idle", true); } // Update is called once per frame void Update() { AmmoText.text = "Ammo: " + AmmoInClip + " /" + " Clips: " + AmmoClips; if (AmmoClips <= 0) { if (Input.GetKeyDown("r")) { return; } } if (Input.GetKey(KeyCode.W)) { if (Input.GetKey(KeyCode.LeftShift)) { _Animator.SetBool("Running", true); if (Input.GetKeyDown("r")) { return; } if (Input.GetButton("Fire1") && Time.time >= ShootDelay) { return; } if (Input.GetButton("Fire2")) { return; } } } if (Input.GetKeyUp(KeyCode.LeftShift)) { _Animator.SetBool("Running", false); } if (isReloading) { if (Input.GetKey(KeyCode.LeftShift)) { _Animator.SetBool("Running", false); } } if (Input.GetButton("Fire2")) { isScoped = true; _Animator.SetBool("Aiming", true); } if (Input.GetButtonUp("Fire2")) { isScoped = false; fpsCam.fieldOfView = normalFOV; _Animator.SetBool("Aiming", false); } if (AmmoClips <= 0 && AmmoInClip <= 0) { NoAmmo(); return; } if (isReloading) return; if (AmmoInClip <= 0) { StartCoroutine(Reload()); return; } if (Input.GetKeyDown("r")) { StartCoroutine(Reload()); _Animator.SetBool("Aiming", false); return; } if (Input.GetButton("Fire1") && Time.time >= ShootDelay) { ShootDelay = Time.time + 1f / fireRate; StartCoroutine(Shoot()); } } //Reloading Mechanics IEnumerator Reload() { isReloading = true; Debug.Log("Reloading..."); _AudioSource.PlayOneShot(ReloadSound); _Animator.SetBool("Reloading", true); yield return new WaitForSeconds(reloadTime); _Animator.SetBool("Reloading", false); AmmoClips -= 1; AmmoInClip = MaxAmmo; isReloading = false; } //Shooting Mechanics IEnumerator Shoot() { _Animator.SetBool("Shooting", true); muzzleflash.Play(); AmmoInClip--; RaycastHit hit; if (Physics.Raycast(Muzzle.transform.position, Muzzle.transform.forward, out hit, range)) { Debug.Log(hit.transform.name); Target target = hit.transform.GetComponent<Target>(); if (target != null) { target.TakeDamage(damage); Hitmarker.SetActive(true); yield return new WaitForSeconds(HitmarkerTimeOnScreen); Hitmarker.SetActive(false); } if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * impactForce); } GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(impactGO, 1f); } Muzzle.transform.Rotate(0.3f, 0f, 0f); if (Input.GetButton("Fire1")) { StartCoroutine(Shoot()); } else yield return new WaitForSeconds(AcuracyReturn); Muzzle.transform.Rotate(-0.3f, 0f, 0f); } void NoAmmo() { OutOfAmmo = true; NoAmmoText.SetActive(true); } }
  7. this link you used? https://www.assetstore.unity3d.com/en/#!/content/90214
  8. so i guess use the link, tell me f it worked. make sure to play around with it tho
  9. if you are using unity 5.60 then use this https://www.assetstore.unity3d.com/en/#!/content/90214 hopefully it will work
  10. What version of unity are you using
  11. Im going to keep looking around
  12. What standard asstes are you using
×