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 mteom · Feb 06, 2015 at 08:00 PM · instantiateparticlesprefabs

Particles issues: not moving and ignoring emitter shape

Hello everybody. I am having a strange issues with particles. I created an object, assigned a particle system to it and made a prefab. The problem is that when i try to instantiate it, the particles don't move at all, they get created, change shape/colour properly but they stand still; this if i instantiate through code. If i drag the prefab from the inspector into the scene, everything works fine. I have this code that take care of creating the particle system:

 public class ParticleHelper : MonoBehaviour
 {
     // Singleton
     public static ParticleHelper Instance;
     //
 
     public ParticleSystem HeartEmitter;
     public ParticleSystem CoinEmitter;
     public ParticleSystem StarBurst;
 
     void Awake()
     {
         // Register the singleton
         if (Instance != null)
         {
             Debug.LogError("Multiple instances created!");
         }
         Instance = this;
     }
 
     // Create an explosion at the given location
     public void HeartParticles(Vector3 position)
     {
         instantiate(HeartEmitter, position);
     }
 
     public void CoinParticles(Vector3 position)
     {
         instantiate(CoinEmitter, position);
     }
 
     public void StarParticles(Vector3 position)
     {
         instantiate(StarBurst, position);
     }
 
 
     // Instantiate a Particle system from the prefab
     private ParticleSystem instantiate(ParticleSystem prefab, Vector3 position)
     {
         ParticleSystem newParticleSystem = Instantiate(prefab, position, Quaternion.identity) as ParticleSystem;
         // Make sure it will be destroyed
         Destroy(newParticleSystem.gameObject, newParticleSystem.startLifetime);
         return newParticleSystem;
     }
 
 }

The particles then gets instantiated in an OnTriggerEnter2D() method like this:

     void OnTriggerEnter2D(Collider2D other)
     {
         if (other.gameObject.name == "kiwi")
         {
             ParticleHelper.Instance.HeartParticles(transform.position);
             ApplicationManager.myScore += points;
             playerScript.setPower();
             Destroy(this.gameObject);       //the gameobject associated to this script (the gems) gets destroyed
         }
     }
 

Now...the particle collider is set to box, if i set it to anything else the particles move fine but they ignore the shape of the emitter and act like it's a sphere. Again, if i drag from the inspector directly into the scene, everything is just fine.

This makes me think that there is something wrong with how they get instantiated... I tried new scenes, new objects, and even everything new from scratch, but still same behaviour. Does anybody know why it happen? I have read a lot of online tutorials and apparently there is nothing wrong. Is it a bug with the particle system? Any help would be appreciated. Thanks.

Comment
Add comment
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

1 Reply

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

Answer by mteom · Feb 06, 2015 at 09:35 PM

Found what the problem was. The instantiated object rotation is instanced to 0 instead of 270 like my prefab. Any idea why the rotation is set to zero after the instance is created?

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 VesuvianPrime · Feb 06, 2015 at 09:35 PM 1
Share

You're feeding Quaternion.identity into the instantiation

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

2 People are following this question.

avatar image avatar image

Related Questions

How to use many particle systems, just varying in size and emitter dimensions 0 Answers

Strange cloning/ghosting problem with instantiated particles 0 Answers

Need help in instantiating at desired position. 1 Answer

Audio and Particles on Trigger 0 Answers

Spawning individual particles at scene coordinates. 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