Add and use cable component (C++ project)?

Add and use cable component (C++ project)?
At runtime in debug editor mode (Win 64) the following breakpoint is triggered when trying to use a cable component in a c++ project.

UE4Editor.exe has triggered a breakpoint.
[Inline Frame] UE4Editor-Engine.dll!FWindowsPlatformMisc::DebugBreak() Line 56	C++	Symbols loaded.

I’m trying to create a grapple that is attached to a character. The following code has been placed in a character class. Is this setup the expected setup when using the cable component?

Header file

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = cable, meta = (AllowPrivateAccess = "true"))
		class UCableComponent* Cable;

Source file

#include "CableComponent.h"

Constructor

Cable = CreateDefaultSubobject<UCableComponent>(TEXT("Cable"));
Cable->AttachToComponent(this->GetRootComponent(), FAttachmentTransformRules::KeepWorldTransform);
Cable->SetAttachEndTo(this, RootComponent->GetDefaultSceneRootVariableName());

In the build.cs file

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "CableComponent" });
PrivateDependencyModuleNames.AddRange(new string[] { "CableComponent" })

;

2 Likes

Thank you very much, it works for me

Can you point me to the documentation for Cable Component c++ code? How can I add a cable component to my Actor class in c++?

It’s like any other component, you just need to configure it according to the cablecomponent specific requirements. I suggest doing it in blueprints first to get a feel what’s required.
Also, because it is a plugin, you need to add it to your build.cs file. 90% of the code required is in this post

I don’t know exactly without seeing the code. Is your goal to attach it before the game starts or on beginplay? Try adding the attachment logic to beginplay and see if it works. It would be good if you could share the code also

Thank you so much. I did that and it’s working. Although, when I derive a BP class from the cpp class and add it to the scene, the cable end point is attached to the world (0, 0, 0) even though in the BP class it is attached to my static mesh correctly. Any ideas about what parameters I might have to change?