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.InheritVelocityModule.curve

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 curve: ParticleSystem.MinMaxCurve;

Description

Curve to define how much emitter velocity is applied during the lifetime of a particle.

See Also: MinMaxCurve.

#pragma strict
private var ps: ParticleSystem;
public var isEnabled: boolean = true;
public var hSliderValue: float = 5.0f;
public var inheritMode: ParticleSystemInheritVelocityMode;
function Start() {
	ps = GetComponent.<ParticleSystem>();
	var main: var = ps.main;
	main.simulationSpace = ParticleSystemSimulationSpace.World;
	// add a sphere so we can see our transform position as it moves
	var sphere: var = GameObject.CreatePrimitive(PrimitiveType.Sphere);
	sphere.transform.parent = ps.transform;
}
function Update() {
	var inheritVelocity: var = ps.inheritVelocity;
	inheritVelocity.enabled = isEnabled;
	inheritVelocity.curve = hSliderValue;
	inheritVelocity.mode = inheritMode;
	ps.transform.position = new Vector3(Mathf.Sin(Time.time * 2.0f) * 2.0f, 0.0f, 0.0f);
}
function OnGUI() {
	isEnabled = GUI.Toggle(new Rect(25, 45, 100, 30), isEnabled, "Enabled");
	hSliderValue = GUI.HorizontalSlider(new Rect(25, 85, 100, 30), hSliderValue, 0.0f, 10.0f);
	inheritMode = ParticleSystemInheritVelocityModeGUI.SelectionGrid(new Rect(25, 125, 300, 30), intinheritMode, [new GUIContent("Initial"), new GUIContent("Current")], 2);
}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public bool isEnabled = true; public float hSliderValue = 5.0f; public ParticleSystemInheritVelocityMode inheritMode;

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

var main = ps.main; main.simulationSpace = ParticleSystemSimulationSpace.World; // rate over distance only works for world space simulations

// add a sphere so we can see our transform position as it moves var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.parent = ps.transform; }

void Update() { var inheritVelocity = ps.inheritVelocity; inheritVelocity.enabled = isEnabled; inheritVelocity.curve = hSliderValue; inheritVelocity.mode = inheritMode;

ps.transform.position = new Vector3(Mathf.Sin(Time.time * 2.0f) * 2.0f, 0.0f, 0.0f); }

void OnGUI() { isEnabled = GUI.Toggle(new Rect(25, 45, 100, 30), isEnabled, "Enabled"); hSliderValue = GUI.HorizontalSlider(new Rect(25, 85, 100, 30), hSliderValue, 0.0f, 10.0f); inheritMode = (ParticleSystemInheritVelocityMode)GUI.SelectionGrid(new Rect(25, 125, 300, 30), (int)inheritMode, new GUIContent[] { new GUIContent("Initial"), new GUIContent("Current") }, 2); } }
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答