BlueprintCallable not working with TankTurret

UFUNCTION(BlueprintCallable, Category = Setup)
void SetTurretReference(UTankTurret* TurretToSet);

For the above code, copied directly from the preexisting UTankBarrel version, having the UFUNCTION macro on it gives me error LNK2019, an unresolved symbol" public: void_cdec|ATank::SetTurretReference(class UTankTurret*)…"
I can change the turret pointer to a float, and adjust it accordingly in the cpp file, but it still won’t work unless I remove the UFUNCTION macro. I went over my files for a while, I did forward declaration with UTankTurret, and even had the ATank::SetTurretReference just log out that it was being called, and it compiles fine so long as the macro isn’t there.

#pragma once

#include “GameFramework/Pawn.h”
#include “Tank.generated.h”

class UTankBarrel;
class UTankTurret;
class UTankAimingComponent;

class BATTLETANK_API ATank : public APawn

void AimAt(FVector HitLocation);

UFUNCTION(BlueprintCallable, Category = Setup)
void SetBarrelReference(UTankBarrel* BarrelToSet);

UFUNCTION(BlueprintCallable, Category = Setup)
void SetTurretReference(UTankTurret* TurretToSet);

CompilerResultsLog:Error: Error Tank.cpp.obj : error LNK2019: unresolved external symbol “public: void __cdecl ATank::SetTurretReference(class UTankTurret *)” (?SetTurretReference@ATank@@QEAAXPEAVUTankTurret@@@Z) referenced in function “public: void __cdecl ATank::execSetTurretReference(struct FFrame &,void * const)” (?execSetTurretReference@ATank@@QEAAXAEAU

What does the .cpp look like?

I would use GitHub, but I was having trouble removing files past the size limit.

You didn’t provide your project files so I could only copy and paste it into Ben’s project and it compiled fine.

Thanks for testing my files! I ended up restarting my computer, and then rebuilding the binaries, and it seemed to work. Then, I continued to add in the turret’s rotation, and ended up getting the same issue. So, i rebuilt the binaries and it worked. I then decided to change the name of the turret’s rotation method, and I ended up getting the same errors again, so I rebuilt again, and it worked. It was giving me errors of the old name of the method in the TankAimingComponent, even though the old method’s name didn’t exist anywhere in the file anymore (changed from “Spin” to “Rotate”). I don’t know why it wouldn’t update, but it works now.

Privacy & Terms