Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by AshwinTheGammer · Sep 21, 2017 at 04:40 AM · fpsparticlesparticle systemparticle emittergrenade

How to make Particle System on when I throw grenades on ground after 5 second.

Tell me how to activate explosion particle on and sound for 5 second when I throw grenade. Please tell me. Thanks in Advance !

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 tmalhassan · Sep 23, 2017 at 08:23 AM 0
Share

so you want the grenade to explode when it touches the ground? or after its thrown and left the hand of the player? or once the player takes the grenade out (in this case it will explode in five seconds and that could also kill the player)?

avatar image AshwinTheGammer tmalhassan · Sep 23, 2017 at 12:11 PM 0
Share

no when the grenade hit the ground then a audio will play and after 5 seconds it will explode with particle system and with a explosion audio. Give me script please if you know.

avatar image tmalhassan AshwinTheGammer · Sep 23, 2017 at 12:13 PM 0
Share

Do you have a code that i can take a look at? or should i just write a script from what i understand?

Show more comments

3 Replies

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

Answer by tmalhassan · Sep 23, 2017 at 02:00 PM

From what i understand, you have a grenade that has a particle system attached to it. You want the particle system and the audio to start after 5 seconds from when it hits the ground. A good way to do this is through collision detection with the ground. Once it collided, you will start a Coroutine() and tell it to play the audio and the particle system after 5 seconds. This is what you will need:

  • A grenade with a Rigidbody to give it the natural physics. And a collider to detect collision with the ground. (The ground must have a collider as well).

  • A particle system that is a child of the genade (the parent). And an Audio Source element and add the explosion sound to it.

  • Create a tag for the ground with the name "Ground"

  • Create a script and attach it to the grenade.

This is how the script should look like:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class GrenadeScript : MonoBehaviour {
 
     public ParticleSystem explosionParticle;
 
     private AudioSource explosionSound;
     private int explosionEnabler = 0;
 
     private void Start()
     {
         explosionSound = gameObject.GetComponent<AudioSource>();
     }
 
     private void OnCollisionEnter(Collision coll)
     {
         if (explosionEnabler == 0)
         {
             if (coll.gameObject.CompareTag("Ground"))
             {
                 explosionEnabler = 1;
                 StartCoroutine(Explosion());
             }
         }
     }
 
     IEnumerator Explosion()
     {
         yield return new WaitForSeconds(5f);

         explosionParticle.gameObject.SetActive(true);
         explosionSound.Play();
     }
 }

This should do the trick.

I attached an image so you can follow the setup exactly

All the best in making you game :)

alt text


screenshot-73.png (211.1 kB)
Comment
Add comment · Show 3 · 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 AshwinTheGammer · Sep 24, 2017 at 12:14 AM 0
Share

But how my player throw grenade ? my player need force to throw grenade, I have already tell you that I don`t have any script. And yes it throw grenade only when I press F after pressing F then my player automatically take his gun and start fiiring. Please do something more for me. This last question please, Please! I have to accept your correct answer.

avatar image tmalhassan AshwinTheGammer · Sep 24, 2017 at 06:34 AM 0
Share

Tell me how to activate explosion particle on and sound for 5 second when I throw grenade. Please tell me. Thanks in Advance !

Your question doesn't mention anything about instantiating the grenade. It only talks about playing the particle system and the audio after 5 seconds from hitting the ground. So as far as i'm concerned, this question is answered. You can post another question and explain what you want in details.

avatar image AshwinTheGammer tmalhassan · Sep 24, 2017 at 09:55 AM 0
Share

okay thanks bro !

avatar image
1

Answer by ifurkend · Sep 21, 2017 at 04:48 AM

Just add start delay (in second) in the particle system main module. As for the sound, you need to add another game object with AudioSource component, and then write a script to delay the activation of the gameobject or its audio component in coroutine.

Comment
Add comment · Show 3 · 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 AshwinTheGammer · Sep 21, 2017 at 11:11 AM 0
Share

Would you give me codes because I noob to unity3d please. I know you have lot of time please. Using coroutine is very diffcult for me. Please plzzzzzzzzz

avatar image ifurkend AshwinTheGammer · Sep 21, 2017 at 02:32 PM 0
Share

If you are a one-man band and want to make your own game with Unity, learning C# scripting is inescapable, you should begin watching Unity scripting tutorial right now. One thing I did mistake is that AudioSource.Play or PlayScheduled provide properties for delay, removing the trouble to write a coroutine, even though I suspect it's a wrapper of coroutine.

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(AudioSource))]
 public class audioDelay : $$anonymous$$onoBehaviour
 {
     public double delay = 5.0;
     void OnEnable()
     {
         AudioSource audio = GetComponent<AudioSource>();
         audio.PlayScheduled(delay);
     }
 }


avatar image AshwinTheGammer ifurkend · Sep 22, 2017 at 12:45 PM -1
Share

Bro give me particle script when I throw grenade then after 5 second the the particles become activated. Sorry ! your answers in not accepted if you give me this script I definitely accept your answer.

avatar image
1

Answer by kskjadav007 · Sep 21, 2017 at 05:17 AM

check collision if it's ground then start coroutine or use time like this

if (// grounded) { Lifetime -=Time.deltaTime }

put lifetime =5

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 AshwinTheGammer · Sep 21, 2017 at 10:51 AM 0
Share

Would you explain it more detaily.

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

100 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

How can you create non circular rocket flame particle effect? 0 Answers

Particles not showing 0 Answers

Particle system does not follow emitter movement in world space: URP 1 Answer

Problem with Particles and Particle System 1 Answer

Some question about ParticleSystem.emit() rendering 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