Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Cherno · Dec 10, 2013 at 02:51 AM · muzzleflash

Muzzle flash not reliable for rapid-fire weapons

I want to add a muzzle flash to my firing submachinegun, it shoots at about 12 rounds per second as a real-life SMG would. Now, at this rate, most of the time the flash isn't created/shown, only if the timescale is lowered to slow-motion will every shot show a muzzle flash. It doesn't matter how I create the muzzleflash, I have tried the following methods and they were all unreliable:

  1. Instatiating a particle system prefab at game start, disabling the emitter, and only enabling it for a short period (0.1 seconds) every shot

  2. Instantiating a particle system prefab for every shot, and destroying it again after 0.1 seconds.

Is there any way to make muzzle flashes for rapid-fire weapons more reliable?

Comment
Add comment · Show 2
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 Commander Quackers · Dec 10, 2013 at 03:15 AM 0
Share

I use a 2d texture on a plane in front of my guns, and it just renders when I am shooting, did you try this?

edit: I also made a spinning animation so it doesn't have the "same" flash every time, the flash is rotated with a particle/additive shader

avatar image Cherno · Dec 10, 2013 at 05:12 AM 0
Share

I'm thinking about doing it with a plane, but what counts is wether it works reliably with a high rate of fire.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Cherno · Jan 31, 2014 at 11:40 PM

I got a reliable solution working, here it is:

 var Muzzle : GameObject;
 var MuzzleFlashPrefab : GameObject;
 var MuzzleFlashClone : GameObject;
 var MuzzleFlashList : List.<GameObject>;

 function DrawMuzzleFlash()
 {
     MuzzleFlashClone = Instantiate(MuzzleFlashPrefab, Muzzle.transform.position, Muzzle.transform.rotation);
     MuzzleFlashList.Add(MuzzleFlashClone);
     MuzzleFlashClone.transform.localScale = Vector3(Random.Range(3.0, 4.0), Random.Range(3.0, 4.0), Random.Range(3.0, 4.0));
     yield WaitForSeconds(0.2);
     Destroy (MuzzleFlashList[0]);
     MuzzleFlashList.RemoveAt(0);
 }
Comment
Add comment · Show 3 · 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 Luizr · Sep 29, 2014 at 05:23 PM 0
Share

Iz that c#

avatar image robertbu · Sep 29, 2014 at 05:24 PM 0
Share

@Luizr - No, it is Javascript/Unityscript.

avatar image Cherno · Sep 29, 2014 at 09:34 PM 1
Share

Oh my, necro much, Luizr? ;)

This was the very first project I ever worked on, I switched to C# after my second one because of the much better documentation and support available, and because C# has a broader application field (that's how I see it in general, after all).

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

18 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

Related Questions

Instantiating Muzzle Flash 1 Answer

How do i put lights with muzzleflash? 1 Answer

Muzzleflash Question 3 Answers

Why the particle system don't play? 2 Answers

How to make and use a muzzleflash 1 Answer


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