Check out my books, games and more!
Join our Discord:
Learn how to create a 2D card game in Unity with randomized decks and draggable/droppable cards using the canvas, C# scripting, prefabs, and more!
Continue with Part 2:
Project Git Repository:
Subscribe and like for more!
Take a tour of Unity 2D:
Check out my books and games:
Follow me on Twitter:
Music shout-out: “8bit Blix” by Micah Young
Nguồn: https://thedancingparent.com/
Xem thêm bài viết khác: https://thedancingparent.com/game/
George Maltez
June 28, 2020This is a great video tutorial. I've learned a lot and hope to improve and create something outstanding. Keep up the great work and thanks for dedicating some time to Unity.
TheGeneral
June 28, 2020I don't usually Like videos because of laziness, but this definitely deserves it!
Keep it up m8, looking forward to more easy to follow tutorials!!!
Randy Ladyka
June 28, 2020What are the camera settings? I can't seem to get it to match the size of the canvas.
Andrew M
June 28, 2020Very good.
Deniz Tuncer Tepe
June 28, 2020I can't drop more than one card into drop zone and it goes to everywhere except drop zone it doesn't sets it's position
Facehunter2003
June 28, 2020This 3 part series has helped me port over my friends card game to digital. Just mainly had to get the basics for Unity down before I could start scripting the rest of the game.
Hugo Zaragoza
June 28, 2020Great tutorial!!! Thanks for the clarity and the pace. Perfect!
Aryan Trehan
June 28, 2020Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption
I am getting this error. Any help?
Luca Laurence
June 28, 2020Hey Farzan! Really enjoyed the tutorial but I just had a question regarding the dragging and dropping. At first for me it didn't work properly and after some testing, turns out when you enable pixel perfect under canvas, for some reason you are unable to move the cards. Would you know why that's the case?
Anyways, looking forward to seeing the rest of this series!
n3rd
June 28, 202040:35 during this part, when I press the "Draw Cards" button I get an "ArgumentOutOfRangeException" error. I copied the exact same code as the one in the github link, so I have no clue what's causing the error.
Александр Кавокин
June 28, 2020Really cool tutorial! Thanks!
Baturalp K
June 28, 2020The tutorial is really helpful, thanks mate.
wancat
June 28, 2020Don't know if this is new for unity. I get the error:
Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption (GameObject: 'Card1(Clone)'
This is for when the Draw Cards script is run. How do you fix this?
Nicholas Young
June 28, 2020Oh my god this video was great, everything i was looking for and more. Subscribing for sure
Juanu Haedo
June 28, 2020Hey Farzan. Great tutorial!
Here is the documentation for doing the drop zone detection a different way.
You can do raycasting with the UI library and avoid going to Rigid Body which might be a bit overload for a Canvas based game.
https://docs.unity3d.com/2018.1/Documentation/ScriptReference/UI.GraphicRaycaster.Raycast.html
Having said that, it would be interesting if anyone did some tests on using the Rigid Body vs GraphicsRaycaster to see if by any chance, using the rigid body is more performant… or not.
Tanzra
June 28, 2020I want to do this on a website. Does this produce a .exe that someone has to install? I don't know if I'm in the wrong place or not. If I am in the wrong, anyone know what I could use to do that for the web?
Davis Nicholas
June 28, 2020Anyone has problem when trying to drag PlayerArea from hierarchy to gameoject?
I am unable to do that. I can drag and drop the prefabs but not the objects from hierarchy?
HELP!!!!!!
mehmet yalinbas
June 28, 2020When the number of cards is 4 in the dropzone region, what should we do to avoid accepting more cards even if we put them in that region?
JJ Lew
June 28, 2020Thank you for sharing this amazing tutorial – I found it super straightforward and easy to follow along!
Ravi Rajput
June 28, 2020This is awesome man!!!
Magzy Wagzy
June 28, 2020For anyone else who came here as an extra guide or reference point after setting up a screenspace camera for the canvas, if the drag and drop is making your cards disappear
if (isDragging)
{
transform.position = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
}
This will fix your drag and drop issue
So far this tutorial is much earlier entry point than the other series i'm following along with, especially with the "no more unity multiplayer" issue fix I see in my recommended side bar
Sida Ren
June 28, 2020Amazing tutorial!!! I really want to progress to the next video but my drag and drop isn't working. The problem is when I click the cards it dissapears rather then being able to drag. I have copied the script exactly up to 47:00 and have added the event triggers correctly
Steve S
June 28, 2020Super video.
What if you were coding a game like Magic the Gathering. Assume a player's deck has 60 unique cards. Is there a better way than in the script to create 60 public GameObjects, and link them? I suppose you might want a game card manager that serves the GameObjects by Id instead of dragging them into the script like you did for card 1 and 2?
maxfield H
June 28, 2020Great tutorial! I feel like just by watching it, it's giving me good insights into the Unity workflow. Which is appreciated, bc as you said, it can be a little overwhelming with all the options!
Chow Brian
June 28, 2020I'm completely new to Unity and you covered a lot of the basics in your video! thank you so much for your work and hope to see more coming!
John Burville
June 28, 2020Just finished this video and it is awesome. Well done. Cant wait to try the other parts. Thanks so much for putting all this time in.
John Burville
June 28, 2020Can I get the code?
Matthew Hudetz
June 28, 2020So when I try typing "GameObject" in the scripts, it doesn't turn blue like yours and it isn't an option to pick. Just doing object works though so I don't know if I'm in the wrong version or not. Also, if I'm in the wrong edition, does object still work?
ben currie
June 28, 2020Thanks for the video! When I am creating the canvas it is only doing it with a width of 640 and a height of 480 and won’t let me change the values. Any reason why?
rednaxelA1122
June 28, 2020This is a great video, it's easy to follow. Although, I had a problem when I tried assigning a colour to the background and areas, it would just remain blank. Any ideas? I'm running Unity 2019.3.10f1.
Greg Galloway
June 28, 2020I really wanted to like the tutorial, but the text size was so small with so little contrast that I couldn't read it 🙁
Would have been excellent otherwise.
Tianhao Zhang
June 28, 202028:51 I followed all the steps but it still won't display the card, it still produces clones outside the canvas.
Jadandlud
June 28, 2020Getting an error here. "The name 'i' does not exist in the current context."
Giorgos Markos
June 28, 2020when i type gameobject on visual studio it doesnt come as a highlited command.What should i do
Panagiotis Mourlas
June 28, 2020This tutorial is amazing.Clear instructions and exactly the kind of thing I have been looking for! Thank you and keep up the good work!
DenglishDesigner
June 28, 2020This was exactly the "basic UI for card games" kind of tutorial I was looking for! Thanks!
Zhaoyin Qin
June 28, 2020Thanks, very helpful!
احسان زارعی
June 28, 2020Hey farzan . first ty so much cuz during this tutorial i learned a thing that i need alot .second ,if i wanna make a uno game ,should i create 52 prefab card and enter them to a list ? for uno i need remove those cards when given to player ,how can i do this ?
Gustavo Hernandez
June 28, 2020Hello Amazing tutorial, but i been having a problem did everything as explain but for some reason the drag and drop is not working.
dimwood2011
June 28, 2020M. S. Farzan i know you have probably moved on to other projects but i do have a question if you have time to respond. I understand random range between the red card and the green card.My question is if i wanted one deck for one player game like solitare would i need to create 52 individual cards for this with the same script on each individual card? thanks i hope that makes sense
Tashenea Burns-Young
June 28, 2020Hey my code doesn't work i am trying to figure out why unity is saying that i need to use using static?? Can you help with that?
devtodev
June 28, 202026:00 from what I understand from general OOP and C#, the script you created by clicking on add component is independent/reusable code. That means the script is not encapsulated within the button object but just attached to it and that also means, you can reuse that script in any other game object. For rexample, create a 3d model of dealer and attach the script to it.