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 DayyanSisson · Oct 18, 2011 at 05:14 AM · texturetexture2dshootingshootmuzzleflash

Instantiating Muzzle Flash

I want to create a muzzle flash for my gun, and I incorporated it into my shoot script. Here's an excerpt:

 if(Input.GetButton("Fire1") && Time.time > nextFire && bulletsLeft > 0 && !boosting) {
         nextFire = Time.time + fireRate;
         Instantiate (projectile, shootPointOne.position, transform.rotation);
         Instantiate (muzzleFlash, shootPointOne.position, transform.rotation);
         hasFired = true;
     }

It all works except for the muzzleFlash. The muzzleFlash is a Texture2D and this seems the most logical way for making a muzzle flash without animations. Is this the correct way to approach this, or is their a better, more direct way?

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 syclamoth · Oct 18, 2011 at 05:37 AM 0
Share

You need to make it a plane, with the texture on it (with transparency). Then, put some fade out and destroy script on the flash prefab.

avatar image timsk · Oct 18, 2011 at 10:40 AM 0
Share

that seems an awful lot like an answer there syclamoth ;).

1 Reply

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

Answer by Owen-Reynolds · Oct 18, 2011 at 02:20 PM

The easiest way to get a "pulse" of a texture is to put it in a particle emitter (which will automatically give it a life-time then kill it.)

To put in the Texture, you can drag it to the bottom of a particle emitter. You should see the material, in ParticleRenderer, update from the white ball to your texture. If that messes up the colors, click on shader where it says "Particles/AlphaBlended" and pick another one from the Particles folder.

To make it appear then die, click (far above) OneShot and AutoDestruct. Then tweak it so it looks nice (size, life -- see the PE docs.)

Comment
Add comment · Show 1 · 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 DayyanSisson · Oct 19, 2011 at 02:16 AM 0
Share

Alright, looks great, except for the muzzle flash texture, which has nothing to do with your answer, so thanks.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Hey can anyone help with a shooting script??? 0 Answers

How to shoot with swipe? 0 Answers

Muzzle Flash Not Working 0 Answers

Update Texture type to GUI during runtime 0 Answers

Change texture of plane pixel by pixel (Unity 5) 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