Version: 2017.3 (switch to 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ParticleSystem.LimitVelocityOverLifetimeModule.dragMultiplier

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 var dragMultiplier: float;
public float dragMultiplier;

Description

Change the drag multiplier.

This method is more efficient than accessing the whole curve, if you only want to change the overall drag multiplier.

#pragma strict
private var ps: ParticleSystem;
public var hSliderValueDrag: float = 1.0f;
public var hToggleUseSize: boolean = false;
public var hToggleUseVelocity: boolean = false;
function Start() {
	ps = GetComponent.<ParticleSystem>();
	var limitVelocityOverLifetime: var = ps.limitVelocityOverLifetime;
	limitVelocityOverLifetime.enabled = true;
	var main: var = ps.main;
	main.startSize = new ParticleSystem.MinMaxCurve(0.1f, 1.5f);
	main.startSpeed = new ParticleSystem.MinMaxCurve(0.5f, 5.0f);
}
function Update() {
	var limitVelocityOverLifetime: var = ps.limitVelocityOverLifetime;
	limitVelocityOverLifetime.dragMultiplier = hSliderValueDrag;
	limitVelocityOverLifetime.multiplyDragByParticleSize = hToggleUseSize;
	limitVelocityOverLifetime.multiplyDragByParticleVelocity = hToggleUseVelocity;
}
function OnGUI() {
	GUI.Label(new Rect(25, 40, 100, 30), "Drag");
	hSliderValueDrag = GUI.HorizontalSlider(new Rect(135, 45, 100, 30), hSliderValueDrag, 0.0f, 3.0f);
	hToggleUseSize = GUI.Toggle(new Rect(25, 85, 200, 30), hToggleUseSize, "Multiply by Size");
	hToggleUseVelocity = GUI.Toggle(new Rect(25, 125, 200, 30), hToggleUseVelocity, "Multiply by Velocity");
}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public float hSliderValueDrag = 1.0f; public bool hToggleUseSize = false; public bool hToggleUseVelocity = false;

void Start() { ps = GetComponent<ParticleSystem>();

var limitVelocityOverLifetime = ps.limitVelocityOverLifetime; limitVelocityOverLifetime.enabled = true;

var main = ps.main; main.startSize = new ParticleSystem.MinMaxCurve(0.1f, 1.5f); main.startSpeed = new ParticleSystem.MinMaxCurve(0.5f, 5.0f); }

void Update() { var limitVelocityOverLifetime = ps.limitVelocityOverLifetime; limitVelocityOverLifetime.dragMultiplier = hSliderValueDrag; limitVelocityOverLifetime.multiplyDragByParticleSize = hToggleUseSize; limitVelocityOverLifetime.multiplyDragByParticleVelocity = hToggleUseVelocity; }

void OnGUI() { GUI.Label(new Rect(25, 40, 100, 30), "Drag");

hSliderValueDrag = GUI.HorizontalSlider(new Rect(135, 45, 100, 30), hSliderValueDrag, 0.0f, 3.0f); hToggleUseSize = GUI.Toggle(new Rect(25, 85, 200, 30), hToggleUseSize, "Multiply by Size"); hToggleUseVelocity = GUI.Toggle(new Rect(25, 125, 200, 30), hToggleUseVelocity, "Multiply by Velocity"); } }

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