Accessed None trying to read property TankMovementComponent

strange - I’m in 4.16.1 - I can compile, but while running, I get the error:

PIE:Error: Error Blueprint Runtime Error: Accessed None trying to read property TankMovementComponent from function: ‘ExecuteUbergraph_Tank_BP’ from node: Intend Move Forward in graph: InputSetup in object: Tank_BP with description: Accessed None trying to read property TankMovementComponent

Any ideas?

Code below:

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

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/NavMovementComponent.h"
#include "TankMovementComponent.generated.h"

UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class BATTLETANK_API UTankMovementComponent : public UNavMovementComponent
{
	GENERATED_BODY()

public:

		UFUNCTION(BlueprintCallable, Category = Input)
		void IntendMoveForward(float Throw);

private:

};

TankMovementComponent.cpp

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

#include "BattleTank.h"
#include "TankMovementComponent.h"

void UTankMovementComponent::IntendMoveForward(float Throw)
{
	UE_LOG(LogTemp, Warning, TEXT("Intend Move Forward %f"), Throw)

}

Tank.h

UCLASS()
class BATTLETANK_API ATank : public APawn
{
	GENERATED_BODY()

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

	...

	UFUNCTION(BlueprintCallable, Category = Firing)
	void Fire();


protected:

	UPROPERTY(BlueprintReadOnly)
	UTankMovementComponent* TankMovementComponent = nullptr;

    ...

Tank.cpp

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

#include "BattleTank.h"
#include "TankAimingComponent.h"
#include "TankMovementComponent.h"
#include "Tank.h"
#include "TankTrack.h"
#include "TankBarrel.h"
#include "TankTurret.h"
#include "Projectile.h"

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

	TankAimingComponent = CreateDefaultSubobject<UTankAimingComponent>(FName("Aiming Component"));
	TankMovementComponent = CreateDefaultSubobject<UTankMovementComponent>(FName("Movement Component"));
}
1 Like

I just ran into this problem, I’m guessing you’ve solved it by now? :wink: Care to share?

I had to remove everything from the event graph, save and close, then compile and add the pieces again. Haven’t seen the issue again in later versions.

Hmmm… didn’t do it for me, unfortunately. Do appreciate the speedy reply though!

I can look again to see if there was anything specific - give me a day

You may need a new BP

Solved it. I made a boo boo, as Ben would’ve put it :wink: I messed up a UFUNCTION decorator, probably from copying it. Thanks for taking the time, buddy :slight_smile:

At least it’s solved!

I have the same issue :confused:. Please help a fellow student here :sob:.

I have literally spent an hour and a half on this problem now :sob:.

One thing you could do, if none of the above helps, is to download the source from Ben’s version and do a file compare to see the differences - the problem may be a subtle typo

Thanks, I fixed it. For some reason Unreal was bugging out. I had to delete the class and create one again and it’s fixed. Still, it’s not picking up the FName() I give TankMovementComponent but it’s working fine now.

I’ll leave the steps here in case someone else has this same problem.

Steps I took:

  1. Removed the Code relating to TankMovementComponent from Tank.h, Tank.cpp and blueprint graph.
  2. Close UE4 and VS.
  3. Delete the TankMovementComponent.cpp and .h files manually.
  4. Delete the Binary folder.
  5. Right Click on BattleTank project file and Generate Visual Studio Project files.
  6. Open the project and Create the TankMovementComponent class again.

Happy learning

I just had this problem too.

It’s unfortunate that this was a challenge, since we were inevitably going to repeat what we did before with components. ie. adding “BlueprintSpawnableComponent” to the UCLASS macro, which actually works. but then we realise we were meant to do it a different way. but I guess Ben wasn’t to know that Unreal would bug out with this change.

The funny thing is he sets the class to BlueprintSpawnableComponent in the next vid anyway :stuck_out_tongue: So if anyone else encounters this problem. just ignore the error and carry on. it will fix itself. :slight_smile:

Sometimes the fix is as simple as restarting unreal. Thanks for the help though. Could you tick this thread as solved?

Privacy & Terms