trying to convert functions to c++ how do I change target to scene component
The SetVisibility and SetWorldLocation functions already have a C ++ implementation.
Better to call the entire function from C ++:
//.h
UFUNCTION(BlueprintCallable)
void StopGrapple();
//.cpp
void Agrapplecomponent::StopGrapple()
{
FVector Location(0.f, 0.f, 0.f);
m_hooked = false;
m_hookfinished = false;
GrappleHookCable->SetVisibility(false);
GrappleHookCable->SetWorldLocation(Location);
}
Update
In the Blueprint, change the name of the GrappleHookCable to BlueprintGrappleHookCable. Save and Compile. Close UE.
In {ProjectName}.build.cs add "CustomMeshComponent"
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "UMG", "CustomMeshComponent"});
Character:
//.h
#include "CustomMeshComponent.h"
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly)
UCustomMeshComponent* GrappleHookCable;
//.cpp
Construct
{
GrappleHookCable = CreateDefaultSubobject<UCustomMeshComponent>(TEXT("GrappleHookCable"));
GrappleHookCable->SetupAttachment(GetRootComponent());
}
Compile. Open project. Open Blueprint. Variables -> Components -> Right click "BlueprintGrappleHookCable" -> Replace Reference.
Find "GrappleHookCable" in "Replace with". Turn on "Only show and replace result from ...". Click "Find and Replace References in ..."