# BlueprintNativeEvent function can't access blueprint variables?

**URL:** <https://forums.unrealengine.com/t/blueprintnativeevent-function-cant-access-blueprint-variables/1941022>\
**Category:** C++\
**Tags:** unreal-engine, question\
**Created:** [July 17, 2024, 7:23pm UTC](https://forums.unrealengine.com/t/blueprintnativeevent-function-cant-access-blueprint-variables/1941022 "2024-07-17T19:23:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sicko\_0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sicko\_0](https://forums.unrealengine.com/u/Sicko_0)\
**Post date:** [July 17, 2024, 7:23pm UTC](https://forums.unrealengine.com/t/blueprintnativeevent-function-cant-access-blueprint-variables/1941022/1 "2024-07-17T19:23:13Z")

</div>

I have a C++ UUserWidget class, and from that I derived a blueprint class.  
In the C++ class, I created a function and added the BlueprintNativeEvent Macro to it in order to be able to call the event from both c++ and blueprints and be able to add code from both.  
The event is being called from both C++ and blueprints perfectly but the problem is that any code executed in the event by C++ cannot access blueprint variables. I can compile both the C++ and blueprints, **but on runtime it is unable to access any blueprint-created variables and instead just gives off an error of “Accessed none”**.  
Am I misunderstanding how to use Blueprint Native Events or is there something else wrong?

**MyWidget.h:**

```auto
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Components/Widget.h"
#include "MyWidget.generated.h"

UCLASS()
class MYGAME_API UMyWidget : public UUserWidget
{
	GENERATED_BODY()

public:
	UMyWidget(const FObjectInitializer& ObjectInitializer);

        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Main Title")
        FText MainTitleText;

	UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "UI")
	void RefreshAll();
};

```

**MyWidget.cpp:**

```auto
#include "MyWidget.h"

UMyWidget::UMyWidget(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	RefreshAll();
}

void UMyWidget::RefreshAll_Implementation()
{
	GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Test Debug Message"));
}

```

**BP\_MyWidget** (Blueprint Derived Class of MyWidget):

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/9/c/c9ceea40a265ce93057de946e0cc1eb45c8e572a.png)  
(Main Title is a text block created in the blueprint class).

**Error On Runtime:**  
`Blueprint Runtime Error: "Accessed None trying to read property MainTitle". Node: SetText (Text) Graph: EventGraph Function: Execute Ubergraph BP Warning Widget Blueprint: BP_WarningWidget`

I’ve done some testing and this error also occurs on any blueprint-created variable used _ **ONLY WHEN C++ CALLS THE EVENT** _.  
I also replicated the same thing in another blueprint.

I would love some help, thanks!

---

<div class="post-metadata">

**Author:** ![RecourseDesign](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/recoursedesign/32/1194503_2.png) [@RecourseDesign](https://forums.unrealengine.com/u/RecourseDesign)\
**Post date:** [July 17, 2024, 7:32pm UTC](https://forums.unrealengine.com/t/blueprintnativeevent-function-cant-access-blueprint-variables/1941022/2 "2024-07-17T19:32:12Z")

</div>

Hi Sicko\_0

Where-ever possible, move your variables into the C++ class, otherwise you can crawl through the BP dictionary to find them like this post explains:

> [@How to access blueprint vars in c++?](https://forums.unrealengine.com/t/how-to-access-blueprint-vars-in-c/275331/4):
>
> UFloatProperty\* FloatProp = FindField(Object-\>GetClass(), PropertyName); if(FloatProp != NULL) { float\* FloatPtr = FloatProp-\>GetPropertyValue\_InContainer(Object); if(FloatPtr != NULL) { float MyFloat = \*FloatPtr; } } I got this working! I am using SetPropertyValue\_InContainer to update my foot placement system Is there an equivalent for UFloatProperty for vectors? I tried UVectorProperty to no avail slight_smile and where is the .h file for UFloatProperty? I bet I can find lot…

---

<div class="post-metadata">

**Author:** ![MagForceSeven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magforceseven/32/906563_2.png) [@MagForceSeven](https://forums.unrealengine.com/u/MagForceSeven)\
**Post date:** [July 17, 2024, 7:57pm UTC](https://forums.unrealengine.com/t/blueprintnativeevent-function-cant-access-blueprint-variables/1941022/3 "2024-07-17T19:57:17Z")

</div>

You’re calling `RefreshAll` from the constructor. The widget assigned to `MainTitle` won’t have been created yet. You shouldn’t make function calls like that from constructors in UE, you should only set default values. You’d want to call this from NativeConstruct.

---

<div class="post-metadata">

**Author:** ![Sicko\_0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sicko\_0](https://forums.unrealengine.com/u/Sicko_0)\
**Post date:** [July 18, 2024, 8:14am UTC](https://forums.unrealengine.com/t/blueprintnativeevent-function-cant-access-blueprint-variables/1941022/4 "2024-07-18T08:14:01Z")

</div>

Not sure how I didn’t think of this earlier! I stopped calling the RefreshAll() function from the constructor and instead somewhere else where I can guarantee that the Main Title had already been created and indeed it worked perfectly. (It will also work in the NativeConstruct)

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [August 17, 2024, 8:14am UTC](https://forums.unrealengine.com/t/blueprintnativeevent-function-cant-access-blueprint-variables/1941022/5 "2024-08-17T08:14:52Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
