Version: 2017.4
LanguageEnglish
  • C#
  • JS

Script language

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

ParticleSystem.MainModule.simulationSpace

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 simulationSpace: ParticleSystemSimulationSpace;
public ParticleSystemSimulationSpace simulationSpace;

Description

This selects the space in which to simulate particles. It can be either world or local space.

Toggle between local and world space simulation using the following example:

#pragma strict
private var ps: ParticleSystem;
public var useLocal: boolean = true;
function Start() {
	ps = GetComponent.<ParticleSystem>();
	var main: var = ps.main;
	useLocal = main.simulationSpace == ParticleSystemSimulationSpace.Local;
}
function Update() {
	var main: var = ps.main;
	main.simulationSpace = useLocal ? ParticleSystemSimulationSpace.Local : ParticleSystemSimulationSpace.World;
}
function OnGUI() {
	useLocal = GUI.Toggle(new Rect(10, 60, 200, 30), useLocal, "Use Local Simulation Space");
}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public bool useLocal = true;

void Start() { ps = GetComponent<ParticleSystem>(); var main = ps.main; useLocal = main.simulationSpace == ParticleSystemSimulationSpace.Local; }

void Update() { var main = ps.main; main.simulationSpace = useLocal ? ParticleSystemSimulationSpace.Local : ParticleSystemSimulationSpace.World; }

void OnGUI() { useLocal = GUI.Toggle(new Rect(10, 60, 200, 30), useLocal, "Use Local Simulation Space"); } }

Simulate particles relative to an independent game object using the following example:

#pragma strict
public class ParticleSystemScript extends MonoBehaviour {
	private var ps: ParticleSystem;
	public var relativeTo: Transform;
	function Start() {
		ps = GetComponent.<ParticleSystem>();
		var main: var = ps.main;
		main.simulationSpace = ParticleSystemSimulationSpace.Custom;
		main.customSimulationSpace = relativeTo;
	}
	function Update() {
	}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ParticleSystemScript : MonoBehaviour { private ParticleSystem ps; public Transform relativeTo;

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

var main = ps.main; main.simulationSpace = ParticleSystemSimulationSpace.Custom; main.customSimulationSpace = relativeTo; }

void Update() { } }