Download

Get Landscape Material from Trace

Am running a trace to get the landscape material from HitInfo but it always returns DefaultPhysicalMaterial. I’ve tried some variations on the trace but it always returns on Landscape DefaultPhysicalMaterial, it works fine if its not a landscape.

If I open landscape properties I can see the value for the Default Phys Material is none. Maybe this needs to change but don’t seem to be able to update it ? Also within the landscape paint tool theres a similar property but I can’t seem to update it either (probably tied in with the material file import).

Does anyone know if this works in UDK or if there’s a fix/workaround?

Thanks.





var UTPhysicalMaterialProperty PhysicalProperty;


///your function///

        local vector loc, norm, end;
	local TraceHitInfo hitInfo;
	local Actor traceHit;

        end = Location;
	end.z = Location.z -100;


traceHit = trace(loc, norm, end, Location, true,, hitInfo);

PhysicalProperty = UTPhysicalMaterialProperty(HitInfo.PhysMaterial.GetPhysicalMaterialProperty(class'UTPhysicalMaterialProperty'));





from my aventador.adapted from some of teglegs code.

edit:may have misunderstood.were you after the material or physmaterial?

Thanks, yeah sorry wasn’t totally clear. I do want the Material returned when on Landscape. It just doesn’t seem to work. Wonder if its because on landscape there can be a blend of materials ?

I had already tried the following



		Extent = vect(40,40,40);
		TraceDest = Location;
		TraceDest.z = Location.z -300;

		Trace(HitLocation, HitNormal, TraceDest, Location, true, Extent, HitInfo);
         	`log("&&&&&&&&&&&&&&&&&&&& material 0 %%%%%%%%%%%%%%%%%%%%"$string(HitInfo.PhysMaterial)); 
                `log("&&&&&&&&&&&&&&&&&&&& material 1 %%%%%%%%%%%%%%%%%%%%"$string(HitInfo.Material)); 


           TraceActor = Trace( out_HitLocation, out_HitNormal,TraceDest, TraceStart, false, Extent, HitInfo );
          PhysicalProperty = UTPhysicalMaterialProperty(HitInfo.PhysMaterial.GetPhysicalMaterialProperty(class'UTPhysicalMaterial Property'));
     
          `log("&&&&&&&&&&&&&&&&&&&& material 2 %%%%%%%%%%%%%%%%%%%%"$PhysicalProperty); 

// when the player moves along the landscape I get these values returned in the log.  I'd like to get the material name that they are on


/// Log :
[0083.40] ScriptLog: &&&&&&&&&&&&&&&&&&&& material 0 %%%%%%%%%%%%%%%%%%%%%DefaultPhysicalMaterial
[0083.40] ScriptLog: &&&&&&&&&&&&&&&&&&&& material 1 %%%%%%%%%%%%%%%%%%%%None
[0083.40] ScriptLog: &&&&&&&&&&&&&&&&&&&& material 2 %%%%%%%%%%%%%%%%%%%%None
	


a bit hacky,but if you create a physmat with the same name as the material layer then something like




if (PhysicalProperty.MaterialType == 'Stone')              
	{
              thematerial = stonematerial;
        }


and so on.

but did you say you cant assign physmats in the landscape tool.

for me.i just select the physmat in the content browser and in the edit mode of the landscape tool hit the little arrow next to the layer.

Worked out why the phys material wasn’t assigning in the Landscape tool. So thought I’d repaint the areas of the landscape I’m interested in with the phys material set to see if that would work but the trace just returns the value “DefaultPhysicalMaterial”.

Deleted the material from the paint tool, readded and repainted onto landscape and still doesn’t work. I noticed this in a google search, Default physical material BUG on landscape patches - UE4 AnswerHub

Normally I ignore UE4 issues on searches but as its with the lansdscape tool and I assume its the same landscape tool UDK uses (I’d guess different version) maybe I’ve hit an earlier iteration of the UE4 issue … Anyway decided to add some triggers to control what I wanted to do with the material, whilst not ideal and they don’t encompass all areas it will suffice for now.

Thanks for the suggestions Gaz.

which udk version are you using?

July 2012 …