• 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
Question by SpeckledGecko · Sep 07, 2020 at 07:47 PM · scripting problemcollisionparticlesparticlesystem

Transforming and playing particle effects? Help!

Updated: I changed some of the code around, and this is what it looks like now: This is the code I made to create and play the particle effect the particle effect:

 public class PlayScript : MonoBehaviour
 {
 
     public GameObject delete;
     public GameObject player;
     private Projectile bullet;
     private BulletDeleteSytem2 isDeleted;
     public Rigidbody shrapnel;
     public Transform BulletSpawn;
     
 
     void Start()
     {
         delete = GameObject.Find("Bullet");
         isDeleted = delete.GetComponent<BulletDeleteSytem2>();
         player = GameObject.Find("FirstPersonPlayer");
         bullet = player.GetComponent<Projectile>();
     }
 
     // Update is called once per frame
     void Update()
     {
         if (bullet.BullEx)
         {
             Rigidbody clone;
             clone = Instantiate(shrapnel, BulletSpawn.position, shrapnel.rotation);
             Debug.Log("HasCreated");
             bullet.BullEx = false;
             Debug.Log("Works");
         }
 
         if (isDeleted.BullColl)
         {
             gameObject.GetComponent<ParticleSystem>().Play();
             Debug.Log("HasPlayed");
 
         }
         transform.localPosition = BulletSpawn.position; 
     }
 }

And this is the script that changes the variables in "playscript1"

 public class BulletDeleteSytem2 : MonoBehaviour
 {
     Rigidbody rb;
    
     public bool BullColl = false;
     void Start()
     {
         rb = GetComponent<Rigidbody>();
     }
 
 
 
     void OnCollisionEnter(Collision collision)
     {
 
         
         BullColl = true;
         Debug.Log(BullColl);
         Destroy(gameObject);
 
     }
     
     
 }



I hope this makes it easier to understand, as before it was a huge mess. Thanks to rh_galaxy for the advice of cleaning this code up

Comment

People who like this

0 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 rh_galaxy · Sep 30, 2020 at 07:30 PM 0
Share

Maybe you run Start() of your BulletDeleteSytem before object "Shrapne1" is created? Set a breakpoint here and see what info it gives you.

 delete = GameObject.Find("Shrapnel");

Also I would advise you to somehow merge your unnamed first script with the PlayScript1-script, since they are identical in function.

1 Reply

  • Sort: 
avatar image

Answer by N-8-D-e-v · Sep 13, 2020 at 07:42 PM

First off, BullColl is never being changed, so that could be your problem. Second, does your gameobject with the script attached have a particle system component attached?

Comment

People who like this

0 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 SpeckledGecko · Sep 14, 2020 at 06:49 PM 0
Share

BullColl is being changed in a separate bullet collision script that I have attached to the post above. That's my bad for not including it in the post and explaining in more detail what I'm doing. When the bullet is shot(The bullet is a separate object), it clones a particle effect with the play script attached in the same position as the bullet(Then its supposed to transform the position of the bullet with the bullet but it just doesn't )

avatar image N-8-D-e-v SpeckledGecko · Sep 28, 2020 at 10:56 PM 0
Share

would you mind recording a video or something? Your code is kind of hard to read and make sense of

avatar image SpeckledGecko N-8-D-e-v · Sep 30, 2020 at 02:53 PM 0
Share

Can I send you images of the project files with relevant things highlighted?

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

143 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 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

Finding Particle Information Upon Collision 2 Answers

Particle collision problem 0 Answers

Particle collisions without physics force 1 Answer

Detect when 2 particle systems collide with each other? 0 Answers

Particles colliding/triggering Particles. Is it possible? 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