Version: 2018.3 (switch to 2019.1)
LanguageEnglish
  • C#

ParticleSystem.ExternalForcesModule.RemoveInfluence

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public void RemoveInfluence(int index);
public void RemoveInfluence(ParticleSystemForceField field);

Parameters

indexThe index to remove the chosen Force Field from.
fieldThe Force Field to remove from the list.

Description

Removes the Force Field from the influencers list at the given index.

When influenceFilter is set to ParticleSystemGameObjectFilter.List then only Force Fields in the influencers list will affect the Particle System.

using UnityEngine;

public class Example : MonoBehaviour { ParticleSystem.ExternalForcesModule externalForcesModule;

void Start() { // Create a default particle system var particleSystemGameObject = new GameObject("Particle System"); var system = particleSystemGameObject.AddComponent<ParticleSystem>();

// Create a force field to influence the particle system var forceFieldGameObject = new GameObject("Force Field"); var forceField = forceFieldGameObject.AddComponent<ParticleSystemForceField>(); forceField.endRange = 5; forceFieldGameObject.transform.position = new Vector3(0, 0, 10);

// Add the force to the particle systems external forces influencers. externalForcesModule = system.externalForces; externalForcesModule.enabled = true; externalForcesModule.influenceFilter = ParticleSystemGameObjectFilter.List; externalForcesModule.AddInfluence(forceField); }

void OnGUI() { GUILayout.Label("Particle System Influencers:"); for (int i = 0; i < externalForcesModule.influenceCount; ++i) { var influence = externalForcesModule.GetInfluence(i);

GUILayout.BeginHorizontal(); GUILayout.Label(i + ": " + influence.name); if (GUILayout.Button("Remove")) { externalForcesModule.RemoveInfluence(i); --i; } GUILayout.EndHorizontal(); } } }

Did you find this page useful? Please give it a rating: