0

So I am a beginner with game programming in UE4, just starting out with c++. The code below worked perfectly before I attached a springcomponent to my mesh. This is a simple Pawn class that I created. I should also mention that once I included the spring component and tested it and it did not work, my computer shut down accidently. It give the same error repeatedly for any class I create, I have tried making a new class and applying the code.

Please see Image for the error VS 2017 gives when I try to debug

Below is the RollingStone.cpp file code.

#include "RollingStone.h"
#include "Classes/Components/InputComponent.h"
#include "Classes/GameFramework/FloatingPawnMovement.h"
#include "Classes/Camera/CameraComponent.h"

// Sets default values
ARollingStone::ARollingStone()
{
    // 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;

    FloatingPawnMovement = CreateDefaultSubobject<UFloatingPawnMovement>("PawnMoevement");

    StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>("StaticMeshComponeent");
    Camera = CreateDefaultSubobject<UCameraComponent>("CameraComponeent");
    Camera->SetRelativeLocation(FVector(-500.f, 0.f, 0.f));
    Camera->SetupAttachment(StaticMesh);

    SetRootComponent(StaticMesh);

    bUseControllerRotationYaw = true;
    bUseControllerRotationPitch = true;

}

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

void ARollingStone::MoveForward(float Amount)
{

    FloatingPawnMovement->AddInputVector(GetActorForwardVector()* Amount);
}

void ARollingStone::MoveRight(float Amount)
{
    FloatingPawnMovement->AddInputVector(GetActorRightVector()* Amount);
}

void ARollingStone::Turn(float Amount)
{
    AddControllerYawInput(Amount);
}

void ARollingStone::Lookup(float Amount)
{
    AddControllerPitchInput(Amount);
}



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

}

// Called to bind functionality to input
void ARollingStone::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);
    PlayerInputComponent->BindAxis("MoveForward", this, &ARollingStone::MoveForward);
    PlayerInputComponent->BindAxis("MoveRight", this, &ARollingStone::MoveRight);
    PlayerInputComponent->BindAxis("Turn", this, &ARollingStone::Turn);
    PlayerInputComponent->BindAxis("LookUp", this, &ARollingStone::Lookup);

}

Below is the RollingStone.h file code:


#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "RollingStone.generated.h"

UCLASS()
class MYPROJECT_API ARollingStone : public APawn
{
    GENERATED_BODY()

public:
    // Sets default values for this pawn's properties
    ARollingStone();

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

    void Turn(float Amount);
    void Lookup(float Amount);


    class UFloatingPawnMovement* FloatingPawnMovement;

    UPROPERTY(EditAnywhere, Category = "Components")
        UStaticMeshComponent* StaticMesh;

    UPROPERTY(EditAnywhere, Category = "Components")
        class UCameraComponent* Camera;

    

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

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

};

Will appreciate you taking the time to help me. I am now very sure that the accidental shutdown caused this since its not working even after I stop using the springarmcomponent, you can see it is not there in the code and this previously working code now does not even debug. I am using visual studio 2017 by the way! Thank you!

Looking forward to a solution.

  • Seems like your project has been corrupted some how. Do you get that same error message when you try to build, when you try to run (but not debug)? – john Jul 23 '20 at 14:00
  • No, the project builds fine. – Tallal Butt Jul 23 '20 at 14:11
  • I found the solution, but its unsatisfactory. I want to know to fix that project because I made a new one. I cant do that for a project in the future that I work hard to setup. – Tallal Butt Jul 23 '20 at 14:24
  • Probably wanna just delete your intermediates and binaries and go again. The build process will restore them with a full rebuild. – George Jul 23 '20 at 16:10
  • Go to the project, there'll be a folder called `.vs` (it maybe hidden), delete that, there'll be folders called Debug and Release, delete those. If you're nervous you can move them out of the project folder instead of deleting. Basically nuke everything that isn't a project file, a solution file or a source file. – john Jul 23 '20 at 17:19
  • But I think you should get familar enough with Visual Studio projects that you can recreate them if necessary. Otherwise you do leave yourself a little vulnerable. – john Jul 23 '20 at 17:21

0 Answers0