Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Particlesystem RotationOverLifeTime constant not getting set as expected

Discussion in 'Editor & General Support' started by VaporAnomaly, May 29, 2020.

  1. VaporAnomaly

    VaporAnomaly

    Joined:
    Jun 9, 2015
    Posts:
    22
    Hi,

    I have the below code, which is expected to set rotation of my particles at runtime.

    Code (CSharp):
    1.     void ChangeParticleRotation()
    2.     {
    3.         //Tilting rain as per wind direction
    4.         var rotationOverLifetimeModule = rainParticleSystem.rotationOverLifetime;
    5.  
    6.         ParticleSystem.MinMaxCurve minMaxCurveZ = new ParticleSystem.MinMaxCurve();
    7.         minMaxCurveZ.mode = ParticleSystemCurveMode.Constant;
    8.         minMaxCurveZ.constant = Mathf.Sign(oceanController.windDirection.z) * 45;
    9.         rotationOverLifetimeModule.z = minMaxCurveZ;
    10.  
    11.         Debug.Log(rotationOverLifetimeModule.z.constant + "," + oceanController.windDirection.z + "," + Mathf.Sign(oceanController.windDirection.z));
    12.     }
    The debug line returns the below results


    45,0.9824775,1
    UnityEngine.Debug:Log(Object)
    SkyManager:ChangeParticleRotation() (at Assets/Scripts/SkyManager.cs:104)
    SkyManager:Update() (at Assets/Scripts/SkyManager.cs:39)

    But in the particles, i can see the value for Z set as below! (Z = 2578.31)

    Particles Rotation OVer LifeTime Error.PNG

    Can someone explain what is happening here. What am I doing wrong?
    Your inputs are much appreciated.

    Thanks,
    Joshua.
     
  2. VaporAnomaly

    VaporAnomaly

    Joined:
    Jun 9, 2015
    Posts:
    22
  3. VaporAnomaly

    VaporAnomaly

    Joined:
    Jun 9, 2015
    Posts:
    22