Search Unity

Shuriken Particle - World Space Simulation + Local Rotation On Emit?

Discussion in 'General Graphics' started by whitesilverrr, Oct 20, 2019.

  1. whitesilverrr

    whitesilverrr

    Joined:
    Oct 11, 2019
    Posts:
    4
    Hello, I'm trying to simulate my particle in world space.
    so in world space, meaning the particle should be in its own position and rotation when emitted? right?
    in my case, the particle still rotates with the parent transform.



    how do I leave it on the first rotation when emitted as the position did?
     

    Attached Files:

  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    I’m not sure if it will work but maybe try the Horizontal Billboard Render Mode.
     
    whitesilverrr likes this.
  3. whitesilverrr

    whitesilverrr

    Joined:
    Oct 11, 2019
    Posts:
    4
    Thanks for responding! I forgot to go back to the thread for the temporary solution I've come up with.
    The particle is on the GIF is a mesh though...

    So I tried setting the start 3D rotation via script with this code

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [ExecuteInEditMode]
    6. public class ParticleFixWorldRotation : MonoBehaviour
    7. {
    8.     public ParticleSystem system;
    9.     public Vector3 EulerOffset;
    10.     public Vector3 OrigEuler;
    11.  
    12.     // Update is called once per frame
    13.     void Update()
    14.     {
    15.         if (system)
    16.         {
    17.             var main = system.main;
    18.             main.startRotation3D = true;
    19.             OrigEuler = (transform.eulerAngles + EulerOffset) * Mathf.Deg2Rad;
    20.             main.startRotationX= OrigEuler.x;
    21.             main.startRotationY= OrigEuler.y;
    22.             main.startRotationZ= OrigEuler.z;
    23.         }
    24.     }
    25. }
    Then once this is applied, I have to set the render alignment too at world space. and it will be fixed.
    I'm sure there's a better code/solution than this, but I guess this enough does the job!
     
    richardkettlewell likes this.