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

Choppy particle rendering

Discussion in 'General Graphics' started by Mystic_Quest, Apr 25, 2020.

  1. Mystic_Quest

    Mystic_Quest

    Joined:
    Feb 22, 2016
    Posts:
    47
    I am trying to achieve a bullet effect https://imgur.com/a/7oGb4gY with particles, called by an emit(1) function on shoot, which shoots a particle with a trail.

    Problem is that the particle is not smoothly rendered as it moves, (giving off the illusion of multiple trails instead of smooth movement) and I have no idea why. Here is a video with much lower particle speed: https://imgur.com/a/uiqp4oM with the same thing happening. Editor framerate is ~3k.

    Also, colliders are very unreliable at high-ish speeds, not updating their position smoothly either. Fixedtimestep does not seem to have an effect. Any way I can change that?

    Should I give up on particles for bullets? Is there any other way you can suggest for a fast bullet effect like on the 1st video (besides stretching textures drawn on a raycast).

    Thanks.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Can you share the code you are using and the settings on the ParticleSystem?
    If you turn off the camera shake effect does it still happen?
     
  3. Mystic_Quest

    Mystic_Quest

    Joined:
    Feb 22, 2016
    Posts:
    47
    Thank you very much for your time.

    Yea, I tried commenting out the impulseSource code, disabling the impulse listener and vcam altogether.

    Here is my scene and the PSystem's settings.
    https://imgur.com/a/042SWdL

    As for the code I just invoke an event here:
    Code (CSharp):
    1. private void Update()
    2.     {
    3.         HandleShooting();
    4.     }
    5.  
    6.     private void HandleShooting()
    7.     {
    8.         if (Input.GetMouseButtonDown(0))
    9.         {
    10.             animControl.isShooting(); //gun kickback anim, tried disabling it
    11.  
    12.             OnShoot?.Invoke(this, new OnShootEventArgs
    13.             {
    14.                 gunEndPointPosition = gunEndPointTransform.position,
    15.                 shootPosition = Utilities.GetMousePosition(),
    16.             });
    17.         }
    18.     }
    ...and then register this function in it:
    Code (CSharp):
    1. private void Start()
    2.     {
    3.         playerShoot.OnShoot += Player_OnShoot;
    4.     }
    5.  
    6.     private void Player_OnShoot(object sender, Shoot.OnShootEventArgs e)
    7.     {
    8.         impulseSource.GenerateImpulse(); //camera effect. tried disabling it
    9.         playerShoot.bulletFX.Emit(1);
    10.     }
    Notes:
    -Might as well set render mode: none, since all I care about is the trail.
    -If I disable the trails and set stretched billboard for example, the same problem happens (but I don't want to use that for other reasons).
    -I used to have the shape module on for bullet spread, but it is currently disabled.
     
    Last edited: Apr 26, 2020
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Try enabling the inherit velocity module.
     
  5. Mystic_Quest

    Mystic_Quest

    Joined:
    Feb 22, 2016
    Posts:
    47
    Thanks for the reply.

    Inherited velocity makes trails (or stretched billboards without trails) tilt a bit https://imgur.com/a/dWT2GEe. Initial V, with 1 multiplier gives the least weird results. Tried changing Render alignment and adding the shape module (as a 0 deg cone -- straight line) with "Align to direction" but no cigar.


    Edit: I kind of solved the problem (I hope) by setting the simulation space to custom setting the player's transform instead of local or world, skipping the parent gun rotation. The bullet moves with the player obviously, but since the speed is very high, it probably won't be noticeable at all.

    My real problem was choppy rendering (which is a little visible even when not moving https://imgur.com/a/IFahn1I) but this, more or less, masks it, because the particle is rendered in the same place in the screen space when moving.

    Is there a way however to make the collider movement more accurate though in such speeds? (They work fine in slow speeds). Perhaps I'll try a raycast from each particle, or send the particle towards a raycast in the first place.

    Also here's my repo for reference if you need it https://github.com/MysticQuest/Unity-ProjectR
     
    Last edited: Apr 26, 2020
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    I tested your project and the collisions seem fine to me. What exactly is wrong with them? I set the particle speed to be hight(500) and didnt see any miss.
     
  7. Mystic_Quest

    Mystic_Quest

    Joined:
    Feb 22, 2016
    Posts:
    47
    Apologies for not being more clear Karl and I hope I am not wasting your time with this.
    The collisions themselves always happen, as seen in the debug log.

    Now, the particle and its trail (or a stretched billboard without trail) is set to stop and be destroyed when they collide (collider module: dampen 1, lifetime 1). (Note: if I don't use dampen *some* of the particles slightly bounce off the collider even with lifetime at 1).

    Anyway, the collision problem is that it gets destroyed at seemingly different random distances in high speeds. The higher the speed, the sooner it can get destroyed before the particle in the scene reaches the collider::https://imgur.com/a/pEjs0ns

    This happens even to speeds around 50 but the distance margin that the particles get destroyed is miniscule. In the video p speed is 200. Some particles do reach the collider, while others get seemingly destroyed much sooner. (FixedTimestep doesn't seem to have any effect on this.)

    Do you get the same effect on your cloned repo?
     
    Last edited: Apr 27, 2020
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    I'll have to look into it closer but I suspect that we do the collision check before the trail is updated and so the hit point is not added to the trail as the particle is now killed. Maybe we can add the hit point as the final point when the particle is destroyed
     
  9. Mystic_Quest

    Mystic_Quest

    Joined:
    Feb 22, 2016
    Posts:
    47
    I see, if I understood correctly the particle hitpoint collides first, kills the particle, which never gets rendered (along with the trail) on that last frame (same happens with stretched billboard particles without a trail https://imgur.com/a/QF2ieRM).

    Would be great! I'll try to get into this and find a way to update it as well.
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    You may be able to work around it by using the on collision event and adding a particle or point in the trail at that point
     
    Mystic_Quest likes this.