Set Render Custom Depth on StaticMeshComponents in C++

I think SetRenderCustomDepth is for a static mesh component, so in your code it would look like:

UStaticMeshComponent* StaticMeshComponent = Components[i];

Hi there guys, i’m trying to create an outline for interacting with my actors…
I created a component, which implements an interface.

But i’m having trouble setting the static mesh component on the actor, i just can’t get it.

this is the code snippet:

void UHighlightsOnFocus::OnStartFocus()
	TArray<UStaticMeshComponent*> Components;
	for (int32 i = 0; i < Components.Num(); i++)
		UStaticMeshComponent* StaticMeshComponent = Components[i];
		UStaticMesh* StaticMesh = StaticMeshComponent->StaticMesh;

		//Here i would like to highlight the component
            //How do i call the : SetRenderCustomDepth?

SetRenderCustomDepth is part of UPrimitiveComponent. Here’s the doc for it: UPrimitiveComponent::SetRenderCustomDepth | Unreal Engine Documentation

UStaticMeshComponent is a child of UPrimitiveComponent so you should be able to call this function no problem in the snippet you provided. :slight_smile: