试图将函数转换为 C++ 如何将目标更改为场景组件

trying to convert functions to c++ how do I change target to scene component

grapplecomponent.h

 protected:
    virtual void BeginPlay() override;
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        bool m_hooked;
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        bool m_hookfinished;
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
        FVector m_hook_location;
    UFUNCTION(BlueprintCallable)
        void m_set_visibility(const bool new_visibility, const bool propagate_to_children);
    UFUNCTION(BlueprintCallable)
        void m_setworldlocation(const FVector& new_location, const bool sweep, const bool teleport, FHitResult& sweep_hit_result);

grapplecomponent.cpp

void Agrapplecomponent:: m_set_visibility(const bool new_visibility, const bool propagate_to_children)
{
    
}

void Agrapplecomponent::m_setworldlocation(const FVector& new_location, const bool sweep, const bool teleport, FHitResult& sweep_hit_result)
{
    
} 

我不知道如何像普通蓝图函数一样将 m_setworldlocation 和 m_set_visibility 的目标更改为场景组件,我该如何解决这个问题?以 M 开头的东西被转换为 c++

SetVisibility 和 SetWorldLocation 函数已有 C++ 实现。

最好从 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);
}

更新

在蓝图中,将 GrappleHookCable 的名称更改为 BlueprintGrappleHookCable。保存并编译。关闭 UE。

在 {ProjectName} 中。build.cs 添加“CustomMeshComponent”

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "UMG", "CustomMeshComponent"});

字符:

//.h

#include "CustomMeshComponent.h"


UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly)
UCustomMeshComponent*   GrappleHookCable;

//.cpp

Construct
{
    GrappleHookCable = CreateDefaultSubobject<UCustomMeshComponent>(TEXT("GrappleHookCable"));
    GrappleHookCable->SetupAttachment(GetRootComponent());
}

编译。打开项目。打开蓝图。变量 -> 组件 -> 右键单击​​“BlueprintGrappleHookCable” -> 替换引用。

在“替换为”中找到“GrappleHookCable”。 打开“仅显示和替换来自...的结果”。 单击“在...中查找和替换引用”