Download

Decal on Particle Collision?

Hi all
this is my first post, I am working on a small student game and would like to know how I could spawn blood decals on particle collisions, I would really appreciate it if you guys could help me out with this or point me in the right direction.
Cheers.
Josh

The particle emitter in question has to have a collision module to detect collisions and then in blueprints you can pick up from the Collision event on that particle emitter and get the hit location of the collisions and then spawn decals

Matt

Thanks for the help Matt.
I have added collision and the blood kills on collision, I have setup this in Blueprint if you don’t mind having a look c49832c1ebf33a899832092fe5c1ff95170609e7.png
no decal is spawning on collision. at this time i am still trying different methods and nodes, but like the idea that the community can help while searching for the answer.
Cheers mate.
Josh

Sorry for not checking back with you, I don’t come here frequently but I’m trying to more often now.

First you need to approach the problem in the way that well best show you what is not working. Instead of spawning a decal at that location, try printing the location of the collisions. If they are coming back with the locations of where your blood is, then your decal isn’t working or spawning in the right direction.

By the looks of your code, you would not be able to see your decal because of it’s rotation, because you’re telling it to be perpendicular to the surface it is hitting. Try spawning objects to test, if they work adjust your rotation accordingly.

It would be nice if we could have decals as particles, just as we can have meshes and point lights. Could also use to simulate fluids flowing across a surface.

You actually can do that manually by using a projection type material. Try using the node “world position behind translucency”. You can use this to make any particle seem like a decal. Then you could do a spheremask with the particle pixeldepth and scenedepth to only render the projection when the particle is close to an opaque object.

That still wouldn’t give us the ability to change lighting characteristics like roughness and surface normal, since the deferred lighting is over by the time our projected translucent material is processed.

Yes that is a great point. I will ask around next week to see if there is some way to actually do decal particles. I am not sure how difficult it would be.

Any update on this?

I got this working actually. Firstly you don’t need to create a Dynamic Material Instance. Secondly, use the Direction for the rotation not the Normal and Thirdly, make the XYZ values for the decal scale the same. This avoids stretching on different angles in your environment. If you want to stop the decals from overlaying on top of the player, just open your pawn, select it’s mesh and uncheck “Receive Decals” in the details panel.

It requires some C++ to create a new particle editor module, but is actually pretty straightforward.
Here is what I came up with:

https://youtube.com/watch?v=RPcB9GcQYi4

The biggest problems is how to set up the correct rotation, as decals are rather ugly when rotated the wrong way.

Any chance you could share how you accomplished that? :slight_smile:

Well, you can just check out the particle plugin (75% off in the sale!): https://www.unrealengine.com/marketplace/particle-editor-extension

But the gist of it is this:
I created a new decal component (by subclassing UDecalComponent) which holds the particle module ID that created it.
I then created a new particle module (by subclassing UAbstractParticleModule) which when updating particles looks at the components attached to its parent to find all the custom decals. It then destroys excess components or creates new ones as necessary (new decal components are attached to the module’s parent so they can be gathered again on the next update).

The custom decal holds the module ID to prevent different modules interfering with each others decals :slight_smile: