Battery Pickup Tutorial Error 2664

Hi.

I’m having an issue with the C++ programming in this tutorial. I’ve looked through it, and the line causing the error is exactly the same as in the tutorial.

APickup* const SpawnedPickup = World->SpawnActor<APickup>(WhatToSpawn, SpawnLocation, SpawnRotation, SpawnParams);

I get the following error:

*error C2664: ‘T *UWorld::SpawnActor(UClass *, const FVector &,const FRotator &,const FActorSpawnParameters &)’ : cannot convert argument 1 from ‘APickup *’ to ‘UClass *’
with

[

    *T=APickup*

]

Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

On closer examination of the code I find that there is a problem with the World->SpawnActor,
with the following message on mouse over:

SpawnActor

Error: no instance of overload function “UWorld::SpawnActor” matches the argument list

         argument types are:(APickup*, FVector, FRotator, FActorSpawnParameters)

         object type is: UWorld

I’m not very well versed in error handling, and as such have a bit of a problem finding out the cause of this… anyone able to help?

Hi Hardishane,

Compiler cannot convert first parameter to UClass. Your variable (WhatToSpawn) should be declared like here:

TSubclassOf<class APickup> WhatToSpawn;

Or you can get class type:

APickup::StaticClass()

Hope it helps!

Hi .

Yet again an answer that fixed my problem :slight_smile: Thank you.