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 asdf123 · Mar 17, 2013 at 05:21 PM · c#gunshootsmokederp

smoke in front of gun when shoot :(

Hi, someone can tell me how i put a smoke in front of the gun when i shoot

 if(Input.GetButton("Fire1"))
 
 {
 
 Script here please
 
 }


In C# please but if you dont know in C#, create in JS :C

Comment
Add comment · Show 7
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 Benproductions1 · Mar 19, 2013 at 12:11 AM 2
Share

If the question has been answered, please accept it!

avatar image sparkzbarca · Mar 19, 2013 at 08:06 AM 3
Share

im amazed by the unity communities willingness to program for people who make no attempt to learn program$$anonymous$$g. :P

avatar image Chronos-L · Mar 19, 2013 at 08:34 AM 2
Share

@$$anonymous$$roductions1, the OP never marks any answers to his questions correct.

@sparkzbarca, I wish I can vote more than once.

avatar image AlucardJay · Mar 19, 2013 at 01:05 PM 1
Share

HEY @asdf123 , how about you learn how to use Unity Answers, and give some credit to those that give their own time for no pay just to help you.

WATCH : http://video.unity3d.com/video/7720450/tutorials-using-unity-answers

Support the 'site that has been supporting you, and give credit where credit is due.

avatar image sdgd · Mar 21, 2013 at 06:28 AM 0
Share

O$$anonymous$$G I've never saw so much support to answerers

what can I say I feel bad helping for not even thanks

so usually I try asking when I really don't know how to move forward in program$$anonymous$$g that happens very rarely

and I very much upvote any answer I see that's correct

this kind of community support gives me some morale to answer some Q even if I could use that time for my own program$$anonymous$$g

Show more comments

2 Replies

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

Answer by fjalla · Mar 17, 2013 at 06:42 PM

By the way Javascript version of it is:

 var smoke : GameObject;
 var endOfGun : Transform;

 function Update () {
     if(Input.GetButton("Fire1")) {
          Instantiate(smoke, 
          endOfGun.transform.position,
          endOfGun.transform.rotation)
     }
 }



But you probably need the smoke to dissapear after a time so put this on it:

 function Start () {
 yield WaitForSeconds(5); //waits for 5 seconds
 Destroy(gameObject) //then destroys the smoke
 }
Comment
Add comment · Show 4 · 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 asdf123 · Mar 18, 2013 at 11:38 PM 0
Share

when i start the game, after 1 second the camera disables and the game stop running :/

avatar image fafase · Mar 19, 2013 at 08:01 AM 1
Share

The second part is wrong, you should use:

 function Start(){
    Destroy(gameObject,5.0f);
 }

or even better the particle asset from Unity has a script to attached to particle system to destroy them automatically on completion.

avatar image asdf123 · Mar 19, 2013 at 10:51 AM 0
Share

when the smoke destroys the camera and the game stop running :/

avatar image fjalla · Mar 19, 2013 at 12:54 PM 0
Share

did you put the script on the smoke prefab?

avatar image
12

Answer by fafase · Mar 17, 2013 at 05:29 PM

  1. Add an empty game object at the end of your gun

  2. Attach the object to the gun

  3. Create a script

  4. Scratch your head

  5. Open up the script

  6. Add the code below

      public GameObject particle;
         public Transform endOfGun;
         void Update(){
             if(Input.GetButton("Fire1"))  
             {
                 Instantiate(particle, endOfgun.position,Quaternion.identity);
             }
         }
    
    
    
    
  7. This is it

  8. Try the game

  9. List item

  10. You are getting Null reference exceptions

  11. Get Back on the forum

  12. Post I get a NullReference Please fix my code

  13. Then someone answers "Have you dragged and drop the prefab and the object in the Inpsector"

  14. You answer "No"

  15. You do it

  16. It works perfectly

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 Loius · Mar 17, 2013 at 06:05 PM 0
Share

can... only... upvote... once... aaaaargh

To expand a little on this answer, you can probably just use a flat plane with a smoke picture on it as your smoke prefab, but you could also use Unity's particles. Before you ask how to do these, do a thorough search, because they have both been asked to death.

avatar image Creator347 · Mar 21, 2013 at 06:33 AM 0
Share

Scratching my head!!!

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

19 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

Related Questions

Gun and hand animation tutorial! 2 Answers

Shooting. Bullet floats and sprays 1 Answer

Problems with a shooting script 1 Answer

Shooting & Animation Problem 1 Answer

How let my machinegun(like the deathmachine in cod black ops) to shoot a projectile one after the other?? 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