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
2
Question by Rodolinc · Jul 20, 2016 at 08:53 PM · gravityparticle systemcustom

is it possible to make a custom gravity modifier to affect a particle system, ignoring the general scene's gravity?

Somebody know if its possible to make a custom gravity modifier to affect a particle system, ignoring the general scene's gravity? because the particle system's gravity modifier works on the current gravity axis setted on the physics settings.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by RealSoftGames · Apr 14, 2017 at 04:07 AM

yes its possible this will need tweeking though

Documentation i found this at: https://docs.unity3d.com/ScriptReference/ParticleSystem.GetParticles.html

     private ParticleSystem.Particle[] m_Particles;
     public ParticleSystem m_System;  
     public Transform target;
     private Vector3 targetDir;
 
     private void Start()
     {
         InitializeIfNeeded();
         m_Particles = new ParticleSystem.Particle[m_System.main.maxParticles];
     }
 
     private void FixedUpdate()
     {
         // GetParticles is allocation free because we reuse the m_Particles buffer between updates
         int numParticlesAlive = m_System.GetParticles(m_Particles);
 
         // Change only the particles that are alive
         for (int i = 0; i < numParticlesAlive; i++)
         {
             //obtain the inverse direction of each particle and apply velocity towards the object
             targetDir = m_Particles[i].position - target.transform.position;
 
             m_Particles[i].velocity += gravity * Time.fixedDeltaTime;
         }
 
         // Apply the particle changes to the particle system
         m_System.SetParticles(m_Particles, numParticlesAlive);
     }
 
     private void InitializeIfNeeded()
     {
         if (m_System == null)
             m_System = GetComponent<ParticleSystem>();
 
         if (m_Particles == null || m_Particles.Length < m_System.main.maxParticles)
             m_Particles = new ParticleSystem.Particle[m_System.main.maxParticles];
     }


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 felixpk · Apr 27, 2017 at 09:26 AM 0
Share

You aren't even using targetDir, why do you assign it? gravity isn't assigned either ... the code is more or less useless

avatar image
1

Answer by richardkettlewell · Nov 28, 2017 at 10:59 PM

You could use the External Forces module and a directional wind zone component.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I change the gravity modifier of a particle system through script? 1 Answer

Custom particle system preview. 0 Answers

How can I apply gravity to each particle within a 'Gravity Zone' region? 0 Answers

How to make orbital gravity 1 Answer

Make a particle system with particles that stick to everything once they collide 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