Search Unity

Particle System Rotation3D Not Updateing

Discussion in 'Scripting' started by DrDecipher, Nov 5, 2018.

  1. DrDecipher

    DrDecipher

    Joined:
    Dec 5, 2012
    Posts:
    54
    I have a Script generating an array of ParticleSystem.Particles. These are handed to a ParticleSystem with only the Render component enabled. All of the properties are accepted and displayed correctly with the exception of Rotation3D.

    Regardles of how the Render Alignment is set the particles do not rotate to the value passed to particle.Rotation3D.

    I have tried this with and without 'ma.startRotation3D = true;' to no effect.
    I would expect if the renderer was set to either Local or World render alignment that the rotation3D in the particle would be shown.

    Any direction would be appriciated,
    Tharyn
     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Can you show us your script and a screenshot of the inspector for the system?
     
    karl_jones likes this.
  3. TharynV

    TharynV

    Joined:
    Jul 13, 2017
    Posts:
    4
    Thanks.

    I found that the error was in the logic of the script. Here is a test script other can use for experimenting in the future.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class ApplyParticleRotationTest : MonoBehaviour {
    6.  
    7.  
    8.     ParticleSystem ps;
    9.     ParticleSystemRenderer psr;
    10.     ParticleSystem.MainModule ma;
    11.     ParticleSystem.Particle[] _particles;
    12.  
    13.     void GenerateParticles()
    14.     {
    15.         for (int i = 0; i < _particles.Length; i++)
    16.         {
    17.             _particles[i].startLifetime = 100;
    18.             _particles[i].remainingLifetime = 100;
    19.             _particles[i].startColor = new Color(255, 0, 255);
    20.             _particles[i].startSize = 0.1f;
    21.  
    22.             _particles[i].position = new Vector3(i * 0.1f, 0, 0);
    23.             _particles[i].velocity = new Vector3(0, 1, 0);
    24.             _particles[i].rotation3D = new Vector3(45, 0, 0);
    25.         }
    26.     }
    27.  
    28.     void RotateParticles()
    29.     {
    30.         for (int i = 0; i < _particles.Length; i++)
    31.         {
    32.             _particles[i].rotation3D += new Vector3(1, 0, 0);
    33.         }
    34.     }
    35.  
    36.     // Use this for initialization
    37.     void Start()
    38.     {
    39.         ps = GetComponent<ParticleSystem>();
    40.         psr = GetComponent<ParticleSystemRenderer>();
    41.         _particles = new ParticleSystem.Particle[20];
    42.         GenerateParticles();
    43.     }
    44.    
    45.     // Update is called once per frame
    46.     void Update ()
    47.     {
    48.         RotateParticles();
    49.  
    50.         ps.SetParticles(_particles, _particles.Length);
    51.     }
    52. }
    53.  
     
    richardkettlewell likes this.
  4. Lance-Huang

    Lance-Huang

    Joined:
    Apr 7, 2013
    Posts:
    9
    Have you solved your problem?I had a similar problem