Creating unique actors and data tables

Yeah, the problem was my DT, i got it working as intended now. My Child actor has this in its Constructor.

271683-3.png

is this the Call to parent function?

How should i handle the Spawning of cards?

I’ve been using numbers just to test. i got row names as well.
I would like to spawn 3 different copies of the actor when an action is called upon. Spawning 3 random cards every time.

Looks about right!

How should i handle the Spawning of
cards?

You can expose the Card Fetch variable on the actor itself and fetch it by name. Although I see that your rows are numbers rather than actual names.

Not sure what mechanics you’ve got in mind.

Is this in the base card BP or in the child actor?

This should work for indexes and/or names:

Since you’ve worked the the DT into the construction script, you should be able to get fetch it by name via an exposed Card Fetch like so:

You asked:


How should i handle the Spawning of
cards?

I would like to spawn 3 different
copies of the actor when an action is
called upon. Spawning 3 random cards
every time.


The image I posted is a method to spawn cards. So it would sit outside of the card object - the SpawnActor node will create whatever you choose in the class dropdown. Spawning a card from inside of a card could create an infinite loop - not a good idea.

It’s up to you if you want to create a base or one of the children; and it’s up to you which blueprint will handle spawning of the cards. With a setup like this, you’re free to do it pretty much anywhere. Maybe wrap it in a function that takes an int (number of cards) and returns an array of cards. Place the function in the GameInstance and it becomes available from anywhere.

I do not know how your game is supposed to work. You probably have a main game loop and conditions that grant the player / opponent cards - these could call the abovementioned GameInstance function. Difficult to advise without knowing more about how you envisioned it.

Is it more like this or more like this this?

Yeah very much like slay the spire.

The player can pick between 3 cards he brings to the next phase. The cards will have costs between 1 to 3 and the player has 3 Mana to spend on cards each round.
So i would like to spawn 3 cards at random for the player to drag and drop into his hand. then play them in the next phase.

This is how i’m handling the spawning at this point. this is in the level blueprint.

I don’t understand, sorry. What do you mean by linked to DT. There’s nothing to link. DT is static. When you spawn an actor it just pull the relevant data from it.

If you’re creating something similar to Slay the Spire, I think there are combat rounds, right (I never played the game)? The beginning of a combat round should be the trigger that spawns X cards and / or removes the ones in hand.

Or is that not how your game works?

Right now, i spawn 3 different cards. But its only in the widget right now. How to i spawn a child actor thats linked to my DT?

Sorry, linked was the wrong word to use. I’ll try to be clearer.

I’m currently spawning my cards on a button press (later to be changed to spawn when entering the “combat” mode)
The card displays the information drawn from my DT. If i am to add functionality to the cards i need to spawn the correct Child Actor to the card. I’m wondering how i can do this.

the plan is to make every card a child actor and add the required actor components to the child.

You can include that information in the Data Table itself, see the element at the bottom:

And then the child, once it has executed parent’s Construction Script, can add its own components or override any functionality that the parent has - this is also a very common thing to do.

I’m now able to spawn the cards and the child actor. But it seams that the widget and the actor spawn does different things. My string for a certain card can pop up from the spawner, but nothing is displayed.

Right now i’m spawning the cards on a Key press from the level BP like this:

And in my base card like this:

This should have been The Midas pot.

271940-3.png

I think the problem is that when the cards is spawned it picks random cards from the DT. Then when a card is spawned it picks another random drom the DT in the card construction script. I need a way for them to pick the same card. This is what i think is happening.

If I remember correctly, you access the DT (randomly?) in the Construction Script, too.

Since you’ve now incorporated class into the struct, do not let the card access the DT from inside of the construction script.

Essentially, make sure that card object passes the data it received when spawning to the widget.

So I need someway to send the row name from my spawner to the card? The spawner is in the level bp right now.
I’m using the name to feed information to the Widget.

Don’t do anything in the Level Blueprint, unless you really must - it’s difficult to communicate with. Why not use GameMode / Game Instance instead?

And it works! I moved the card spawner to the game mode and did a cast from the card to get the same result! TY so much!
I still have questions about the drag and drop but ill create a new thread for that!

i’m wondering if I can create 3 different versions of the potion card out of 1 widget. I’m also wondering if I can pass along information from my data table when I drag and drop the card to the player hand.