LoginSignup
4
4

More than 5 years have passed since last update.

ParticleSystemとスクリプトで星空的なものを作る

Last updated at Posted at 2017-03-22

5000個パーティクル作り、パーティクルは静止させている。
image

using UnityEngine;
using System.Collections;

public class ParticleTest : MonoBehaviour
{

    // Use this for initialization
    void Start ()
    {
        ParticleSystem particleSystem = GetComponent<ParticleSystem> ();

        int num = 5000;

        particleSystem.Emit (num);
        ParticleSystem.Particle[] particle = new ParticleSystem.Particle[num];
        particleSystem.GetParticles(particle);
        particleSystem.Pause();
        for (var i = 0; i < num; i++)
        {
            particle [i].position = new Vector3 (
                (Random.value-0.5f)*100f,
                (Random.value-0.5f)*100f,
                (Random.value-0.5f)*100f
            );
        }

        particleSystem.SetParticles(particle,num);
    }

}
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4