Download

Getting UV coordinates from overlap

I need to translate the “hit location” of an OnComponentBeginOverlap event to UV coordinates for a very unorthodox fluid-like surface using Blueprint Render Targets. Everything is working, including a line trace from the camera and using the “Find Collision UV” node. However, as I understand that that node doesn’t work with overlap events (and as proven by trying it), I need to find another way. So far, it’s incredibly tedious trying to hack a line trace based on the hit location, since the actor is very close to the surface and can easily pass through and flip out the trace. I’ve tried the set up that comes with the original Blueprint Render Target sample, which uses the Invert Transform and Transform Location nodes, but the coordinates are way off when using my own mesh, which is why I’ve tried to use the Find Collision UV node. My vector math skills to try and solve that problem are also not that advanced.

So, no-one knows why the code with the Invert Transform and Transform Location nodes from the Render Target sample work there and not with my own Blueprint? Or a proper alternative to get the UV coordinates with an overlap?

The only thing I can come up with is to fire off a Line Trace with Begin Overlap, and somehow offsetting the starting and end points so the line trace goes from one side of the surface mesh to the other, but perpendicular to the mesh, so along its Forward Vector. What I did before was firing off a trace from the World Location of the Other Component (so the collision component of the Actor overlapping the surface) towards the Hit Location, but it doesn’t always work, probably because the starting and end points are too close to each other or behind the surface so it never hits.

I also want to use specific collision components so I have complete control over how Actors create the waves. That isn’t difficult, since I would just use a custom Object/Trace Channel, which is otherwise ignored except by the surface mesh and the collision components. The intended effect is then that when a collision component overlaps the surface, it creates the ripples. Does OnComponentBeginOverlap also work for each collision component of a single Actor? So if an object has two Sphere Collision components attached to it, does each component individually fire the Overlap events or only the first one? Basically, it should fire a single Line Trace from the World Location of each overlapping component, with the starting and end points offset so the trace actually hits, regardless of the direction the Actor is passing through. And of course any (relatively small) number of Actors should be able to create ripples as they either pass through or just sit there overlapping the surface.

I do not know the sample you mentioned but here’s what I’ve been using:

Untitled.png

Inverse transform gives you local space but you still need to obtain 0-1 range. The returned GridHitLoc is fed to a material vector param, I then use it as V2.
There might be a better way, not an expert on materials.

Thank you, it’s working now, though I have to use the Value Z from the Inverse Transform Location, probably because the surface mesh was modelled vertically with X forward/up instead of Z up. But then it works completely.