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 Daniele · Dec 02, 2010 at 10:00 AM · fpsshootingfirst-person-controllerspacemuzzleflash

Make that muzzle flash? How?

Hello :}

Okay so I'm attempting to create a FPS game set within space. At a stage where code needs to be implemented. Trying to figure out how to make a muzzle flash? I've made a plane so far and don't know what is additional required in terms of code?

Help anyone?

Thanks :}

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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Tommynator · Dec 02, 2010 at 11:27 AM

You can create muzzle flashes easily by using textured planes in front of the camera. Alternatively you can use animated meshes, or particle effects. No matter which effect you will choose, you can show the effect by using a simple script that is sitting on the muzzle gameobject like:

public class MuzzleFlash : MonoBehaviour { private float _muzzleFlashEnd = 0;

 public void Show(float time)
 {
     //enable renderer/animations
     gameObject.SetActiveRecursively(true);

     //add some variations
     transform.localRotation = Quaternion.Euler(0, 0, Random.Range(0, 360));

    //set a duration for the effect
     _muzzleFlashEnd = Time.time + duration;
 }

 private void Update()
 {
     if (_muzzleFlashEnd < Time.time)
     {
         gameObject.SetActiveRecursively(false);
     }
 }

}

Now activate the effect by something like

if(input.GetMouseButtonDown(0))
{
   _myMuzzleFlash.Show(0.1f);
}

The gameobject will activate and deactivate itself when the effect is over. That way it will not consume any resources when not in use.

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 Daniele · Dec 02, 2010 at 11:47 AM 1
Share

Its says reference script on this behaviour is missing? Did I do something wrong ;/ I created the gameObject and linked with new script...

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

No one has followed this question yet.

Related Questions

Crosshair? How? 6 Answers

Space Skybox implementation 5 Answers

click shooting how do i do it? 1 Answer

Make an enemy only rotate with navmesh agent 1 Answer

Shooting only once, returning boolean as false 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