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 Zaliyphis · Oct 25, 2013 at 06:02 AM · addingfirst person shooter

How to add particle effects to a FPS

I am in a entry level video game design class, and one of our assingments is creating a simple first person shooter game. While its not required, I want to add some particle effects to it. The sparks effect on the gun barrel for every time a shot is fired and the small explosion effect for targets that are hit. My instructor will only give me crude hints as how to do this (since the next course is supposed to cover scripting more) and I have not been able to find a clear refference here on the Unity website.

How would I script these?

This is the javascript I am using so far for the shots fired and target destroy.

function Start () {

} var projectile : Rigidbody; var speed : float = 75; var fire : AudioClip;

function Update () { if(Input.GetButtonDown("Fire1")){ var instantiatedProjectile : Rigidbody = Instantiate(projectile, transform.position + Vector3(0,-0,0), transform.rotation); instantiatedProjectile.velocity = transform.TransformDirection(Vector3(0,0,speed)); Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);

audio.PlayOneShot(fire); } }

function Start () {

} var hitTarget : AudioClip;

function OnTriggerEnter (other : Collider) { AudioSource.PlayClipAtPoint (hitTarget, Camera.main.transform.position); Destroy(gameObject); Destroy(other.gameObject);

TargetsRemaining.intTargetsRemaining--; }

Thanks in advance. Also, what is a good source for learning how to script in unity?

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 yogee · Oct 25, 2013 at 06:22 AM 0
Share

not clear bro

avatar image EvilWarren · Oct 25, 2013 at 09:26 AM 0
Share

Could you format the code in your post? Also this "next course" sounds suspiciously like the course I will $$anonymous$$ch since I am following up on a design course... I'm wondering if you are based in Scotland...

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Crystalline · Oct 25, 2013 at 09:21 AM

For particles use the 'particle emission' component.

And make sure you use 'Code Sample' to post your code, otherwise it looks awful (your posted code is impossible to read).

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 Zaliyphis · Oct 28, 2013 at 05:45 AM 0
Share

I accidently added the script code format as an answer, it appears to have disapeared. So here it is again for those who want to see it. function Start () {

 }
 var projectile : Rigidbody;
 var speed : float = 75;
 var fire : AudioClip;
 
 function Update () {
    if(AmmoRemaining.intAmmoRemaining > 0){
    if(Input.GetButtonDown("Fire1")){
    var instantiatedProjectile : Rigidbody = Instantiate(projectile, transform.position +
 Vector3(0,-0,0), transform.rotation);
    instantiatedProjectile.velocity = transform.TransformDirection(Vector3(0,0,speed));
    Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);
    
    AmmoRemaining.intAmmoRemaining--;
    
    audio.PlayOneShot(fire);
    }
   }
 }

The destroy code, which is also applied to the projectile prefab while the target itself is the trigger. function Start () {

 }
 var hitTarget : AudioClip;
 
 function OnTriggerEnter (other : Collider) {
    AudioSource.PlayClipAtPoint (hitTarget, Camera.main.transform.position);
    Destroy(gameObject);
    Destroy(other.gameObject);
    
    TargetsRemaining.intTargetsRemaining--;
 }

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

18 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

Related Questions

trouble adding script to clone object 1 Answer

Add Fresh Script to Game Object 1 Answer

FPS Tutorial Part 3 Help needed 0 Answers

Adding a box collider to an object in csharp script 3 Answers

Add an animation clip with AnimationClip using cSharp script 1 Answer


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