Running Project in C++ triggers breakpoints

Hi,

I’ve been trying to create a custom component through C++ to add it in my game. My concept is to create a custom component that contains some other sub-components. I am using Unreal Engine version 4.5.1. No errors appear but when i try to run the code, it triggers some breakpoints although i don’t have any breakpoints set in my code.

My .h file is:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Components/ActorComponent.h"
#include "GameWallComponent.generated.h"

/**
 * 
 */
// Game Wall Component (Destructible)
UCLASS(ClassGroup = GameComponents, editinlinenew, meta = (BlueprintSpawnableComponent), hidecategories = ("Lighting|Sockets|Base|Physics"))
class THE3DPERSON_CPP_API UGameWallComponent : public USceneComponent
{
	GENERATED_UCLASS_BODY()

	protected:
		
		UPROPERTY(EditAnywhere, Category = "WallProperties")
		int32 wallLife;

		UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Mesh)
		TSubobjectPtr<class UStaticMeshComponent> WallStaticMesh;

	public:
		UFUNCTION(Category = "Events")
		void OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
		
};

and my .cpp file is:

// Fill out your copyright notice in the Description page of Project Settings.

#include "The3DPerson_cpp.h"
#include "GameWallComponent.h"
#include "GenericCannonBall.h"


UGameWallComponent::UGameWallComponent(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	WallStaticMesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("StaticMesh"));
	WallStaticMesh->AttachTo(this);
	WallStaticMesh->SetRelativeScale3D(FVector(1, 1, 1));
	WallStaticMesh->OnComponentHit.AddDynamic(this, &UGameWallComponent::OnHit);
	WallStaticMesh->RegisterComponent();

	wallLife = 3;
}


void UGameWallComponent::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
	AGenericCannonBall* p = Cast<AGenericCannonBall>(OtherActor);
	if (p) {
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, "Hitted C++ Target");
	}
}

When i run my code it triggers a breakpoint several times in the “WallStaticMesh->RegisterComponent();”. I do not know why. If i click on Continue the editor and game runs fine.

My Visual Studio Log just before the breakpoint is:

UE4Editor.exe' (Win32): Loaded 'C:\Windows\System32\atl.dll'. Symbols loaded.
'UE4Editor.exe' (Win32): Loaded 'C:\Windows\System32\mfplat.dll'. Symbols loaded.
'UE4Editor.exe' (Win32): Loaded 'C:\Windows\System32\avrt.dll'. Symbols loaded.
'UE4Editor.exe' (Win32): Loaded 'C:\Windows\System32\ksuser.dll'. Symbols loaded.
'UE4Editor.exe' (Win32): Loaded 'C:\Windows\System32\MFPlay.dll'. Symbols loaded.
'UE4Editor.exe' (Win32): Loaded 'C:\Program Files\Unreal Engine\4.5\Engine\Plugins\Runtime\WindowsMoviePlayer\Binaries\Win64\UE4Editor-WindowsMoviePlayer.dll'. Cannot find or open the PDB file.
'UE4Editor.exe' (Win32): Loaded 'C:\Program Files\Unreal Engine\4.5\Engine\Plugins\2D\Paper2D\Binaries\Win64\UE4Editor-Paper2D.dll'. Cannot find or open the PDB file.
'UE4Editor.exe' (Win32): Loaded 'C:\Program Files\Unreal Engine\4.5\Engine\Plugins\Messaging\UdpMessaging\Binaries\Win64\UE4Editor-UdpMessaging.dll'. Cannot find or open the PDB file.
[2014.11.02-10.23.22:208][  0]UdpMessaging: Initializing bridge on interface 0.0.0.0:0 to multicast group 230.0.0.1:6666.
'UE4Editor.exe' (Win32): Loaded 'C:\Windows\System32\WSHTCPIP.DLL'. Symbols loaded.
'UE4Editor.exe' (Win32): Loaded 'C:\Program Files\Unreal Engine\4.5\Engine\Plugins\ScriptPlugin\Binaries\Win64\UE4Editor-ScriptPlugin.dll'. Cannot find or open the PDB file.
'UE4Editor.exe' (Win32): Loaded 'C:\Users\LUFFY-KUN\Documents\Unreal Projects\The3DPerson_cpp\Binaries\Win64\UE4Editor-The3DPerson_cpp.dll'. Symbols loaded.
Ensure condition failed: GetOwner() && GetOwner()->() [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.5\Engine\Source\Runtime\Engine\Private\ActorComponent.cpp] [Line: 623] 

UE4Editor.exe has triggered a breakpoint.

Thanks in advance.

I think this asset is called for default object for your class because this default object doesn’t have an Owner.

I wonder why you even calling register component?

if WallStaticMesh is only component set it as root component insted of register

RootComponent = WallStaticMesh;

as far as i know you don’t need to register components, you use addcomponent instad, but root component is added automaticlly so you don’t need to do that either, only when you got non-root components

As for break point, where it actully breaks?

Sorry but a am still a newbie regarding Unreal Engine C++ programming. So the register component is not needed? What do you mean by default object? But is there a way to disable these breakpoint triggering?

Thanks a lot i will try it out! :slight_smile: