Why did we change the Tank Aiming Component in the TankPlayerController_BP?

What is the new ? Why is the new form better than previous ?

Where is the difference?

Old form:
1

New form:

I’m not sure why that is done, it’s essentially just moving where the cast is done.

The first casts the pawn to ATank (in C++) to get the aiming component.

The second searches the components for the first ATankAimingComponent which would most likely be done via iterating over the components and casting each to ATankAimingComponent until the cast doesn’t result in nullptr

Thanks @DanM but still not obvious !!
I don’t know what is the idea :thinking:

What do you mean? I’m saying it shouldn’t make a difference.

The first solution could not change the color of the crosshair till after modifying the c++ code.
So we were forced to update the blueprint solution as the second picture shown above.

Looking at the code for this lecture, it doesn’t look like TankAimingComponent is ever assigned a value.

https://github.com/UnrealCourse/04_BattleTank/blob/37b939b43fd502147ce27f5b6f305315641b7885/BattleTank/Source/BattleTank/Private/Tank.cpp

Adding this before Super::BeginPlay should make it work.

void ATank::BeginPlay()
{
	TankAimingComponent = FindComponentByClass<UTankAimingComponent>();

Privacy & Terms