Hello world !
New in C++, what i’m trying to do is to Left mouse clic and spawn a line trace with the player controller.
So I put a input “SpawnTrace” in the PlayerController, I also put a Debug message but nothing working, I have
no print with the DebugMessage.
Here is the code:
.h file:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "CPP_Controller.generated.h"
UCLASS()
class FNJCPP_API ACPP_Controller : public APlayerController
{
GENERATED_BODY()
public:
ACPP_Controller();
void SpawnTrace();
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent);
};
.cpp file:
// Fill out your copyright notice in the Description page of Project Settings.
#include "CPP_Controller.h"
#include "Engine.h"
ACPP_Controller::ACPP_Controller()
{
bShowMouseCursor = true;
}
void ACPP_Controller::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
PlayerInputComponent->BindAction("SpawnTrace", IE_Pressed, this, &ACPP_Controller::SpawnTrace);
}
void ACPP_Controller::SpawnTrace()
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Red, TEXT("TRACE"));
}
}
and when i put an override at the end of the line:
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
I have an error saying : " ‘override’ did not override any base class methods"
thank you guys