Download

Trouble moving my Pawn!! NEED HELP !!

Well I am a complete beginner in Unreal Engine, so I am running into some problems that I need help with!!
I am working on a project named Alpha1, where I made a C++ Pawn class named “Collider” and a blueprint of it named “Collider_BP”. But the problem is, the Collider is not moving at all. Here are the things that I did in order to make it move:

  1. In my project, out of the default game mode C++ class, I made a game mode blueprint named, “Alpha1_Collider_Gamemode_BP”, in the “Details” tab of Alpha1_Collider_Gamemode_BP, I set the default pawn class as the “Collider_BP”, I uploaded a screenshot of it.

  2. In my “World Settings”, I set the default game mode as the “Alpha1_Collider_Gamemode_BP” that I made, where The default Pawn class was “Collider_BP”. I uploaded the screenshot of my world settings too.
    4.jpg

  3. In the “Details” tab of my “Collider_BP”, I set the “Auto Possess Player” variable as “Player0” and in the C++ code of my “Collider.cpp”, “Collider.h”, “ColliderMovementComponent.cpp” as well as in my “ColliderMovementComponent.h”, the auto possess player is set to “Player0”. I also set the “Input” variable in the “Details” tab of my “Collider_BP” to “Player0”. All the codes are uploaded below. and I also uploaded the screenshot for this one too.
    1.jpg

  4. In the “Project Settings” of my project “Alpha1”, in the “Input” option, I set the axis parameters with W,A,S and D as well as with Up, Down, Right and Left arrow keys. I uploaded the screenshot of this too.

Now Ill upload my C++ codes for the Pawn Collider as well as for the ColliderMovementComponent

Collider.cpp
#include “Collider.h”
#include “Components/SphereComponent.h”
#include “Components/StaticMeshComponent.h”
#include “UObject/ConstructorHelpers.h”
#include “Components/InputComponent.h”
#include “GameFramework/SpringArmComponent.h”
#include “Camera/CameraComponent.h”
#include “ColliderMovementComponent.h”

// Sets default values
ACollider::ACollider()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;

//RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT(“RootComponent”));
SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT(“SphereComponent”));

//SphereComponent->SetupAttachment(GetRootComponent());
RootComponent = SphereComponent;
SphereComponent->InitSphereRadius(40.0f);
SphereComponent->SetCollisionProfileName(TEXT(“Pawn”));

MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT(“MeshComponent”));
MeshComponent->SetupAttachment(GetRootComponent());

static ConstructorHelpers::FObjectFinder<UStaticMesh> MeshComponentAsset(TEXT(“StaticMesh’/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere’”));

if (MeshComponentAsset.Succeeded())
{
MeshComponent->SetStaticMesh(MeshComponentAsset.Object);
MeshComponent->SetRelativeLocation(FVector(0.f, 0.f, -40.f));
MeshComponent->SetWorldScale3D(FVector(0.8f, 0.8f, 0.8f));
}
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT(“SpringArm”));
SpringArm->SetupAttachment(GetRootComponent());
SpringArm->RelativeRotation = FRotator(-45.f, 0.f, 0.f);
SpringArm->TargetArmLength = 400.f;
SpringArm->bEnableCameraLag = true;
SpringArm->CameraLagSpeed = 3.0f;

Camera = CreateDefaultSubobject<UCameraComponent>(TEXT(“Camera”));
Camera->SetupAttachment(SpringArm, USpringArmComponent::SocketName);

OurMovementComponent = CreateDefaultSubobject<UColliderMovementComponent>(TEXT(“OurMovementComponent”));
OurMovementComponent->UpdatedComponent = RootComponent;

AutoPossessPlayer = EAutoReceiveInput::Player0;
}

// Called when the game starts or when spawned
void ACollider::BeginPlay()
{
Super::BeginPlay();

}

// Called every frame
void ACollider::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

}

// Called to bind functionality to input
void ACollider::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);

