Exposing scene component to blueprints

Hello Everyone!

So i’m relatively new to Unreal C++ and im having some issues exposing some scene components to blueprints.

I have a scene component which i want to use to indicate a specific point in a wheeled vehicle, So i create it in C++

  UPROPERTY(Category = AI, VisibleInstanceOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
    	USceneComponent* FrontLineTracePoint;

ABuggyPawn::ABuggyPawn(const FObjectInitializer& ObjectInitializer) : 
	Super(ObjectInitializer)
{

	FrontLineTracePoint = CreateDefaultSubobject<USceneComponent>(TEXT("FrontLineTracePoint"));
	FrontLineTracePoint->SetupAttachment(RootComponent);
}

But when i click on the component in the blueprint the details panel doesn’t display, Ive tried every descriptor i can think of to display the details but to no luck. i would like to be able to access the transform of the scene component.

Any help would be greatly appreciated,

Thanks

It seems to me the VisibleInstanceOnly specifier is probably not what you’re looking for. Here’s the description of that specifier from the UE4 documentation:

[VisibleInstanceOnly] Indicates that this property is only visible in property windows for instances, not for archetypes, and cannot be edited. This Specifier is incompatible with any of the “Edit” Specifiers.

I suggest removing that specifier and using either EditDefaultsOnly or even EditAnywhere just to be thorough. So your new UPROPERTY macro would look more like this:

UPROPERTY(Category = AI, EditDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))

I also suggest closing the editor and re-opening it after recompiling, because sometimes reflection changes like this don’t always update perfectly via hot-reloading.

Hopefully this helps with your issue and gets you moving forward again! If you’re curious about the other property specifiers, the docs page on the topic is pretty handy.

Best of luck!

Hey Batch,

Thanks for the reply, I tired EditDefaultsOnly and it worked but it exposed the pointer which is something I don’t want to allow, so I ended up using VisibleDefaultsOnly which works the way I wanted but it is not letting me see the Location and Rotation of the scene component but when I do the exact same thing in blueprints “AddComponent>SceneComponent” it shows the Location and Rotation, is there a UPROPERTY() tag I’m missing to allow this?

Hey again. Just changed my screen name, but same person, following up where we left off earlier.

I’m not sure what you mean by you not wanting to allow “exposing the pointer”. (Are you talking about preventing other C++ classes from modifying the address/reference of your FrontLineTracePoint pointer?) Could you describe what you mean in another way?

I have a hunch that the EditDefaultsOnly specifier is actually what would work best for your situation, but let’s work through the other questions/issues and see what we can figure out!

Hey!

Thanks again for getting back to me again, I just realized I asked this question on a different account but it’s still the OP, MB.

So essentially if I use EditDefaultsOnly I get this:

I don’t want people to be able to modify what the pointer points to, I want it the same as it would show if I created the scene component from blueprints I.E: This

When I use VisibleDefaultsOnly I get this:

which is almost what I want but IDK why it doesn’t show Location and Rotation, which is what I’m trying to display.

Hope that explains it better,

Thanks again.

Well, first off, I gave you bad advice! You’re right that VisibleDefaultsOnly or VisibleAnywhere is better suited for UPROPERTY pointers like the ones you’re dealing with. One glance at the engine source code quickly proved that I was thinking the wrong way. Sorry about that!

That’s what I get for trying to give UE4 programming advice off the top of my head after midnight.

Anyway, I did some playing around in the editor and in code, and there’s gotta be something else going on that’s giving you that undesired behavior. Because, using a blank actor as a starting point, I was able to get everything hooked up and working as expected using the VisibleAnywhere specifier.

So this is a long shot, and may not even be relevant to you depending on how you’ve set up your pawn class, but maybe you aren’t explicitly setting your “Mesh” component to be the RootComponent of your actor?

The reason I mention this is, during my experiments, at first I got the same results you showed in the first image in your reply. But after I remembered to explicitly set the root component, and then attach the other components to that root, the issue went away and everything showed up properly.

Again, it’s a long shot, and may not be the answer in your case, but I thought I’d mention it.

Otherwise, if that doesn’t fix it, I’m out of ideas unless you’re willing to share more of your pawn’s header and constructor, so I can compare what you’ve got to what I just put together.

Fantastic! So glad that did the trick!

Yes! that was exactly that, Nice longshot lol, I’ve been banging my head with this for almost 2 days now lol.

Thanks Again for the help! It would’ve taken me quite a long time to figure this out on my own