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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Stretched billboard particle system collision

Discussion in 'Editor & General Support' started by Xarfai, Sep 19, 2018.

  1. Xarfai

    Xarfai

    Joined:
    Mar 28, 2017
    Posts:
    2
    Hello everyone,

    in my game I have a beam attack, that is using a particle system, which is rendered by a stretched billboard. Now I want the beam to collide with walls (since I dont want to be able to shoot through walls). But when I add collisions, it does not collide with anything at all.

    When I visualize the bounds of the collider, I can see that the collider barely moves and therefore does not collide with any wall even though it seems like the beam goes right through. Is there any workaround for that?

    If it helps, I am using Unity 5.5.2 in 2D Mode and Effect 8 from the Realistic Effects 4 Pack.
     
  2. Xarfai

    Xarfai

    Joined:
    Mar 28, 2017
    Posts:
    2
    In case anyone is ever interested in this, I solved this by attaching a script which uses a RayCast to determine the distance to the next collider and manually setting the lengthScale of the ParticleSystemRenderer. This made the Particle effect to appear slower the more close an object came to the player, I increased the ParticleSystems simulationSpeed the closer the object gets.

    If anyone has a better suggestion on how to solve this problem, please go ahead and tell me :)
     
  3. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    683
    I found a better solution if you're still interested. The problem is that you're stretch billboarding out from the origin of the particle forward. So I tried to find a way to stretch the billboard back the direction the particle came from. There doesn't seem to be a way to do that. So my solution follows:

    1. In the ParticleSystem Render settings, set the "Trail Material" to the material being used in the ParticleSystem.
    2. Set the ParticleSystem Renderer type to None.
    3. Enable the Trails setting in the Particle System.
    4. Make sure the Trails properties are as follows.

    This will move the bounds (the portion that handles collision) to the front of the visual effect. In reality you're not moving it, you're just making the visual effect become simulated behind the actual particle, instead of billboard stretching it out from the particle. With the bounds now in the front, when THAT portion hits the wall, it will do whatever you want it to do based on your ParticleSystem's Collision settings.
     
    ejsingson likes this.
  4. ejsingson

    ejsingson

    Joined:
    Aug 11, 2019
    Posts:
    3
    Sorry to bother, but could you reupload the image of your trails settings? I would really love to be able to use collisions with trails.
     
    DaDarkDan likes this.