Hi,
I had been following the courses exactly and suddenly my BindAxis function doesn’t want to work, saying that it doesn’t have the right arguments while I have the exact same as in the video and I even checked the declaration and I have the right arguments, so I really don’t understand what’s wrong.
And then secondly it says that my declaration of Speed is wrong while it looks like a perfectly normal and right declaration to me and as well here I have the exact same as the video.
the error goes as followed:
I did it in VS-code because in UE4 the text would be to big to fit in 1 picture, as I would have to go more to the right.
And my code of Tank.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Tank.h"
#include "Camera/CameraComponent.h"
#include "Components/InputComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "Kismet/GameplayStatics.h"
ATank::ATank()
{
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
SpringArm->SetupAttachment(RootComponent);
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(SpringArm);
}
// Called to bind functionality to input
void ATank::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis(TEXT("MoveForward"), this, &ATank::Move);
}
void ATank::Move(float Value, float Speed, float DeltaTime)
{
FVector DeltaLocation = FVector::ZeroVector;
DeltaLocation.X = Value * Speed * UGameplayStatics::GetWorldDeltaSeconds(this);
AddActorLocalOffset(DeltaLocation);
}
Finally, my Tank.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BasePawn.h"
#include "Tank.generated.h"
/**
*
*/
UCLASS()
class TOONTANKS_API ATank : public ABasePawn
{
GENERATED_BODY()
public:
ATank();
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
private:
UPROPERTY(VisibleAnywhere, Category = "Components")
class USpringArmComponent* SpringArm;
UPROPERTY(VisibleAnywhere, Category = "Components")
class UCameraComponent* Camera;
UPROPERTY(EditAnywhere, Category = "Movement")
float Speed = 100.f;
void Move(float Value, float Speed, float DeltaTime);
};
Any help would be much appreciated as I’ve been looking for where there could be any mistake but I can’t find anything.
Sorry if I missed something stupid.