I want to make a card game.
I have an AActor
called ACardGame
, i can place it in my world.
the ACardGame
has a ADeck
inside it. The ADeck
is an AActor
too. I want to be able to position the ADeck
relative to where i placed the ACardGame
so I have the following code:
// Spawn an instance of a deck of cards
this->deckOfCards = this->CreateDefaultSubobject<ADeck>(TEXT("Deck of cards"));
// Used to position where the card game will be
this->SetRootComponent(this->CreateDefaultSubobject<USphereComponent>(TEXT("Root component for card game")));
// Attach deck of cards to the card game
this->deckOfCards->AttachToComponent(this->GetRootComponent(), FAttachmentTransformRules::KeepRelativeTransform);
I now make a blueprint based off of my ACardGame
class and enter the blueprint editor. Inside, i see a RootComponent
, but no ADeck
attached to that root?..
…I have realised this is because only scene components can be displayed inside an AActor
???. However, the ADeck
is a thing in its own right, it may sometimes be completely seperate from the ACardGame
… so i don’t want it to have to be a component and yet i need it to be editable inside the blueprint?
My question is:
Instead of making the ADeck
a UPrimitiveComponent
so that i can see it in the blueprint editor and edit it, what do you recommend i do?
My goal
I want to have a card game that i can position in my game editor, and then from that i want to be able to position my deck in the game editor and so on and so forth… At the same time, the deck needs to be an item that i can place on its own as an item to pick up.