Hi guys!
Quick question about getting my C++ Actor class object to receive input at the same time as my player character all through C++.
Essentially put, I have gone over every possible thing I can and can not seem to get it working. I have tried multiple ways of setting up the input, it will not work. Here is the code that I am currently working with:
=====
.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include “GameFramework/Actor.h”
#include “myExampleCPP.generated.h”
UCLASS()
class MYEXAMPLE_API AmyExampleCPP : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor’s properties
AmyExampleCPP();
UFUNCTION(BlueprintCallable, Category = "Go to me function")
void GoToMe();
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent);
UPROPERTY(BlueprintReadWrite, Category = "Testing")
bool testBool = false;
};
=====
CPP
// Fill out your copyright notice in the Description page of Project Settings.
#include “myExample.h”
#include “myExampleCPP.h”
// Sets default values
AmyExampleCPP::AmyExampleCPP()
{
}
void AmyExampleCPP::GoToMe() {
testBool = true;
}
void AmyExampleCPP::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
// Set up gameplay key bindings
check(InputComponent);
InputComponent->BindAction(“Left Mouse Click”, IE_Pressed, this, &AmyExampleCPP::GoToMe);
//InputComponent->BindAction(“Jump”, IE_Released, this, &ACharacter::StopJumping);
}
===
Essentially put, with this code, the player would press the left mouse button. The code would then go to GoToMe and set my testBool Boolean to true. The Boolean is a variable that serves no other purpose then to test that the code is working properly.
So am I missing something here? Thank you in advance.