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 Zitoox · Jul 23, 2016 at 12:34 AM · createhow tomuzzleflash

How to make a muzzle flash

I already use bullets in my game, but i am seriously thinking that i need to change it to muzzle flash, because my actual system requires a high powerfull hardware and do a big size change to my FPS.

Is there a tutorial or something to make a muzzle flash particle? Everything i tried until now failed and i want something real.

Comment
Add comment · Show 3
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 Zitoox · Jul 23, 2016 at 03:46 PM 0
Share

TESTING UP

avatar image AlucardJay · Jul 23, 2016 at 05:19 PM 0
Share

Everything i tried until now failed and i want something real. : can you give examples of what you have tried? What was the expected result, and what was the actual result?

avatar image Zitoox AlucardJay · Jul 23, 2016 at 05:31 PM 0
Share

I want to do a muzzle flash. When you use fire 1 (left mouse button), a bullet (a different one that i already made and it's better than the older version) spawns AND a muzzle flash, like a particle.

Basically, when you shoot, a "fire" particle appears for one second and then disappears, but i want to do one that doesn't bug if you shoot many times in a short period of time.

I tried using just cubes with images, but it doesn't work as expected, and i only found one single muzzle flash particle in ALL the internet, and it's buggy and heavy.

I am trying to make something that make the player feel that he is shooting a REAL weapon. Something nice.

The results i had until now were: - Black background muzzle flash EVEN using transparency,shaders and marked options. - Bugged particles. - Errors during spawn. - $$anonymous$$uzzle flash hiding the bullet as it spawns - Conflict between the two.

3 Replies

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

Answer by Cherno · Jul 23, 2016 at 05:49 PM

First of all, I don't recommend using particles for a muzzle flash effect. The reason is that particles are only shown from one angle, and muzzle flashes in real life typically don't look like a ball of fire but rather like a longish flame spurting out of the barrel, plus additional flashes depending on the muzle break or flash hider on the gun. Most games use a combination of planes with alpha-masked textures on them, it's what I used for my sentry gun:

alt text

Just two planes perpendicular to each other with a long flash, and another one at flat against their "base" witha round flash one for where the bullet leaves the barrel.

For the issue of rapid fire, see this thread:

(Rapid fire) How to accurately wait for a very short amount of time?

Comment
Add comment · Show 2 · 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 Zitoox · Jul 23, 2016 at 09:05 PM 0
Share

Thanks! ^.^ i am almost finishing it, and i know it will work. Could you make this an answer? So i can accept it.

avatar image AlucardJay · Jul 30, 2016 at 11:22 AM 0
Share

Upvoted. The only reason I added an answer is because the OP posted again : http://answers.unity3d.com/questions/1222973/how-to-spawn-a-muzzleflash.html

avatar image
3

Answer by AlucardJay · Jul 30, 2016 at 11:22 AM

The Angry Bots demo has a perfect example of using a pyramid mesh with a 'muzzle flash' texture, and a script to rotate the mesh while the gun is being fired.

From the Angry Bots demo :

alt text

The 'muzzle flash' mesh is a child of the gun, positioned at the end of the barrel. Also note the rotation, as this will determine what axis the mesh is rotated on in the script.

Now there is a script called MuzzleFlashAnimate.js. Quite simply :

 #pragma strict
 
 function Update () {
     transform.localScale = Vector3.one * Random.Range(0.5,1.5);
     transform.localEulerAngles.z = Random.Range(0,90.0);
 }

Per frame (Update), this randomly : scales the object; rotates the object on the Z axis.

Now in the firing script AutoFire.js, this can be heavily abbreviated to just :

 var muzzleFlashFront : GameObject;
 
 function Start()
 {
     muzzleFlashFront.SetActive (false);
 }
 
 function Update ()
 {
     if(Input.GetButtonDown("SHOOT"))
     {
         muzzleFlashFront.SetActive (true);
     }
 
     if(Input.GetButtonUp("SHOOT"))
     {
         muzzleFlashFront.SetActive (false);
     }
 }

If the shoot button is pressed, enable the muzzleflash gameobject. If the shoot button is released, disable the muzzleflash gameobject.

When the muzzleflash object is enabled, the script MuzzleFlashAnimate starts working, and the muzzleflash effect is rotated and scaled, creating the illusion of a muzzleflash.

This is the simplest way of achieving the effect. But very effective, as stated in the original answer by Cherno (you could expand on this basic method as described by Cherno).


angrybots-muzzleflash.jpg (422.4 kB)
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
1

Answer by $$anonymous$$ · Jul 23, 2016 at 07:55 PM

Gabemeister1201 explains on how to do it, it's quite simple: https://www.youtube.com/watch?v=XGG0VwMieGc watch from 0:00 to 7:25.

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

52 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

Related Questions

How to make Low Poly Terrain (free) 1 Answer

Can't create a new shader 1 Answer

How to create a login system online? 1 Answer

Basic Scripting help 2 Answers

character creation 2 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