Can't access UActorComponent variables in Blueprint

In C++, I created the following UActorComponent

UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent, RestrictedToClasses = "APawn"))
class HOTELSIMTEST_API UMouseRaycaster : public UActorComponent
{
	GENERATED_BODY()

public:	
	UMouseRaycaster();
	
protected:
	//Raycast
	UFUNCTION(Category = Raycasting, BlueprintCallable)
	FHitResult RaycastActor();
	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Raycasting)
		AActor* currentInteractable;
	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Raycasting)
		AActor* selectedInteractable;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Raycasting, meta = (AllowPrivateAccess = "true"))
		float raycastDistance = 2000.0f;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Raycasting, meta = (AllowPrivateAccess = "true"))
		TEnumAsByte<ECollisionChannel> channel = TEnumAsByte<ECollisionChannel>(ECollisionChannel::ECC_Visibility);
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Raycasting, meta = (AllowPrivateAccess = "true"))
		bool raycastingEnabled = true;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Raycasting)
		bool debugRaycast = false;

public:
	//Get/Set Variables
	UFUNCTION(BlueprintCallable, Category = Raycasting)
		void SetRaycastingEnables(bool set);
	UFUNCTION(BlueprintPure, Category = Raycasting)
		bool GetRaycastingEnables();
	UFUNCTION(BlueprintCallable, Category = Raycasting)
		void SetChannel(ECollisionChannel set);
	UFUNCTION(BlueprintPure, Category = Raycasting)
		ECollisionChannel GetChannel();
	UFUNCTION(BlueprintCallable, Category = Raycasting)
		void SetRaycastDistance(float set = 2000.0f);
	UFUNCTION(BlueprintPure, Category = Raycasting)
		float GetRaycastDistance();
};

(Some functions irrelevant to this question are left out)
The component works as it should when attached, which is it shoots a line trace from the mouse position. However, I want to access the variable raycastingEnabled in blueprints. They show up fine in the details panel and editor, but no matter what UPROPERTY specifiers I add, or changing variables to public, or adding public get/set functions instead, I can’t access anything from in the component. No where that I’ve looked says you can’t access ActorComponent properties, so I’m not sure where I’m going wrong (or maybe the documentation is just awful as always).

What I want to do is have two of these components so that they can line trace on different channels. They would only be enabled at certain times, so I want to put in blueprint that when a specific trigger is activated I reenable the RaycasterTiles, and then when it’s finished, disable it so only RaycasterObjects is active. Regardless if there is a better way to do this, I’m still flabbergasted as to why I can’t access functions and variables from actor components in blueprints.

Just to test it out, I made UMouseRaycaster Blueprintable and BlueprintType so that I can make a blueprint class from it. Still can’t access any of the BlueprintReadWrite variables from a blueprint that directly inherits from it.

I made all the functions BlueprintNativeEvents, I added _Implementation versions of each, I overrided them in the Blueprints and made them call their parent functions. Still can’t access anything from other blueprints.

I did make them public and it still didn’t work. That’s why what I posted has public Get/Set functions to try and circumvent it, but still no luck.

You try to make them public ? If you trying to access them directly i don’t see point
why you got them protected

Hi,
try to set VisibleAnywhere in UPROPERTY. Check the below snippet. It should work.

345508-unreal-help.png

You declared it as Category=“Raycasting”.

Tick ‘Context sensitive’, and scroll down to Variables > Raycasting, it’ll be there.