Can't get my Laser VFX to be visible without colliding with objects

Hello,
I made a laser VFX following Gabriel Aguiar videos, and at the end of his video he made the vfx have effects when colliding with an object.

I managed to make that effect using vfx property binder raycast and it worked.

Problem is, now if the laser is not colliding with an object it disappears, and I’m not sure what to change to have the desired effect. Also, I tried removing collision from the core beam effect, but it made the laser go through objects which is not what I want.

Any help would be appreciated!

Morning. I’ve been able to find the tutorial you were referring to. I think that It’s actually not from Gabriel Aguiar but from Zii and here is the video link for those who are interested:

You can also get the Source file of the tutorial here

I’ve didn’t watch the full video but from what I can see here, when the “Hit” is false, you’re interpolating between the VFX Local Position (0,0,0) and VFX Local Position (0,0,0).

So if the Hit failed as the Max Ray distance was too short or no Collider was found, all your particle’s position are in Local (0,0,0).

So what you can do instead of setting (0,0,0) in the false property of your branch operator is too wire a newly computed position. You can, for example, use:

LocalPosition (0,0,0) + Raycast Direction * Raycast Max distance;

In my case, the Ray Cast Max distance is equal to 5. This means that my Laser beam will be drawn between the local position and the LocalPos + (RaycastHit Dir * 5)*
Unity_XYDcLOFDxq
The Laser is always drawn. Note that it’s best to keep in sync the Max Distance property with the Max Distance of the Raycast in the property binder.

Now, something that can be improved from the video tutorial is the spawning of particles on the Hit Position. Don’t hesitate to use your “Hit” boolean property to condition the spawning of your other systems. This way, you’ll only spawn particles if the Hit succeeded.


Here’s an example of a Spark system that only spawns particles if the Hit is true. The Hit Property is used to drive the “Activation port” that allows to activate/deactivate a block dynamically.

To help you and others that might found this Topic, I’m joining a small package with my VFX Graph. Note that it has been made with Unity 6. This means that you won’t be able to open it in a previous Unity version. But you should be able to open it in Unity 6 for both URP or HDRP. From there you can easily replicate the setup with some minor adjustment.

Here are the results of the VFX:
Laser Beam:

Sparks:

Fake Decaks:

Smoke:

Unity_QJrTxxUan7

Have a beautiful and sunny day.
VFXG_LaserBeam_Raycast.unitypackage (1.9 MB)

1 Like

Hi thanks so much for answering I actually figured out the new computed position part when it’s false as it turned out I totally missed that ).
I made the laser beam itself from gabriel’s video then went to see how to use collisions on it from Zii’s tutorial so both actually.
I will benefit a lot from the hit effect you made really as the one I tried to make was not nice at all :smiley:

Glad to know you were able to figured it out. :clap: I forgot to mention a small mistake in the tutorial. To get a proper distribution for your laser beam, you should use:

ParticleindexinStrip / (ParticleCountinStrip - 1.0f)

ParticleIndexInStrip always starts at 0, so you need to subtract 1 to the ParticleCountInStrip

Ex: For 128 spawned particles, the ParticleIndexinStrip will range between 0-127.

Don’t hesitate to share your result with the community. Always nice to see users do cool stuff with the tools :wink: . Have a great day