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 Kazaskater · Dec 01, 2010 at 02:56 AM · javascriptraycastgunparticleshoot

How do I make a gun?

Okay, so I am making a first person shooter in Unity, and I am working on the gun. I have the gun set, I have a muzzle flash, and I have the sound effects and the reloading and stuff like that. Now all I need to do is make it project a particle effect directly in the center of the screen, where the crosshair is. I made a function called particle, and when I shoot, I call that function. I have no clue what to put in there though. I have been looking forever, but I am completely clueless. I have even tried the machinegun.js in the first person shooter tutorial, but still, nothing. Any help would be greatly appreciated.

Comment
Add comment · Show 1
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 Anton Petrov · Dec 01, 2010 at 08:24 AM 0
Share

What is this particle effect? Is it a hit effect or a fire flash? You should create a prefab with your particle effect. The just instantiate this prefab when you shoot where you want :)))

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Rennat · Dec 01, 2010 at 06:09 PM

If you're wanting to simulate a tracer round's light streak I would use a LineRenderer from the tip of the gun to the point where you will hit. Create it then destroy it a frame later.


If you want impact/ricochet sparks, create a prefab with a particle emitter, make it one shot and autodestruct. Then instantiate it at the impact point.


You can get the point where you will hit by using Physics.Raycast with Camera.ScreenPointToRay

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 Scott 7 · Mar 14, 2011 at 02:50 PM 1
Share

actually if the gun has a particle emmiter (with emit disabled so it doesn't emit at unwanted times) you can use particleEmitter.Emit() see the scripting documentation on particleEmitter. You can Emit using the settings on the emitter or you can set the position, velocity etc.

avatar image Rennat · Aug 12, 2011 at 07:20 PM 0
Share

nice solution @Scott7

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

1 Person is following this question.

avatar image

Related Questions

How do I make a gun project a particle? 1 Answer

How can I decrease accuracy when the gun is fired? 2 Answers

How to add a delay to my script. 3 Answers

Bullets will not fire forwards 1 Answer

musket gun script is not working 3 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