Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by OOGABALLOOGA · Apr 28, 2018 at 09:14 PM · not showingmuzzleflashfire rate

Muzzle flash not showing up at high fire rates

I downloaded War FX (https://assetstore.unity.com/packages/vfx/particles/war-fx-5669) for the muzzle flashes and I followed Brackeys tutorial on unity shooting, but when I raise my fire rate over 10 and hold down fire, the muzzle flash only appears when I let go of the button. Here's the code if any one think they might know the problem.

 using UnityEngine;
 
 public class GunScript : MonoBehaviour {
 
     //Gun basics
     public float damage = 10f;
     public float range = 100f;
     public float fireRate = 15f;
     private float nextTimeToFire = 0f;
 
     //FPS camera
     public Camera fpsCam;
 
     //Gun effects
     public ParticleSystem muzzleFlash;
     public GameObject impactSand;
     public float impactForce = 30f;
 
     // Update is called once per frame
     void Update ()
     {
         if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire)
         {
             nextTimeToFire = Time.time + 1f / fireRate;
             Shoot();
         }
     }
 
     void Shoot()
     {
         muzzleFlash.Play();
         RaycastHit hit;
         if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
         {
             Debug.Log(hit.transform.name);
 
             Enemy enemy = hit.transform.GetComponent<Enemy>();
             if (enemy != null)
             {
                 enemy.TakeDamage(damage);
             }
 
             if (hit.rigidbody != null)
             {
                 hit.rigidbody.AddForce(-hit.normal * impactForce);
             }  
 
             GameObject ImpactGO = Instantiate(impactSand, hit.point, Quaternion.LookRotation(hit.normal));
             Destroy(ImpactGO, 1f);
         }
     }
 }


Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by TrippyVision · Jul 07, 2020 at 09:32 AM

@OOGABALLOOGA sorry for the very late reply and i think you got the answer but in case you dont or any body who comes here for the answer go to your muzzle flash effect and scroll down to where it says culling mode and switch it from pause and catch up to automatic and i hope i help someone,@OOGABALLOOGA Hi its great to see a fellow from brackeys tutorial, i had the same problem but i found the solution got o your muzzle flash particle effect scroll down to where it says Culling mode and switch from pause and catch up to automatic and i hope i helped you

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by JohnnyBoyle2 · Feb 15 at 05:54 PM

The solution that I found was turning the fire rate to 10 or below, for some reason when its higher the muzzle flash doesn't show up. (Also make sure to do this in Unity and not in the code as "fireRate" is a public variable),The solution that I found was turning the fire rate to 10 or below, for some reason when it's higher the muzzle flash doesn't show up. (Also make sure to do this in Unity and not in the code as "fireRate" is a public variable)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by andrew-lukasik · Feb 15 at 06:49 PM


Replace that muzzleFlash.Play(); with:

 if( !muzzleFlash.isPlaying || muzzleFlash.time>(1f/muzzleFlash.emission.rateOverTime.constant) )
 {
     muzzleFlash.Play();
 }


Calling muzzleFlash.Play(); every frame is equivalent to calling animation.Play() or sound.Play() every frame and the results are always the same: seeing first animation frame only, hearing the first music note only (often a total silence) or seeing only the first ParticleSystem animation frame - which is often nothing at all.


Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

138 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Raycast Decals,Sound and MuzzleFlash not working too well 0 Answers

How to set a firerate on this? 2 Answers

App is not showing on Xcode simulator 1 Answer

muzzle flash and particle emit didn't show when shot 1 Answer

Disabling Simulate in WorldSpace in Ellipsoid Particle Emitter not working! 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges