# About hands of card game

**URL:** <https://forums.unrealengine.com/t/about-hands-of-card-game/677382>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [October 26, 2022, 10:30am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382 "2022-10-26T10:30:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![0u0high](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0u0high](https://forums.unrealengine.com/u/0u0high)\
**Post date:** [October 26, 2022, 10:30am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/1 "2022-10-26T10:30:25Z")

</div>

We are currently developing a card game with a small team.  
I have a question about how to implement hand cards.  
We tried to implement it using the following assets, but because it is a widget, the cards themselves cannot reflect lighting, etc. Also, we cannot actually put them on the field.

Therefore, I am thinking of implementing the card itself as an Actor in BP, and then sticking a Widget on it.

In that case, how can I make it look like I am expanding my cards according to the number of cards in my hand, as shown in the following image (I am also thinking of highlighting the cards on mouse-over, etc.)?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/2/0/8206406b8c0df356ab21c65b163a8ba3e53ac715.jpeg)

Personally, I think it is necessary to separate the implementation of “cards in hand” and “cards by themselves” by having a sort of “saucer” of cards in BP\_PlayerCharacter itself, and placing random cards in that saucer when the game starts. Then, I am thinking that we should put a process in the “saucer” itself that arranges the cards neatly as shown in the image, depending on the number of cards.

However, I don’t know how to arrange the cards neatly in the first place. (Is it possible to use “Spline” or something similar?)  
Also, I don’t know if this implementation itself is OK.

It would be very difficult to write down all the implementation methods, so please just give me an example of how to do it.

Thanks.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 26, 2022, 2:33pm UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/2 "2022-10-26T14:33:50Z")

</div>

I posted this today:

> [@UI drag and drop at a specific location in the 3d world.](https://forums.unrealengine.com/t/ui-drag-and-drop-at-a-specific-location-in-the-3d-world/676587/8):
>
> cards in hand are 2d widgets a 3d card could be an extended Widget Component (the method is [here](https://forums.unrealengine.com/t/steam-trading-card-hover-effect/250907/3)); or, ideally, an actor with extended WC. The actor would handle the player / board interaction and the attached WC would handle card logic. the board is an actor with a collision volume reacting to traces (the post I linked above) the card actors can be spawned dynamically and attached to the abovementioned volume. They don’t need to be attached but I feel it could make things easier in the long r…

Judging by the vid above, you wouldn’t need to physically place the cards down, would you now? Cards in hand can be 3D, ofc - but you’d need to work hard to keep the widget components looking _sharp_ - especially the text.

You can absolutely distribute them along a spline but rotating a vector would also work fine.

---

<div class="post-metadata">

**Author:** ![0u0high](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0u0high](https://forums.unrealengine.com/u/0u0high)\
**Post date:** [October 26, 2022, 3:27pm UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/4 "2022-10-26T15:27:24Z")

</div>

In the video I just attached, the cards do not actually need to be 3D,  
but what I am developing needs to be an actor because the cards need to actually be placed on the field!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 26, 2022, 3:29pm UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/5 "2022-10-26T15:29:48Z")

</div>

Hold a hand of 2d cards. Spawn actors with a widget component and place them on the field. What is the feature you’re currently struggling with? Hand distribution in a semicircle?

---

<div class="post-metadata">

**Author:** ![0u0high](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0u0high](https://forums.unrealengine.com/u/0u0high)\
**Post date:** [October 26, 2022, 3:34pm UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/6 "2022-10-26T15:34:13Z")

</div>

What I’m struggling with is the clean placement of the cards in the hand,  
ideally it should behave like a SlayTheSpire or Inscryption hand.  
I would like to be able to highlight cards on mouse over, etc.

---

<div class="post-metadata">

**Author:** ![0u0high](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0u0high](https://forums.unrealengine.com/u/0u0high)\
**Post date:** [October 26, 2022, 3:35pm UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/7 "2022-10-26T15:35:10Z")

</div>

By the way, in Inscryption, are the cards in hand implemented as widgets and the cards actually placed as actors?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 26, 2022, 3:36pm UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/8 "2022-10-26T15:36:15Z")

</div>

No clue, never played it but looks like a **banger** :

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/7/b/07b45631618bcc9cfc1c8867c67009f48cd28fa2.jpeg)

This, right:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/3/e/73e57f920a4eff62760fd44394fcfc73c04b6910.jpeg)

Looks like it’s all 3d

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 26, 2022, 3:38pm UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/9 "2022-10-26T15:38:11Z")

</div>

> [@0u0high](#):
>
> Inscryption

I now know what I’m doing tonight, though.

---

<div class="post-metadata">

**Author:** ![0u0high](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0u0high](https://forums.unrealengine.com/u/0u0high)\
**Post date:** [October 26, 2022, 3:40pm UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/11 "2022-10-26T15:40:58Z")

</div>

It’s a lot of fun.  
The most ideal implementation of cards like Inscryption.  
But I’ve never developed a card game before, so I’m wondering how it should be implemented.

What is the best way to implement this so that the cards line up nicely at hand like Inscryption?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 27, 2022, 7:35am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/12 "2022-10-27T07:35:21Z")

</div>

For 2D you could experiment with something along the lines of:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/f/9/df978c87a00398deea3406b740faa0f9d50e299c.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/c/0/6c0933c4d8c9a6fc5cdc1d455661918214aaae9f.jpeg)

Play with the values, see what they do, this can be dramatically improved ofc. The hand widget is just a canvas that spawns a bunch of widgets, shifts them around and rotates. Animations should be added to the individual card widgets. zOrder can be handled in the card or in the hand.

---

<div class="post-metadata">

**Author:** ![0u0high](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0u0high](https://forums.unrealengine.com/u/0u0high)\
**Post date:** [October 27, 2022, 8:37am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/13 "2022-10-27T08:37:40Z")

</div>

Thank you!! Can I replace this with an actor?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 27, 2022, 8:49am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/14 "2022-10-27T08:49:06Z")

</div>

Sure, why not. You mentioned a spline at some point:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/1/fd12dc2306c523f2da0308d7a7632b4212a4e7b0.jpeg)

The spline is attached to the camera:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/4/0/d403a2a4513b401e10094ecc65d35d8a14edc6c8.png)

The card actors get attached to the spline and distributed along it evenly. Each card actor has a world space widget component. You’d need to add rotation and so on, ofc. More logic to handle a varying number of cards…

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/c/0/1c07d4f7ed1af468aa65f4cfd1e27cd5f11cdfc7.jpeg)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/4/1/741367ac3129e107cea3e4f99afb69af1338de82.jpeg)

---

<div class="post-metadata">

**Author:** ![0u0high](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0u0high](https://forums.unrealengine.com/u/0u0high)\
**Post date:** [October 27, 2022, 9:01am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/15 "2022-10-27T09:01:00Z")

</div>

With Inscryption, the width gets narrower with the number of cards. is it possible to do that with Spline?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/e/c/7ec7a7f57c96b42a943ebdd1dd24d0343161def3.jpeg)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/7/a/47a050edf5c7ca0e1c560f52f96a786eba97f302.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 27, 2022, 9:02am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/16 "2022-10-27T09:02:52Z")

</div>

Yes. The default spline duration is 1s. You divide it by whatever number of cards you need and use it to calculate a step for the next element. Or you can edit duration itself. Or move the spline points. There’s probably as many methods of handling this as there are people.

Let’s say I had 4 cards and only want to use 20% of the spline to distribute them:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/3/3/c33e416bbabd22e9e46a303f47ef4bde0e6ada5a.png)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/4/c/e4caee716a192dee6a5a188cf29c731c9bb4b5ea.jpeg)

It’s somewhat flexible, could work well for what’s needed here.

---

<div class="post-metadata">

**Author:** ![0u0high](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0u0high](https://forums.unrealengine.com/u/0u0high)\
**Post date:** [October 27, 2022, 9:24am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/17 "2022-10-27T09:24:45Z")

</div>

It saved my life. Thank you.  
I tried to implement this as a test, but the cards are arranged like in the picture.(Sorry it is hard to see…)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/a/f/bafa5d6139330c4cd64ae6ad3d3d9fb22899e224.jpeg)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/f/2/5f21426ad421f6e31f2b903628295e217a9dc368.png)

---

<div class="post-metadata">

**Author:** ![0u0high](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0u0high](https://forums.unrealengine.com/u/0u0high)\
**Post date:** [October 27, 2022, 9:40am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/18 "2022-10-27T09:40:23Z")

</div>

The above problem has been resolved.  
The splines were in the wrong shape.  
What is the best way to angle the card?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 27, 2022, 9:45am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/19 "2022-10-27T09:45:05Z")

</div>

Not sure if you mean the order or the distance from the camera. Splines have input points, you shift them any way you want:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/8/8/88887f50d00b69e478b41b40d797a0cb3597b9d0.jpeg)

0 would be the beginning.

When it comes to what appears on top of what, this is fully 3d so the world location dictates occlusion. Reshape the spline as needed.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/5/5/45553cc5b37927473d8af7bd205d8ec0a2dd81d9.jpeg)

Almost certain this could be done with scene depth / post process. But we may not need to go as deep, ehm.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 27, 2022, 10:12am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/20 "2022-10-27T10:12:56Z")

</div>

The spline has rotation data:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/6/4/564422025aa86348f9c9624fc6f984e9dc5f8964.png)

To make the above better you could use the spline time location as pivot (currently the cards snap by their midpoints) and rotate from there. Or find a common pivot and rotate a vector around it instead. One way or another it’s a bunch of math you will need for other things anyway. 😃

---

<div class="post-metadata">

**Author:** ![0u0high](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0u0high](https://forums.unrealengine.com/u/0u0high)\
**Post date:** [October 27, 2022, 10:42am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/21 "2022-10-27T10:42:17Z")

</div>

Perfect!! Thanks a million. It’s looking pretty good.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/2/1/3213fb3274684f6e3c6a92cbed8bdbfd36edfe9c.jpeg)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/e/3fe6e305782f6f6d285b64648656ba6bb0c007fb.png)

If I only use 50% of the Spline width, I’m adding 0.5. Is there any other way?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 27, 2022, 10:44am UTC](https://forums.unrealengine.com/t/about-hands-of-card-game/677382/22 "2022-10-27T10:44:45Z")

</div>

I guess you could adjust spline duration. But the end result would be similar.

[Next page](https://forums.unrealengine.com/t/about-hands-of-card-game/677382.md?page=2)
