Tank Not Moving Even though my code matches the instructor

my tank doesn’t seem to be moving despite the fact that the code i have written is the exact same as the instructors, here’s my code

// Fill out your copyright notice in the Description page of Project Settings.


#include "Tank.h"
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"
#include "Components/InputComponent.h"

ATank::ATank()
{
    SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
    SpringArm->SetupAttachment(SpringArm);

    Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
    Camera->SetupAttachment(SpringArm);
}

void ATank::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);

    PlayerInputComponent->BindAxis(TEXT("MoveForward"), this, &ATank::Move);
}

void ATank::Move(float Value)
{ 
    FVector DeltaLocation = FVector::ZeroVector;
    DeltaLocation.X = Value;
    AddActorLocalOffset(DeltaLocation);
}

it compiles just fine, but when i press the W key or the S key it doesn’t move, i also checked if the values in the project settings were correct, and they are.

Have you added logs to Move to see if you’re getting the expected values?

adding the ulog has resulted in giving me the line

LogPackageName: Warning: DoesPackageExist called on PackageName that will always return false. Reason: Input '' was empty.

Trying to delete the cache didn’t work, both in the appdata folder and in the project folder.

That has nothing to do with any logs you have added so just ignore that for now.

If you add a log in Begin Play does it show up?

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms