[New Wiki] How to get UV hit information back from Line Traces in UE4!

I haven’t tried this yet, but if you can get something like this to work please share the code.
I will probably look into this in a few weeks, when I am finished with the current milestone

Here are the positions in the code at StaticMesh.cpp : Line 290



	// On cooked platforms we never need the resource data.
	// TODO: Not needed in uncooked games either after PostLoad!
	bool bNeedsCPUAccess = !FPlatformProperties::RequiresCookedData();


	static FORCEINLINE bool RequiresCookedData( )
	{
		return !HAS_EDITOR_DATA;
	}

I would rather prefer to have bNeedsCPUAccess as UPROPERTY variable, so you can configure the assets according to your own needs.
Maybe we should file this as a feature request as it is a common thing you need in many scenarios.

BTW guys, I found a good answer about how to calculate the UVs when you have the barycentric coordinates. This of course doesn’t help with the issue of the UV data being cooked out, but I thought it might be useful for those that have found a workaround and are moving onto the next step: Calculate UV coordinates of 3D point on plane of mesh's triangle - Unity Answers

Thank you for sharing this link!

Will investigate at my nearest opportunity

:slight_smile:

Rama

Looking forward to it, you’re a community hero.

So i guess if i want to modify a texture to paint a splatter mark or something similar on a texture from a line trace hit, i would need c++ along with the math described in that link? None of this will be doable with current blueprint nodes?

Hi everyone,

Rama, thank you for your contribution!

It looks like as of 4.13, a Find Collision UV node was added.
Ref: Unreal 4.13 Notes, CTRL-F “NEW: TEXTURE COORDINATES FROM LINE TRACES”

You can use a Line Trace hit result to find the UV that was hit. But make sure to do the following:

  1. Under Project Settings > Engine > Physics > Optimization, enable “Support UV From Hit Results”. This enables the feature but uses more CPU to store the UV information.
  2. When performing the Line Trace, ensure, “Trace Complex” is checked.

almost 2 years later… but okay…

Do you know of any way i could use this on landscapes?