Crash in 4.18

I’ve got myself stuck on this lecture using engine version 4.18.2.

I tracked down the problem to two areas. Firstly when declaring the Barrel StaticMeshComponent in TankAimingComponent.h:

private:
UStaticMeshComponent* Barrel = nullptr;

Adding this causes the engine to crash with no feedback. I initially thought this might be because i needed to include the Compoents/StaticMeshComponent.h header, which i did with no success. Removing the assignment to nullptr allows the engine to load.

However, after doing this, the engine still crashes when i click play at the point of setting Barrel=BarrelToSet inside UTankAimingComponent::SetBarrelReference.

It seems to be an issue assigning to the Barrel property inside TankAimingComponent. Currently I’m lost for answers so any suggestions are welcome.

Issue is at this commit on my github: https://github.com/ChristopherJohnston/UnrealCourse_04_BattleTank/tree/892218527cb299f10d5333f0483e8f382abea6e3

as a work-around until I can work out what is going wrong with this, I have moved the Barrel reference into Tank.cpp and pass the BarrelLocation FVector to UTankAimingComponent::AimAt from ATank::AimAt.

At least then it doesnt crash and I can continue the course working on the aiming code from the TankAimComponent.

See: https://github.com/ChristopherJohnston/UnrealCourse_04_BattleTank/commit/834b9a36041e6c9b995be8d5865efb54137e3410

Two things appeared to solve this issue:

  1. Firstly, cleaning up using: Build -> Clean Solution, Build->Build in visual studio.
  2. Later on, Replacing UStaticMeshComponent with the custom UTankBarrel c++ component in the future video “140. BlueprintSpawnableComponent()”

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

Privacy & Terms