# Component pointer reset to null after assigned. UPROPERTY doesnt fix.

**URL:** <https://forums.unrealengine.com/t/component-pointer-reset-to-null-after-assigned-uproperty-doesnt-fix/754971>\
**Category:** C++\
**Tags:** bug, unreal-engine, Components, question, CPP\
**Created:** [January 23, 2023, 12:14am UTC](https://forums.unrealengine.com/t/component-pointer-reset-to-null-after-assigned-uproperty-doesnt-fix/754971 "2023-01-23T00:14:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swogers](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Swogers](https://forums.unrealengine.com/u/Swogers)\
**Post date:** [January 23, 2023, 12:14am UTC](https://forums.unrealengine.com/t/component-pointer-reset-to-null-after-assigned-uproperty-doesnt-fix/754971/1 "2023-01-23T00:14:50Z")

</div>

Im trying to make an HTTPComponent attach to a floating pawn.

My header file for the pawn looks like this:

```auto
#include "InputActionValue.h"
#include "Player/FLCameraController.h"
#include "Vehicle/VehicleComp.h"
#include "Inventory/InventoryComp.h"
#include "Networking/HTTPComp.h"
#include "CoreMinimal.h"
#include "EnhancedInputComponent.h"
#include "GameFramework/Pawn.h"
#include "Blueprint/UserWidget.h"
#include "FLCameraPawn.generated.h"
public:
	// Sets default values for this pawn's properties
	AFLCameraPawn();
virtual void Tick(float DeltaSeconds) override;
	UPROPERTY(EditAnywhere,BlueprintReadOnly)
		APlayerController* AsPlayerController;
	UPROPERTY(EditAnywhere,BlueprintReadOnly)
		AFLCameraController* AsFLCameraController;
	UPROPERTY(EditAnywhere,BlueprintReadWrite)//important component. 
		UHTTPComp* HTTPCompVariable;

```

The cpp file for the pawn looks like this:

```auto
AFLCameraPawn::AFLCameraPawn()
{
	PrimaryActorTick.bCanEverTick = true;
	AActor::SetReplicateMovement(true);
	SetReplicates(true);
	bAlwaysRelevant = true;
	HTTPCompVariable = CreateDefaultSubobject<UHTTPComp>(TEXT("HTTPComp"));
}
void AFLCameraPawn::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);
	if(bDebugMode)
	{
		if(HTTPCompVariable)
		{
			GEngine->AddOnScreenDebugMessage(7, 0.1f, FColor::Red, FString::Printf(TEXT("Is replacement host: %s"),(HTTPCompVariable->bIsReplacementHost ? TEXT("true"):TEXT("false"))));
		}
	}
}

```

The HTTP has 2 functions and a simple boolean variable. Nothing worth showing here unless its detrimental to solving the problem.

The problem:  
HTTPCompVariable returns invalid after creation in constructor. THIS TIME, i HAVE used UPROPERTY(), UPROPETY(EditAnywhere, VisibleAnywhere, EditDefaultsOnly, EditAnywhere, BlueprintReadWrite, AND BlueprintReadOnly) Basically every possible combination of UPROPERTY onto pointers. I have also tried removing the UPROPERTY entirely.

Please, any help is much appreciated. I cant exactly work on UE5 if i cant even use components.

---

<div class="post-metadata">

**Author:** ![Alizia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alizia](https://forums.unrealengine.com/u/Alizia)\
**Post date:** [January 23, 2023, 12:26am UTC](https://forums.unrealengine.com/t/component-pointer-reset-to-null-after-assigned-uproperty-doesnt-fix/754971/2 "2023-01-23T00:26:33Z")

</div>

Have you added the include for this httpComp class ?

Also, this will only print if bIsReplacementHost is true. Better use “IsValid()” then a simple if too.

---

<div class="post-metadata">

**Author:** ![Swogers](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Swogers](https://forums.unrealengine.com/u/Swogers)\
**Post date:** [January 23, 2023, 12:39am UTC](https://forums.unrealengine.com/t/component-pointer-reset-to-null-after-assigned-uproperty-doesnt-fix/754971/3 "2023-01-23T00:39:53Z")

</div>

I’ve modified it so that you see the includes on the header file.

Due to the post being too long, i trimmed off the Else statement that was triggering on if(HTTPCompVariable). It would constantly say “Comp is invalid” every tick and was very annoying. instead, when running, i look out to see if the variable displays on screen. I removed the if and tested it and got the same result

---

<div class="post-metadata">

**Author:** ![Alizia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alizia](https://forums.unrealengine.com/u/Alizia)\
**Post date:** [January 23, 2023, 12:43am UTC](https://forums.unrealengine.com/t/component-pointer-reset-to-null-after-assigned-uproperty-doesnt-fix/754971/4 "2023-01-23T00:43:56Z")

</div>

The code seems correct to me. Have you tried to reparent your blueprint class ?

---

<div class="post-metadata">

**Author:** ![Swogers](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Swogers](https://forums.unrealengine.com/u/Swogers)\
**Post date:** [January 23, 2023, 2:32am UTC](https://forums.unrealengine.com/t/component-pointer-reset-to-null-after-assigned-uproperty-doesnt-fix/754971/5 "2023-01-23T02:32:27Z")

</div>

I just switched to a diff parent class and switched back and now it works. Must be some kind of bug. thanks for the help
