# Passed pointer to another component arrives as nullptr

**URL:** <https://forums.unrealengine.com/t/passed-pointer-to-another-component-arrives-as-nullptr/379928>\
**Category:** Community & Industry Discussion\
**Tags:** deleted, unreal-engine, component, pointer, null, question\
**Created:** [December 21, 2016, 8:53pm UTC](https://forums.unrealengine.com/t/passed-pointer-to-another-component-arrives-as-nullptr/379928 "2016-12-21T20:53:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_e0de330b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e0de330b](https://forums.unrealengine.com/u/anonymous_user_e0de330b)\
**Post date:** [December 21, 2016, 8:53pm UTC](https://forums.unrealengine.com/t/passed-pointer-to-another-component-arrives-as-nullptr/379928/1 "2016-12-21T20:53:21Z")

</div>

Ok, now it gets slightly esoteric.

I have two components… one is called “Interactable” the other one “Interactor”.  
Both derive from SphereComponent.

I check collision between those two and if collision is found I call the “Select” function of the Interactable class.

```
void UInteractorComponent::OverlapBegin_Func(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	UInteractableComponent* Component = Cast<UInteractableComponent>(OtherComp);

	if (CurrentInteractable != Component)
	{
		UInteractorComponent* Myself = this;

		if (Myself == nullptr)
			UE_LOG(HugLogs, Error, TEXT("UInteractorComponent::OverlapBegin_Func -> this == NULL"));

		CurrentInteractable = Component;

		CurrentInteractable->Select(Myself);
	}
}

```

Now, this is the other side:

```
void UInteractableComponent::Select(UInteractorComponent* Source)
{
	if (Source == nullptr)
		UE_LOG(HugLogs, Error, TEXT("UInteractableComponent::Select -> Source == NULL"));

	IsSelected = true;

	OnSelected.Broadcast(Source);
}

```

And now the riddle. WHY on earth is this is the output:

```
HugLogs:Error: UInteractableComponent::Select -> Source == NULL
HugLogs:Error: UInteractableComponent::Select -> Source == NULL
HugLogs:Error: UInteractableComponent::Select -> Source == NULL
HugLogs:Error: UInteractableComponent::Select -> Source == NULL

```

The THIS pointer I pass is definitely not NULL. The debug message there is never printed.  
But the pointer that arrives at the called function is definitely NULL.

What happens to that pointer while it travels through Unreal? Why does it get deleted? And how?

Before you say it: Nothing else is calling that select function. This is the only code that calls select and I actually checked with a debug log that it is happening.

I need help. 😛

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e0de330b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e0de330b](https://forums.unrealengine.com/u/anonymous_user_e0de330b)\
**Post date:** [December 23, 2016, 6:34pm UTC](https://forums.unrealengine.com/t/passed-pointer-to-another-component-arrives-as-nullptr/379928/2 "2016-12-23T18:34:20Z")

</div>

Whatever it was, a complete deletion of Intermediate/Saved/Binary and project regeneration fixed it.
