Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Change Particle size at runtime

Discussion in 'Scripting' started by ClaireJY, Oct 22, 2020.

  1. ClaireJY

    ClaireJY

    Joined:
    Mar 26, 2018
    Posts:
    4
    How to change everty particle size during runtime? Like , make x and y always the same.
    upload_2020-10-22_14-15-41.png
    this kind of code does not take effect
     
  2. alexeu

    alexeu

    Joined:
    Jan 24, 2016
    Posts:
    257
  3. ClaireJY

    ClaireJY

    Joined:
    Mar 26, 2018
    Posts:
    4
  4. alexeu

    alexeu

    Joined:
    Jan 24, 2016
    Posts:
    257
    So basicaly it's ParticleSystem.MainModule.startSize3D
    that means that you need to declare a MainModule to acceed to the startSize3D property (or any other one...)

    Now you want to change some of them. you mean some of the PS ? this is just Logic, nothing to do with PS specificaly. You need an IF statement that says "Oh, change the startSize3D of this PS. Oh not this one..."
    You can use layers, tags or whatever relativ to your PS.

    In a second time you would change some axis only. startSize3D is a Vector3 so you can assign values to its axis as you want (or almost). I use a simple example. No array...

    Code (CSharp):
    1. psmain.startSize3D =  new Vector3(newValueX, newValueY, newValueZ);

    Now If you want to change just some axis (lets say the Y axis) keeping the others as they are you can say

    Code (CSharp):
    1. psmain.startSize3D =  new Vector3(psmain.startSize3D.x, newValueY, psmain.startSize3D.z);
    Hope i understood what you need...