Search Unity

Particle collision radius origin is offset to the left. How can I make it centered?

Discussion in 'General Graphics' started by ewagstaff, Jun 21, 2017.

  1. ewagstaff

    ewagstaff

    Joined:
    Apr 21, 2017
    Posts:
    13
    I'm making a 2D top-down shooter in Unity and I'm using particles for bullets instead of GameObjects to try to save on performance cost. I've gotten pretty far in development when I started to notice a quirk of the particle collision system (at least as far as I understand it). Some shots appear to go through enemies, even though the center of the particle passes through them.



    Those jellyfish are the enemies. That dark blue circle is a particle bullet (set to a sprite material) that is passing through the bottom jellyfish.

    I ruled out collision accuracy issues by making sure all the colliders were dynamic and the collision accuracy settings were at their highest possible value. Because it's a classic top down shooter and the player always shoots directly up, I was able to observe that if a shot like the one above misses the first time, it will continue to miss every time unless the player moves to the right. That's when I realized that the origin of the collision radius is in the top left corner, not in the center.

    Here's another screenshot of a bullet that is about to successfully collide:



    Unity does have a helpful attribute for particle collisions called "Radius Scale," however, because the origin itself appears to be offset, the radius increases around the top left corner so it's still not helping to assure accuracy. Does anyone know how to change the origin of the particle to fix this issue? Or is this a bug in particle collisions?

    Also, here are the particle system settings in case that helps answer questions about the setup (I wish the "Visualize Bounds" checkbox would work, but it does not seem to):



     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    "Visualize Bounds" only works in the Scene View, if that helps you diagnose what is going on.

    It should be the center. My only guess is that the texture you are applying to the particle is offset, (i.e. you have a large empty area in the texture) but that seems unlikely.

    I can't see anything obviously wrong with your setup based on what you have posted. I think you have a few options:

    1. Try to validate this in the Scene View, where Visualize Pivot and Visualize Bounds should both help you
    2. Submit a minimal reproduction project as a bug
    3. Try using the Pivot settings in the Renderer, to counteract this weird behavior.

    But the third option is not really addressing the root cause of the problem :)
     
  3. ewagstaff

    ewagstaff

    Joined:
    Apr 21, 2017
    Posts:
    13
    Ah, thanks for the quick response! I'll take a look at the bounds in scene view if I can. Otherwise, I'll whip up a small project to repro the issue.
     
    richardkettlewell likes this.