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 /
avatar image
0
Question by RetnuhStudio · Sep 12, 2016 at 11:15 AM · instantiateparticles

Spawning individual particles at scene coordinates.

So i'm messing around with creating a 'galaxy' type star field. I have one gameobject that creates a Vector3[] array of star positions using a for loop and Random.insideUnitSphere then it creates gameobjects at those positions.

 // Spawn Systems.
 for (int i = 0; i < systemCount; i++) {
       Vector3 pos = Random.insideUnitSphere * galaxySize;
       systemPositions [i] = pos;

       GameObject s = Instantiate (prefabSystem, pos, new Quaternion (0, 0, 0, 0)) as GameObject;
       s.transform.SetParent (transform);
 }


After that I have a ParticleSystem gameobject that accesses that Vector3[] and tries to create particles at those positions.

 public void PopulateParticleSystem() {
       pSystem = GetComponentInChildren<ParticleSystem> ();
       gManager = GetComponent<scriptGalaxyManager> ();
 
       sParticles = new ParticleSystem.Particle[gManager.systemPositions.Length];
       int s = pSystem.GetParticles (sParticles);
         
       for (int i = 0; i < s; i++)
             sParticles [i].position = gManager.systemPositions [i];
         
       pSystem.SetParticles (sParticles, s);
       pSystem.Emit (sParticles.Length);
       pSystem.Pause ();
 }


However I am having issues with things lining up.

alt text

The sphere colliders are gameobjects that have been Instantiated at the systemsPosition vectors and the white dots are the particles.

Both the galaxy size and particle sphere radius are set to 10,000.

The parenting hierarchy. alt text

'galaxyManager' is what the above script is running on and 'particleSystem' is the particle system it is accessing. Both are at position (0, 0, 0).

Does anyone have any experience with this type of thing and can lend a hand, Let me know if you need any more details.

Thanks - Matt

parenting.jpg (37.8 kB)
galaxy.jpg (110.0 kB)
Comment
Add comment · 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 RetnuhStudio · Sep 13, 2016 at 10:23 AM 0
Share

Anyone else have any ideas, by doing some more searching I guess what I am creating is a Point Cloud. By looking at other posts ..GetParticles(...) and ..SetParticles(...) does seem to be the way to do it so I must just be getting something wrong. Are particle positions still regular (x, y, z) coordinates?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by TobyKaos · Sep 12, 2016 at 12:19 PM

Are the same origin for both?

Comment
Add comment · Show 5 · 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 RetnuhStudio · Sep 12, 2016 at 12:25 PM 0
Share

Yea, both are at at 0, 0, 0. I've tried different rotations of each to try find alignment and also parenting. Nothing seems to come close.

avatar image TobyKaos · Sep 12, 2016 at 12:51 PM 0
Share

Can you add gameObject creation code and parenting?

avatar image RetnuhStudio · Sep 12, 2016 at 01:02 PM 0
Share

Sure thing, have updated original post.

avatar image TobyKaos · Sep 12, 2016 at 01:23 PM 0
Share

$$anonymous$$aybe collider offset

avatar image RetnuhStudio · Sep 12, 2016 at 01:31 PM 0
Share

Nah that's all zeroed as well. alt text

prefab.jpg (60.8 kB)

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

67 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

Related Questions

bind instantiated particles to an object 1 Answer

A question related to the explosion after creation of debris 1 Answer

performance question about particles and instantiating 1 Answer

Instantiate diffent particle for different object 1 Answer

Instantiate an prefab as a child of the player 3 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