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 Ochreous · Feb 20, 2014 at 10:02 PM · c#particles

C# Changing Force over Lifetime Through Script

I would like to change certain axes in the force over lifetime feature in a shuriken particle system through a script. But I'm not sure where it is. I've searched on the Unity script reference and I couldn't find anything along the lines of force over lifetime. I'm not even if it is possible to access it through this manner. I've tried ParticleSystem.ForceOverLifetime.Vector3.X but ForceOverLifetime is not in the class ParticleSystem.

Comment
Add comment · Show 3
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 getyour411 · Feb 20, 2014 at 10:30 PM 1
Share

There might not be a direct Unity API to do that yet, but this UA post talks about how to do it manually - the example uses color over lifetime but you might be able to adapt it to force over lifetime

http://answers.unity3d.com/questions/347675/how-to-change-particle-systems-color-over-lifetime.html

avatar image Ochreous · Feb 21, 2014 at 12:42 AM 0
Share

I looked and there is no vector3 variable called force so I don't think that will work.

avatar image rutter · Feb 21, 2014 at 01:48 AM 0
Share

There's no "force", but there is velocity. Force causes change in velocity.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Scopperloit · May 13, 2014 at 01:13 AM

If you want to change the behaviour of each particle individually, you will have to create a storage space in terms of an array, and use particleSystem.GetParticles(yourArray); to store the entire particle system. After altering each particle, you need to put the array back into the particle system like this: particleSystem.SetParticles(yourArray, int size);

Next you need to loop through the array using a for-loop, then change the velocity of each particle.

I've used this technique to make particles orbit a sphere by simulating a gravitational pull on each individual particle. Performance-wise it works fine on my desktop with at least 10.000. I'm not sure how this many particles performs on a phone, though. If you want to see how it all works out, take a look at my YouTube-video.

Here's a suggestion for how to set up the code:

 private void AddForceOnParticles(){
         
         ParticleSystem.Particle[] _particles = new ParticleSystem.Particle[particleSystem.particleCount];
         this.particleSystem.GetParticles(_particles);
         
         for (int i = 0; i < _particles.Length; i++){
             // Here you can do whatever you want with each particle by using _particles[i] 
         }
 
         this.particleSystem.SetParticles(_particles, int size);
     }

Call the AddForceOnParticles() from the Update() method.

Hope this helps somehow! :)

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

Answer by zhuk1011 · Jan 28, 2016 at 01:27 PM

http://docs.unity3d.com/Manual/PartSysForceOverLifeModule.html

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

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

21 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

Related Questions

C# Emit Particle Upon Left Mouse Click 2 Answers

Player lives script help 1 Answer

C# -- Build character unit from script 1 Answer

C# Randomly Adding Elements from stringListA to stringListB 1 Answer

C# Input.GetKey("Tab") Double Tap 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