Unreal c++ Call a void from a Actor With LineTrace

Unreal c++ Call a void from a Actor With LineTrace

Im new to c++ (use to c#) and trying to call a void on a Actor when it gets hit with a raycast and send it the cords. Heres the script header that im trying to call "EditMesh" on (near the bottom)

Im new to c++ (use to c#) and trying to call a void on a Actor when it gets hit with a raycast and send it the cords. Heres the script header that im trying to call "EditMesh" on (near the bottom)

 #pragma once
    #include "CoreMinimal.h"
    #include "GameFramework/Actor.h"
    #include "ProceduralMeshComponent.h"
    //#include "Core.h"
    #include "Chunk.generated.h"




UCLASS()
class VOXELWARS_API AChunk : public AActor 
{

    GENERATED_BODY()

public:
    // Sets default values for this actor's properties
    AChunk();

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;


public:
    // Called every frame
    //virtual void Tick(float DeltaTime) override;

    //UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Default)
    //  UMaterialInterface* TheMaterial;
    UPROPERTY(EditAnywhere)
        AChunk* ChunkRef; 

    UPROPERTY(EditAnywhere)
        class UMaterialInterface* OnMaterial;

    UPROPERTY(VisibleAnywhere)
UProceduralMeshComponent * mesh;
    UPROPERTY(VisibleAnywhere)
int faceCount = 0;
TArray<FVector> vertices;
UPROPERTY(VisibleAnywhere)
TArray<int32> Triangles;
TArray<FVector> normals; 
TArray<FVector2D> UV0;
TArray<FProcMeshTangent> tangents;
TArray<FLinearColor> vertexColors;
TArray<FVector2D> blocks; 

int worldData[16][16][16] = { {} };
float tUnit = 0.0625; 


public:void CubeTop(int x = 0, int y = 0, int z = 0, int block = 0);
public:void CubeNorth(int x = 0, int y = 0, int z = 0, int block = 0);
public:void CubeEast(int x = 0, int y = 0, int z = 0, int block = 0);
public:void CubeSouth(int x = 0, int y = 0, int z = 0, int block = 0);
public:void CubeWest(int x = 0, int y = 0, int z = 0, int block = 0);
public:void CubeBot(int x = 0, int y = 0, int z = 0, int block = 0);
public:void Cube(FVector2D texturePos);
public:void UpdateMesh(); 
public:void ClearMeshData(); 
public:void GenMesh();
public:void EditMesh(int x = 0, int y = 0, int z = 0, int block = 0); //here

public:int Chk(int x = 0, int y = 0, int z = 0);
//     int* mBlock(int x = 0, int y = 0, int z = 0);
};

And here is part of the cpp of the other script that I want to call EditMesh() with

        #include "Chunk.h"
        #include "VoxelWarsCharacter.h"
        #include "VoxelWarsProjectile.h"
        #include "Animation/AnimInstance.h"
        #include "Camera/CameraComponent.h"
        #include "Components/CapsuleComponent.h"
        #include "Components/InputComponent.h"
        #include "GameFramework/InputSettings.h"
        #include "HeadMountedDisplayFunctionLibrary.h"
        #include "Kismet/GameplayStatics.h"
        #include "MotionControllerComponent.h"
        #include "XRMotionControllerBase.h" // for 

void AVoxelWarsCharacter::OnFire()
{
    FVector StartLocation = GetActorLocation(); //your location 
    StartLocation.Z += 15; 
    FVector EndLocation = StartLocation + (FirstPersonCameraComponent->GetForwardVector() * 4000.f); //get forward dir
    FHitResult Hit;
    FCollisionQueryParams ColParms; //ignor stuff
    ColParms.AddIgnoredActor(this);//ignor hitting self

    GetWorld()->LineTraceSingleByChannel(Hit, StartLocation, EndLocation, ECC_Visibility, ColParms);//ECC_WorldDynamic will only hit Actors, ECC_Visibility is everything

    if (Hit.GetActor()) {
        //Hit.GetActor()->AChunk::EditMesh(0, 0, 0, 1);
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor(255,255,255), "Hit a actor");
        UKismetSystemLibrary::DrawDebugLine(GetWorld(), StartLocation, Hit.Location, FColor(255, 255, 0), 5, 1);//FColor::Red 

        Hit.GetActor()->FindComponentByClass<AChunk>()->EditMesh((int)Hit.Location.X, (int)Hit.Location.Y, (int)Hit.Location.Z, 0); 
       //How do I do this?????????
    }
}

Errors I get

CompilerResultsLog: Error: D:\ProgramFiles\Epic Games\4.19\UE_4.19\Engine\Source\Runtime\Engine\Classes\GameFramework/Actor.h(2640) : error C2338: 'T' template parameter to FindComponentByClass must be derived from UActorComponent CompilerResultsLog:

Error: C:\Users\nolan\Desktop\VoxelWarsUR\Project\VoxelWars\Source\VoxelWars\VoxelWarsCharacter.cpp(160) : note: see reference to function template instantiation 'T *AActor::FindComponentByClass(void) const' being compiled

c++ unreal-engine

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Loops in C++ | For, While, and Do While Loops in C++

In this Video We are going to see how to use Loops in C++. We will see How to use For, While, and Do While Loops in C++.

How to Create a 2.5D Platformer Game with Unreal Engine using C++

Learn how to create a 2.5D Platformer game with Unreal Engine in this full tutorial using C++. You will how to create a game with Unreal Engine and Blueprints.

Using isdigit() in C/C++

In this article, we'll take a look at using the isdigit() function in C/C++. This is a very simple way to check if any value is a digit or not. Let's look

C++ Tutorial for Beginners 19 - C++ Structures | Struct declaration | C++ Data Structures

Welcome to this course on C++ Tutorial for Beginners. In this video we will see How to use C++ Structures.

Object Oriented Programming in C++ | C++ OOPs Concepts | Learn Object Oriented C++

C++ is general purpose, compiled, object-oriented programming language and its concepts served as the basis for several other languages such as Java, Python, Ruby, Perl etc.