Search Unity

Bug Rate Over Distance Multiplier

Discussion in 'General Graphics' started by MousePods, Jul 21, 2021.

  1. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Hi!

    I have an issue where I set:

    Code (CSharp):
    1. smallHeartsEmissionModule.rateOverDistanceMultiplier = smallHeartsRateOverDistanceMultiplierCollected;
    2.  
    1. If I set it to 0, it will not show anything, good!
    2. If I set it to any number higher than 1, it will work so 2 or 100 spawns correctly
    3. BUG: If I set it to anything lower than 1 it will not work. Even setting it to 0.00001f will not work. It seems to spawn as if it's always 1.

    NOTE: The rateOverTimeMultiplier works.

    Am I missing something?

    Screen Shot 2021-07-21 at 12.14.12 PM.png

    Thanks!
     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Interesting... sounds like a bug, could you report it please? If you reply here with the case number it will help me track it.

    thanks!
     
    MousePods and karl_jones like this.
  3. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Case #: 1352410

    Thanks!
     
    richardkettlewell likes this.
  4. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    So it seems like QA couldn't reproduce it. I don't know when this happened, but it might have happened in beta 5 of 2021.2 or was always happening and I just never noticed?

    Now when I change rateOverDistanceMultiplier, it changes the rateOverDistance?



    Here is the code:

    Code (CSharp):
    1. [ExecuteInEditMode]
    2. public class NewBehaviourScript : MonoBehaviour
    3. {
    4.     private ParticleSystem ps;
    5.     public float hSliderValue = 1;
    6.  
    7.     void Start()
    8.     {
    9.         ps = GetComponent<ParticleSystem>();
    10.     }
    11.  
    12.     void Update()
    13.     {
    14.         var emission = ps.emission;
    15.         emission.rateOverDistanceMultiplier = hSliderValue;
    16.  
    17.         ps.transform.position = new Vector3(Mathf.Sin(Time.time) * 2.0f, 0.0f, 0.0f);
    18.     }
    19. }
    NOTE: Thanks for moving my post! I now know where to post particle system issues :)

    Thanks!
     
    richardkettlewell likes this.
  5. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Those 2 properties are pretty much the same thing.
    The only difference is one is the full MinMaxCurve, which is a big type and slower to mess with, compared to the “multiplier” version, which simply operates on the single value, or if in curve mode, the multiplier for the whole curve. Basically a fast-path for the common use case.

    https://docs.unity3d.com/ScriptRefe...missionModule-rateOverDistanceMultiplier.html
     
    MousePods likes this.
  6. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Oh okay! I guess I was thinking of the multiplier as taking whatever you have in that field in whatever mode and just multiplying it by the multiplier instead of having to change the actual values. That way you could say 0.5f or 2 and get twice or half the speed.

    If I wanted to do that (just use the multiplier and not change the actual rate over distance), I need to change them into curves and then use the multiplier.

    Because yeah, when I have between two constants, it will change the right most constant. Not what I expected but I am glad I know now and hopefully this will help others!

    Screen Shot 2021-08-04 at 1.38.11 PM.png

    Thanks!
     
    AlejMC likes this.
  7. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,445
    It really would be great if we had an overall scalar modifier like MousePods was expecting, which carried through the emission rates of ALL children. For example, a chunk of code could accept any particlesystem prefab, and adjust a master "spigot" to ramp it up and down without really knowing much about the structure of the prefab itself. Now I have to construct a new dictionary every time the car tire hits a different material with a different prefab, just so I can memorize all of the original emission rates and apply them back as traction allows.