Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Problem with particles in World simulation space while rotating bones at LateUpdate

Discussion in 'Animation' started by DanMorEx, Feb 22, 2016.

  1. DanMorEx

    DanMorEx

    Joined:
    Dec 10, 2015
    Posts:
    2
    I need my character's spine to rotate independently from legs. That is why I use my own rotation logic in LateUpdate.

    But I also need a special lighting trail effect on the hand weapon of my character. It can be done only with particle system in world simulation space (not local).

    Rotating bone in LateUpdate leads to the bugs with particle system: position of trail particles become wrong, they are calculated before Late Update call... Rotating particles in LateUpdate leads to nothing: their positions are updating in next Update call..

    Ok, I detached my trail from bone and started to rotate and move it manually in Update, with on position of bones of last frame.. Wah.. It almost working, but particle system lags behind with one frame... Still not good.

    What i shall to do?
     
    Last edited: Feb 23, 2016
  2. DanMorEx

    DanMorEx

    Joined:
    Dec 10, 2015
    Posts:
    2
    Help please o_O
     
  3. erenaydin

    erenaydin

    Joined:
    Mar 1, 2011
    Posts:
    384
    I'm having the same issue right now. Searching for a solution
     
  4. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    I'm late

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. // Make sure the order is later than your LateUpdate script, say IK system, you can check the order at Edit->ProejectSettings->ScriptExecutionOrder
    4. [DefaultExecutionOrder(11000)]
    5. public class LateUpdateParticles : MonoBehaviour
    6. {
    7.     private ParticleSystem[] _systems;
    8.  
    9.     private void Awake()
    10.     {
    11.         _systems = GetComponentsInChildren<ParticleSystem>();
    12.     }
    13.  
    14.     /// <summary>
    15.     /// Simulate particles in whatever stage you want
    16.     /// </summary>
    17.     private void LateUpdate()
    18.     {
    19.         foreach (var system in _systems)
    20.         {
    21.             // Fast-forward particles then pause it, so you can simulate them step by step
    22.             // However you may want to tweak these parameters to fit your case, please see also the doc
    23.             system.Simulate(Time.deltaTime, true, false, false);
    24.         }
    25.     }
    26. }
     
  5. Andrey-Postelzhuk

    Andrey-Postelzhuk

    Joined:
    Nov 26, 2013
    Posts:
    75
    I had the similar problem.
    1. I had MoveAlongThePath component that moved transform in LateUpdate.
    2. MoveAlongThePath's properties is controlled by Animator.
    3. I use LateUpdate to override transform.position written from Animator.
    4. ParticlesSystem update after Animator but before LateUpdate.
    5. If moving object has ParticlesSystems children they will be showed not in the position on LateUpdate but in the position from Animator.
    6. The solution was to use in MoveAlongThePath `OnDidApplyAnimationProperties` instead of `LateUpdate`.