Hello, I am currently trying to learn how to spawn actors in C++. I took a brief look in how they did it in First Person Template and coded my function like so:
void AHeroShip::SpawnShield()
{
if (Energy >= 50 && ShieldClass != NULL)
{
const FRotator SpawnRotation = GetControlRotation();
const FVector SpawnLocation = GetActorLocation() + SpawnRotation.RotateVector(ShieldOffset);
UWorld* const World = GetWorld();
if (World != NULL)
{
Energy -= 50.f;
World->SpawnActor<Shield>(ShieldClass, SpawnLocation, SpawnRotation);
}
}
}
Which then I know I’m supposed to say what the class is in blueprint, but I keep getting the error (MSB3070, exited with code -1) Normally, I’m good at finding these bugs and fixing them, but I can’t find out what is wrong with the code, any ideas why this might be happening? Any help would be appreciated.
Here is the .h file, I’ll also will link the .cpp file if anyone needs to see it.:
#pragma once
#include "BaseShip.h"
#include "HeroShip.generated.h"
/**
*
*/
UCLASS(Blueprintable)
class TWINSTICKEXAMPLE_API AHeroShip : public ABaseShip
{
GENERATED_BODY()
public:
AHeroShip();
//Ammo Types
float BounceShotAmmo;
float SpreadShotAmmo;
float BeamShotAmmo;
bool isLow;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "GunType")
int32 Type;
UPROPERTY(EditDefaultsOnly, Category = "Shield")
TSubclassOf<class Shield> ShieldClass;
//Any offsets
FVector UDOffset;
FVector ShieldOffset;
FTimerHandle EnergyDepleteBoost;
FTimerHandle RestoreEnergyTimer;
protected:
//movement
void MoveForward(float Delta);
void MoveRight(float Delta);
void MoveUD(); //Move either up or down
void Boost();
void notBoost();
//EnergyBased Spawns
void SpawnShield();
//Gun
void SetToAuto();
void SetToBounce();
void SetToSpread();
void SetToBeam();
void RestoreEnergy();
virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
};