TSubclassOf error

Hi im getting this no suitable user-defined conversion from “TSubclassOf” to “AWeapon” exists error when trying to pass my weapontospawn variable to my giveweapon function

TSubclassOf WeaponToSpawn;

is a class not an object which would be AWeapon for example.
Your give weapon function should either

  • Accept a TSubclassOf and spawn it
  • Or your Weapon pickup spawns a AWeapon from TSubclassOf and calls give weapon with the spawned object, which should be a AWeapon* you want a pointer to a AWeapon, not a AWeapon directly

Thanks i got it working now

pls accept the answer, or post your solution and accept that,
my ocd is triggered by not closed answers :stuck_out_tongue:

I got it working by changing my GiveWeapon function parameter from

void GiveWeapon(AWeapon WeaponToSpawn);


Void GiveWeapon(TSubclassOf<AWeapon> WeaponToSpawn);