I have the following classes:
Hand.h:
#pragma once
#include "GameFramework/Actor.h"
#include "Hand.generated.h"
/**
*
*/
UCLASS(Within = Arm)
class AHand : public AActor
{
//code
};
Arm.h:
#pragma once
#include "GameFramework/Actor.h"
#include "Hand.h"
#include "Arm.generated.h"
UCLASS()
class AArm : public AActor
{
GENERATED_UCLASS_BODY()
void createHand();
UPROPERTY()
AHand * handPart;
};
Arm.Cpp:
void AArm::createHand()
{
FActorSpawnParameters spawnInfo;
spawnInfo.Owner = this;
handPart = GetWorld()->SpawnActor<AHand>(spawnInfo);
}
This compiles fine, but when I run AArm::createHand() during runtime the game crashes. I get this error message in the Log:
[2014.07.21-03.11.48:269][638]LogWindows: === Critical error: === Unhandled Exception: 0x00000001
[2014.07.21-03.11.48:270][638]LogWindows: Object Hand Hand created in Level instead of Arm
If I change UCLASS(Within = Arm)
to UCLASS()
in Hand.h, no crash occurs.
Why am I crashing and how do I fix it?
Thanks!