(.h)
class ATutorialProjectile; // forward declaration, this is above the UCLASS()
TSubclassOf<class ATutorialProjectile> MyProjectile;
(.cpp)
//in constructor
static ConstructorHelpers::FObjectFinder<UBlueprint> ProjectileBlueprint(TEXT("Blueprint'/Game/Blueprints/BP_Projectile.BP_Projectile'"));
if (ProjectileBlueprint.Object)
{
MyProjectile = (UClass*)ProjectileBlueprint.Object->GeneratedClass;
}
//in void Fire() function
if (MyProjectile != nullptr)
{
ATutorialProjectile* SpawnActor = GetWorld()->SpawnActor<ATutorialProjectile>(MyProjectile, MyArrow->GetComponentLocation(), MyArrow->GetComponentRotation());
}
I’ve already tested to see if it was maybe the MyArrow component that was crashing me, but it wasn’t. I replaced the FVector location and FRotator rotation with 0.0f, 0.0f, 0.0f just to see, and it still crashed. It’s 100% the MyProjectile object, but I don’t see what I’m doing wrong. I did the exact same thing for my Weapon in another class, and it works perfectly. I’ve also done this before without a problem. It’s almost like it just doesn’t like my blueprint for my projectile.
Is this some sort of bug? I used this method of spawning actors a ton of times before and not had problems. It’s like the engine selectively chooses when it wants to accept a blueprint.
ALSO, MyProjectile, my projectile blueprint, isn’t returning nullptr, so I honestly have no idea what is going on.
More information is necessary to help investigate this issue. Can you provide the callstack and log files from the crash? If possible, please also include the full code for your projectile class to help me reproduce the issue on my machine.
Didn’t know you responded, sorry. I would’ve responded earlier, but I’m kinda glad I didn’t. It just started working, as I’m writing this. I didn’t change anything. It just worked. I can’t really explain it. I’m like 1000% positive there’s a bug somewhere here, I just can’t explain what it is. This has happened to me before, a long time ago, where the game would constantly crash because it wouldn’t accept my blueprint. It wouldn’t return null, but the actual
TSubclassOf —
would be corrupt and it would just crash over and over again. I don’t know why, but it’s something like that.
My projectile class was just a class extended from AActor with nothing added:
Even though I’m no longer having the issue, could you still look into it possibly being a bug? I think it has something to do with the path to the blueprint not being properly or something. This is the second time I’ve run into this, and I have a feeling I’ll run into it again.
I don’t exactly know what logs you want. These were taken from my /Project/Saved/Logs folder from last night when the issue was still occurring:
[2016.11.17-05.34.43:971][311]LogClass: Function CalculateHealth is new.
[2016.11.17-05.34.44:230][311]LogCrashTracker: