Search Unity

Particle System and Fixed Update Stutter - No collision event in fixed update.

Discussion in 'Scripting' started by naked_chicken, Sep 20, 2015.

  1. naked_chicken

    naked_chicken

    Joined:
    Sep 10, 2012
    Posts:
    186
    So I ran into the issue that so many do where a camera following a rigid body object will sometimes stutter. I fixed this by putting the camera follow in FixedUpdate. This works great for all rigid bodies, but I also have a lot of particle effects following those rigid bodies around. Those stutter when my camera moves in Fixed Update.
    I found a solution here that works great to fix the stuttering by re-simulating the system during FixedUpdate, but it introduces a new problem. Most of my particle systems are set to collide with world objects and send the collision event to those objects. When I use the script, the particles still collide just fine, but they no longer send the collision event.

    Any thoughts or other solutions for getting rid of the movement stutter?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,737
    Collision events are not sent to FixedUpdate(). They are generally sent to OnColliderEnter or OnTriggerEnter, and from there you can set a flag and handle it however you like in either Update() or FixedUpdate().
     
  3. naked_chicken

    naked_chicken

    Joined:
    Sep 10, 2012
    Posts:
    186
    Yeah I've got a OnParticleCollision set up and it works when I don't use FixedUpdate. As soon as I resimulate in FixedUpdate, however, OnParticleCollision no longer works.
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    How are you moving things? Try switching to one of the rigidbody methods, like MovePosition.