Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Nikola310 · Dec 21, 2015 at 04:25 PM · particlesscripting beginnerparticlesystem

Particles that follow the Player

I'm making an explosion particle effect, and it's a child of my Player object in the hierarchy. My game is advanced Roll A Ball, and i want the explosion to play when the player falls off a platform. I want the explosion to play, and then the scene to restart (I know how to restart the scene). The particle system should "follow" the player so if he falls off at any point the explosion will play where the player falls. Here's my script:

using UnityEngine; using System.Collections; using UnityEngine.SceneManagement;

public class DeathFall : MonoBehaviour {

 void Start()
 {
 }

 void Update()
 {
     if(gameObject.transform.position.y <= -20 && gameObject.transform.position.y >= -60)
     {
         //Play the explosion here
     }

     if(gameObject.transform.position.y <= -60)
     {
         SceneManager.LoadScene(Application.loadedLevel);
         //This restarts the game
     }
 }

}

Yes, the DeathFall script is attached to the Player. Thank you in advance.

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 NoseKills · Dec 21, 2015 at 11:18 PM 0
Share

Attach the particle system component to the ball ? Possibly set it to use World space in emission settings and Play the particle effect when your condition becomes true (checkwith a boolean when you do this so you only do it once)

avatar image Nikola310 NoseKills · Dec 22, 2015 at 01:41 PM 0
Share

I've tried adding a boolean, but I can't Play it. Here's the script:

 using UnityEngine;
 using System.Collections;
 using UnityEngine.Scene$$anonymous$$anagement;
 
 public class DeathFall : $$anonymous$$onoBehaviour {
 
     public ParticleSystem tpc;
     private bool derp = false;
 
     void Start()
     {
         tpc = gameObject.GetComponent<ParticleSystem> ();
         tpc.emissionRate = 0;
     }
 
     void Update()
     {
         if(gameObject.transform.position.y <= -20 && gameObject.transform.position.y >= -60)
         {
             derp = true;
         }
 
         if(gameObject.transform.position.y <= -60)
         {
             Scene$$anonymous$$anager.LoadScene(Application.loadedLevel);
             //This restarts the game
         }
         if(derp = true)
         {
             tpc.emissionRate = 1;
             //THIS DOESN'T WOR$$anonymous$$!
         }
     }
 }
 

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Script not playing Particle Effect 0 Answers

How do you make a particle effect play on a key press? 0 Answers

How do I set the statColor of a particle system through script 2 Answers

Problem with particle effects and detonating bombs 0 Answers

Particle system only playing when visible 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