PlayerInputComponent->BindAxis(TEXT(“moveForwardBackward”), this, &ACollider::moveForwardBackward);
PlayerInputComponent->BindAxis(TEXT(“moveRightLeft”), this, &ACollider::moveRightLeft);
}

void ACollider::moveForwardBackward(float input)
{
FVector Forward = GetActorForwardVector();
if (OurMovementComponent)
{
OurMovementComponent->AddInputVector(input * Forward);
}
}
void ACollider::moveRightLeft(float input)
{
FVector Right = GetActorRightVector();
if (OurMovementComponent)
{
OurMovementComponent->AddInputVector(input * Right);
}
}
UPawnMovementComponent* ACollider::GetMovementComponent()const
{
return OurMovementComponent;
}

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

#pragma once

#include “CoreMinimal.h”
#include “GameFramework/Pawn.h”
#include “Collider.generated.h”

UCLASS()
class ALPHA1_API ACollider : public APawn
{
GENERATED_BODY()

public:
// Sets default values for this pawn’s properties
ACollider();

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

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

// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

UPROPERTY(VisibleAnywhere, category = “Mesh”)
class UStaticMeshComponent* MeshComponent;

UPROPERTY(VisibleAnywhere, category = “Mesh”)
class USphereComponent* SphereComponent;

UPROPERTY(VisibleAnywhere, category = “Mesh”)
class UCameraComponent* Camera;

UPROPERTY(VisibleAnywhere, category = “Mesh”)
class USpringArmComponent* SpringArm;

UPROPERTY(VisibleAnywhere, category = “Mesh”)
class UColliderMovementComponent* OurMovementComponent;

virtual UPawnMovementComponent* GetMovementComponent() const override;

FORCEINLINE UStaticMeshComponent* GetMeshComponent() { return MeshComponent; }
FORCEINLINE void SetMeshComponent(UStaticMeshComponent* Mesh) { MeshComponent = Mesh; }

FORCEINLINE USphereComponent* GetSphereComponent() { return SphereComponent; }
FORCEINLINE void SetSphereComponent(USphereComponent* Sphere) { SphereComponent = Sphere; }

FORCEINLINE UCameraComponent* GetCameraComponent() { return Camera; }
FORCEINLINE void SetCameraComponent(UCameraComponent* InCamera) { Camera = InCamera; }

FORCEINLINE USpringArmComponent* GetSpringArmComponent() { return SpringArm; }
FORCEINLINE void SetSpringArmComponent(USpringArmComponent* InSpringArm) { SpringArm = InSpringArm; }

private:

void moveForwardBackward(float input);
void moveRightLeft(float input);
};

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

#include “ColliderMovementComponent.h”

void UColliderMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

if (!PawnOwner || !UpdatedComponent || ShouldSkipUpdate(DeltaTime))
{
    return;
}

FVector DesiredMovementThisFrame = ConsumeInputVector().GetClampedToMaxSize(1.0f) * DeltaTime * 150.f;

if (!DesiredMovementThisFrame.IsNearlyZero())
{
    FHitResult Hit;
    SafeMoveUpdatedComponent(DesiredMovementThisFrame, UpdatedComponent-&gt;GetComponentRotation(), true, Hit);

    if (Hit.IsValidBlockingHit())
    {
        SlideAlongSurface(DesiredMovementThisFrame, 1.f - Hit.Time, Hit.Normal, Hit);
    }
}

}

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

#pragma once

#include “CoreMinimal.h”
#include “GameFramework/PawnMovementComponent.h”
#include “ColliderMovementComponent.generated.h”

/**
*
*/
UCLASS()
class ALPHA1_API UColliderMovementComponent : public UPawnMovementComponent
{
GENERATED_BODY()

public:

virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;      

};

When I compile these codes, the build report says “Build: 1 Succeeded, 0 Failed, 0 up-to-date, 1 Skipped”, So, I think the compiler is skipping something important.
If any other detail is required then please let me know and please help me out with this issue please !!!