Develop Trading Card Game Battle System With Unity 3D: Part XIV (Targeting System & Message Manager) | Vladimir Limarchenko | Skillshare

Develop Trading Card Game Battle System With Unity 3D: Part XIV (Targeting System & Message Manager)

Vladimir Limarchenko, Game Developer, Unity3d and C#

Develop Trading Card Game Battle System With Unity 3D: Part XIV (Targeting System & Message Manager)

Vladimir Limarchenko, Game Developer, Unity3d and C#

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
3 Lessons (46m)
    • 1. Targeting System – Introduction

    • 2. Targeting System – Troubleshooting and Testing

    • 3. Message Manager

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

In this class/series we set an ambitious goal of developing our own trading card game with Unity3d and C#, mostly focusing on card game battle mechanics.

In this class we'll discuss 2 topics that are a must for each and every card game:

  • To assist players in picking targets for their spells and attacks, we'll make a targeting system that will consist of an arrow that will follow your cursor and a target icon that will mark the target for your action. You'll learn how to work with LineRenderers in Unity (LineRenderer will be used to draw the arrow)
  • We'll also cover showing simple text messages to our player. In our case, the only 2 messages that we'll show are: “Your Turn” or “Enemy's Turn”, but you can use this same system to show scores, notify players that the battle is over and display some other information.

With this class you will gain access to a compete, fully functional Unity project that is an example of a card game battle. The game mechanics are somewhat similar to Hearthstone: custom spells, hero powers, creature effects and so on.

Additional information:

  • The files showed in the course are downloadable from the link that you can find in the "Class Project".
  • The next class of this series will be published on 2017.01.05.

Meet Your Teacher

Teacher Profile Image

Vladimir Limarchenko

Game Developer, Unity3d and C#


I am a Unity3d and C# developer with about 2,5 years of experience in game development. I also have a scientific background. I got a Ph.D. in Theoretical Mechanics in 2014, but then decided to pursue my childhood dream of becoming a game developer. I'm mostly interested in making 2D games. In my opinion, a perfect game should have some tactical or puzzle element to it.

Over the last couple of years I've also worked as an instructor and created several courses on game development. Some of the topics of my courses are: making a 2048 game, building quiz apps, creating a simple virtual pet game, animating 2d characters, building an in-game character customization system.

I'm always willing to experiment and work on some interesting and challenging game mechanics.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.



1. Targeting System – Introduction: Hello, everyone. And thanks for watching the scores in. This lecture will take on targeted spell cards. So we want to have a card that will have this special targeting system. It will draw a target gizmo and an arrow. When we start dragging this card, I've already made some preparatory steps not to make all the same actions all over again. I have created a copy off our ordinary spell card. I've renamed this game object into a targeted spell card, and I prefab this game object so that unity knows that it's something else. And we're working on something new and first to start working on this game. Object. Let's bring in our target. I'll go to my assets folder sprites and I've prepared a special sprite for our target. And it looks like this. I'll just bring it into our scene and I'd like to have it on top off our card. First and foremost, we can change the sorting layer to be above everything. I guess so. We want to see these targets above all the other game objects, and later we'll see if we need to change the scale off the Stargate game object. We might want to make it a bit smaller because this graphic is white. You can change the color to whatever you want. In my previous project, I chose something red so that the targets will be nice, invisible on top off our characters and creatures. And I'll close this color picker to the Stargate. Game Objects should be a child off our targeted spell card game objects, so I'll do that whole drag the Stargate, and I'll make it a child off our new spell card. Now, as a child off the Stargate, we would also like to have this little triangle, so I'll drag the strangle into our scene. I'll also change. It's sorting layer to above. Everything will change its color, and I'll pick the same color that our red target has so that it's absolutely similar. I'll close this color picker and I'll make the strangle a child off our target. And we'd also like to have another game object as a child off our target, and it will be a so called lion render. So I'll right click create an empty game object. And for this game object. I would like to attach a component off type line render line Render is a special component that will draw a line between any number off points that are defined in this positions ary and there are lots off different settings, like our start color and our end color. I already know that for our start, Carl er, I have selected something transparent. So I brought this Alfa value all the way 20 and for our end color. I think we should have the same red color that we have on our target and on this little triangle that will be the pointy end off our arrow. And using line render requires us to create a material. So to do that, I will go to my Essence folder, right click. I'll create a new folder and I'll call this one materials. And inside of this folder, I can right click, go to this create menu again and create a new material. Let's call this one line material and I think for this materials Shader. I had it set. I'm sorry in this Manu. I had it said to sprites default and then I can select our game object that we also have to rename later and then I can drag our line material onto this element zero in our array off materials. I'll rename this game object to be cold lion render as well. And currently we don't have to worry about positioning off all these game objects because all the magic will happen behind the scenes in our dragging Actions script. And it will take care off positioning, activating and deactivating these game objects for us. For now, I'll go to our targets and spell card, and I'll apply only changes to our prefab. And this leads us to another interesting discussion, this game object that's cold targeted spell card. It currently has all these scripts, like Better Card Rotation, the Spokes Collider, one card Manager and Hover Preview. And in this case, we don't need to have all these scripts attached to our targeted spell card who have to bring some of the scripts off off this game. Object onto our new target game object, and there's an easy way of doing this, So first we can bring our books Collider. I know that we should have our books collider attached to our target game object, and I know that you cannot see this whole menu. But there's this'll item in the menu that is called copy component so I can select that. And it just copies this whole box glider component, and I can then reattach it to another game object. And to reattach this component, I can right click on any off the existing components. If you don't have any components like Sprite render, you most likely have transform so you can right click and select this option based component as new. And then it will attach our books collider to the Stargate Aiken. Now we can switch back to our targeted spell card and remove this component. So in this drop down menu, I'll select remove component, and we'll do this same thing with our hover previous creeped. So I'll quicken this little gear I can. Then I'll select copy component in this man. You go to our target right click in our Box collider. Select based component is new, and then I can remove this component from our parent card game object, so our card should be left with just these two components. For now, our better card rotation and our one card manager and our better card rotation currently tells us that it's missing a reference to our collider. Previously, it was attached to this same game object, and now it's on our target game Object soil. Grab our target and bring onto this field in our better card rotation and release. This way, our script will know about the existence off this glider, and then it leads to another interesting thing when we'll draw our line with our line. Render line Render doesn't behave in the same way as our sprites or our u. Y. In terms of these sorting layers. And what matters for line render is it's transformed that position. So whatever is on top of this land, render will be rendered on top. Whatever has greater said value than our line render, it will be rendered below our line render So to resolve this issue, I've used this interesting trick. For now, we can just set transform position off the Stargate game, object to 00 and we want to change its that coordinates. So we want to make it a bit closer to our camera, and I will set it to minus zero 0.1, for example, instantly by setting this transform position to minus 0.1. It breaks something. Our better card rotation script already thinks that this card should be rotated and facing with our back towards the camera. While this is not the case, and this card should not be rotated like this and it's happening because our box collider is currently not in line with our card, it is I don't know if you were able to see this, but it is now a bit in front off our cart and we want to bring it back. So an easy way to bring our collider back would be to go to this box collider and there is a public vector three, I guess that says center, it's that coordinate is currently set to zero, and we want to change it and bring it to zero point one. And I haven't noticed this behavior before. It seems like here we get to see some off our line. Render will get to experiment with our line render a bit later. But for now, if we switch back to duty mode, then our card should be back to normal because our collider is now again in line with the surface off our card and the only reason for doing this history. So the issue with the sorting order off our lion render later, and we can also disable the Sprite render on our target and on our triangle so we don't want to be able to see them, and we can also disable our line render. So all these graphical elements, when we're saving the data to our prefab, they should just be disabled, and later they will all get re enabled by our custom scripts. So now that we've come to scripts, let's take a look at them. I think the first strip that will use is in our assets scripts dragging, dragging tests. So we're still staying with these dragging test scripts, and we'll see the actual scripts that we use for dragging later because they rely on some of the game logic. So for our targeted spell card will select our target this time. So we want to attach these dragging scripts, do the game object that we're actually going to drag so well, grab our drug able tests, and I'll attach this script to our target game object, and I want to bring one more script or project. I've added it to our folder download scripts, dragging, dragging tests. And it is called drag on Target Test. And this stripped also inherits from our dragging actions test. And it will control the behavior off this Dragonball target and off our line render and off this strangler Arab. So let's bring it to our project as well. And I can minimize this window and I can drag this dragon target tests on to our game. Object. I've made this script out of one of the scripts that I've used in my test implications. So it has this public Inam field that is called targets. And here we get to select it can either have no target or all creatures enemy creatures, your pictures. And actually, we don't have to adjust this manually. This variable will be sat automatically by our other scripts. So for each spell, when the card figures out that okay, I'm this spell, it will check its card asset and inside off our card acid. There should be information about suitable targets for this spell. Now I'll apply all these changes to my prefab, and I'd also like to try and launch the game to check out if this works, so the spell guard loads to infer about our fireball. And if I try and drag this card, then I'm getting this error. So I'll exit play mode and check out what we have in our council. It says. No reference exception object reference not set to an instance of an object. And it turns out that, and I'll zoom in on this code in awake function. We've made an assumption that our triangle game object it is called triangle in unity, and in our case, it is called Triangle to. I guess so. L change its name to just say triangle. Then I'll apply these changes to our prefab, and I'll try to launch the game again. So now if I hover over this card and then I started dragging it, then it gives me another error. Now I'll double click on this, and it gave me this error object reference not set to an instance, often object again, and in this case it is nice to disable this maximize on play when you start her game. And there's also this one useful trick in the Inspector. You can right click on the name of the inspector and you can select the display mode for your inspector instead of normal. You can bring it to debug mode, and this way you will be able to see all the private fields. So our script Dragon Target test. It has to establish the connection with our targets Sprite render with our line render, it has to find the triangle. It has to find the triangle Sprite render. And it also has to find some other game object that is called target. So when we launched the game, we can see that it finds the Sprite render without any problems. It finds the line render as well, but it can't find triangle and it can't find the triangle Sprite render And what a started I don't know right now, so we'll have to check out our script. It turns out that this game object that is called target is unnecessary. So I can just lead it from our script. And it was used when we were actually determining what is the target game object that were dragging this spell onto. So it's a bit complicated and we'll look into this later. For now, I can just delete it and then there is some problem with our triangle, and I think that it might be caused by some spelling problems. Maybe, or maybe by organizing our game objects in higher. I'll figure out this issue and then I'll get back to you. Yes, it turns out that I had a spelling issue instead, off triangle I said Tree Nagel or something like that. So we have to make sure that all the spelling is correct, because this search for this game object actually relies on spelling. So currently everything should be spelled correctly. I typed in dry angle here and let's launch the game and check out how this works. So now if I hover over our spell card and if I start dragging, it seems like we're not getting any errors. But our script is not reacting to dragging, and we can see that by going to this Dragonball Tests and this check mark that is called dragging. That should go from false too true. When we start dragging our game object, it doesn't react to our actions. So I think that I'll sort out this issue and I will follow with a solution in our next lecture. So not always. Everything goes smoothly when you try to develop your applications. Sometimes things don't go as planned. And you have just seen it with my simple spelling errors of spelling the word triangle. I've wasted a couple of minutes on that, so I'd like to thank you for watching the scores and we'll figure out what's happening with our dragging script in our next lecture. 2. Targeting System – Troubleshooting and Testing: Hello, everyone. And thank you very much for watching the scores about card games. In my previous lecture, I've made several mistakes while designing this whole targeting dragging system. And I am not even saving my project from this lecture because this is just shameful. And in this lecture, I wanted to use this opportunity and to address all those issues and all the mistakes that I've made. So the first and the most significant ever that I've made was attaching a wrong script to our target game object. Instead, off attaching this drug able test with actions, I've attached another script that is just called Dragonball tests. And this is just the simplest script that we've used to explain those dragging concepts. And that script doesn't even know above the existence off our dragging actions. So when we had this drinkable test script on our card, it could not find our other script that is called drag on Target test, and it had no idea whatsoever about what we wanted to achieve with this set up. So now we have fixed this by attaching the correct script, and it's called drag a ble test with actions, and I'm sorry for this confusion later in our project will have just one script that will be called Drag a Ble and will have several other scripts for our dragging actions. So it will be much harder to make a mistake and attach the wrong script to our game object . And even for our Dragonball test with action script, I've introduced a little change into this script as well. I would like to open Monta, develop and show it to you. The first line appeared in this own miles dull method, and I've included comment that says New line. So when we first brought this script into our project, we did not even have our hover previews and our drug a bles. They should be connected with our hover previous. So when we're dragging something, our hover previous should know that they just should not appear during this time. So to ensure for that here, I'm saying, however, preview dot previews allowed equals false. So this, however, previews the whole class and previews allowed is a static property. And if we're setting this value to fools, it means that all the previous they will be just turned off and another line it insures that we'll turn our previous back on when we stop dragging our game object. So in this method on mouse up were saying how our preview previous allowed equals two troop . If we are no longer dragging something, then it means that we can hover with our cursor over our cards or our creatures, and we should see our previews. These are all the changes to our drinkable tests with action script. Otherwise, it works absolutely in the same manner as before. So we have already discussed how the stripped works, and now we can return back to unity. And I can enable this maximize on play option because now I know that everything should work. And if I launched the game, we have our card. It says fireballs. So we have to drag this guard onto a certain target. And once they start dragging the moment I press this button, this card returns back to its original position and all the previews they get turned off. And once they start moving this, I can first. If I don't move it too far away, then I have just this target. Aiken, If I start and this Aiken gets further away from my card. Then we also get to see this arrow, and then we also get to see our line render that draws a line between our card and our pointy arrow or our target Aiken. And another thing that's interesting about this story and because we have set our however previous to false if I'll hover over all these creature guards with my cursor. But then the previews will not be turned on. So our previous are currently disabled, and that's exactly what we meant by saying Harbor Breeze previews allowed equals false. And once I release this whole system of targeting, it will return back to this card, and I can now preview all these other cards and I can grab this card again, and this arrow will be drawn again in our scene. The only thing is, I guess I got the starting color for this arrow. Wrong. It creates this interesting Grady Inter fact, but it starts with white collar, and I thought that it will not influence our line render and because its initial color is transparent, it should be all red. But actually we can make this one little adjustment to our line render l Select our line, render game object, and for the start color, I'll select the color picker and I'll pick this second red color. So this line render should be of the same color in its starting point and in its final point. And it's Alfa Value in our starting point should remain the same. So I'll hit, apply and I launched a game again, and now we feed dragged this arrow. Then you can see that the collar just stays the same. So he goes from, absolutely to inspire intra to 100% not transparent red. And then it ends with this arrow, and with this Stargate, I will exit play mode. And now that we finally got this system working, let's take a look at our script. So L go to our target and this script drag on target tests. It is responsible for all this functionality, so I'll double click on it, and then we'll get to seed in our Mona develop. First, we have this public variable, off type targeting options that says targets, and it's something that will get from our cards for this particular Test street. We will not need this so I can just comment out this line. I'll go to file and hit safe. Then we have these private references. First, we have a reference to our sprite render. And because this script is attached to the same game object that holds our target than the Sprite render that is called S are it will be the Sprite Render off our target, Aiken. Then we have a reference to our line render We have a transform for our triangle and we have a sprite render for our triangle Sprite. Render in awake. We're getting all these components except for Sprite render We should get component on this game. Object for our line render. We're getting this component in a child game object. So we're saying get component in Children. Then we are setting the sorting Glier for our line render. And this way, I guess we ensure that it's above everything but line renders. They also have to do something with that Gordon A. So even if you have this sorting waiver set up correctly and you haven't said the correct position in that coordinate, he will still get some wrong results. So make sure that your line renders are not only set to the highest sorting layer, but they should also be on top of everything else in there. Is that coordinate? Then we have this shaky bids were searching for a transformed by name by saying transformed , Don't find were searching for a child game object that is called triangle and we are obtaining a reference to its transform. And here I've actually made a typo and we have fixed it in our previous lecture. So when you do something like this, you have to make sure that you don't have any typos. 100% later, we have this triangle s R, which is a sprite. Render off our triangle that is the pointy end off our arrow. And here we are saying triangle that get components right render Then in this method on Star Trek that is called by our drag a ble test with actions script we say as our dot enabled. So we actually start showing our target and we also say l r dot enabled equals True. So we are turning on our line render and we start drawing our line. We also have this method on dragging in update that insurers for all this behavior, off line drawing and correctly positioning and rotating our triangle, which is also very important. So here in the comment, I've said this code Onley droves the arrow, and it's 100% correct. It's responsible Onley for drawing our arrow, so displaying our line render and the pointy end off our arrow correctly, so none of the logic will ever happen in this method. All the logic only happens in our key moments when we start dragging this target game object or when we finish dragging our target game objects. And here we just do some math first, we're trying to figure out the direction in which we're dragging the Stargate, and we need this to rotate the pointy end off our arrow correctly. And actually, I think this line is a bit of an overkill. So first we're trying to figure out the not normalized direction, which is a Vector three that is just equal to transform position minus transform, not parent dot position. So transform parent for this game. Object is our card. So we're comparing the transform position off our target Aiken to the transform position off our card that makes sense than this next line. We're trying to normalize this vector, and by normalized, we mean that the magnitude off this vector will be equal to one after that. And then I have this line float, distance to target equals direction multiplied by 2.3 f dot magnitude, and I think that it will be always equal to just 2.3 f. I can just try to come and hear equals two and open a couple of question marks. So if you are curious, he can check this if you substitute. This line was just distance to target equals two going to the F, and it breaks nothing than this is the right way to go. And generally, it's not a very nice practice to have some magic numbers in your code. For example, there is no reason for having 2.3 F instead off something else here. So 2.3 f is just a distance that we have to drag our target from our card, and then it starts drawing the line. It starts displaying this pointy end off our arrow and so on and so forth. So we're checking, if not normalized dot magnitude. So this is the actual current distance from our transform position. So from the Stargate to our card. So how far have we drag this target from our card? And here you are basically saying if it's greater than 2.3 F So if we have dragged this Stargate far enough from our card than we make all these actions first we draw a line between the creature and the target, and it might not only be creature, it might also be a spell. So we're saying line render dot set positions, which is a method for our line render, and it takes in a Vector three array, so it might contain any number of points. And as the first point we are supplying the position off our card and as a final point, we're giving it this vector so transformed dot position minus direction multiplied by 2.3 f . So here, if we just say transform dot position, then our line will just connect the center off our card with the center off our target. But we don't want this to happen, so we don't want our line render to reach the center off our target. That's why we are subtracting this value off direction multiplied by 2.3 F, and we are also making sure that our line render is enabled. And next, we have to set the pointy end off our arrow into its correct position. So first were saying triangle as are enabled, equals true. And then we are accessing its transform position. And actually, we could have used this transform that is called triangle, so we could have just said triangle dot position. But this Wait, who else work? So we're saying try and go sour transform position equals transform positions. So we first said it to the same position where our target is, and then we say, minus 1.5, which is also a magic number, so you can experiment with it. And it will either make this pointy end off our arrow closer to our target, or it will make it stand further from our target, multiplied by direction. And then this moment is a bit tricky. We set the proper rotation off our arrows, and it is done by setting it's zed rotation. So we say, float rotations. That equals. And I found this method somewhere on the Internet, so we can actually figure out this angle like an arc tangent. So this is the opposite of tension. Tension is getting the value of tension from an angle, and arc Tangent is getting a value off angle from our tension. And then we have to also multiplied by math f dot radiance, two degrees. And then we also say triangle Asare they'll transform dealt rotation equals quite Ernie in So rotations. They're represented by these quite Iranians. And if you want to set your criterion in from just three rallies like it is in Inspector, they're actually cold air where angles. And here we're saying quote Ernie adult earlier, and we supply zeros as our X and y rotation. And as our rotation said, we say rotations at minus 90. So this minus nineties also important and I guess also founded on that solution on the Internet that I've used and else. So if our target is no that far from our card, then it turns out that we don't have to draw the line and we don't have to display the pointy end off our arrow. Then we're saying line render dot enabled equals false and triangle Asare dot enabled equals false. And when we have ended, dragging this game object, we said the local position off our target game object 200 and 0.1. So we have to remember that we've set the local position off this game. Object to be 0.1 in set coordinate to ensure that our line is displayed correctly. And when we returned this game object back. We have to use this 0.1 as as that coordinate for our transform and we are disabling all the renders. So the sprite render line render and our triangle sprite render they should all be disabled . This method drag successful is not used in this strip but because it's marked as abstract in our dragging actions test class Then I should override this method and here have just made this method return the value off. True. So in this lecture we have discussed how the targeting system will work in our game. We can return back to unity and ensure that it actually works and it will work absolutely the same for our creatures and for our spells in the actual game. So in the game, instead, off our test scripts who have the actual scripts. But this part that is responsible for drawing our target and our line with this pointy end . It will work absolutely the same both for the spells in our game and for our creatures in our next lecture will bring another simple visual system into a game that is a system off displaying a message for our player in my tests up, I had these messages displayed on Lee when our turn starts or our opponents turn starts, and it was just a message that was located here in the center, off our screen. And it said your turn if it was our turn and it said Enemy turn if it was our enemy Stern. So it had just these to use cases, and actually we could have used this system when the game is over as well. So once one off our characters is defeated, we can display a message that you want or your enemy one or something like that so we can figure out multiple uses for this message displaying system Animal added to our project in our next lecture. Thank you very much for watching, and I will see you in our next video 3. Message Manager: Hello, everyone. And thanks for watching this course. In our previous lecture, we have completed the discussion about our targeted spell cards and our targeting system in general. So if we want this arrow and a target gizmo or target Aiken to appear in our seen, it means that we'll have to structure our game, object a bit differently. And we've done that for our targeted spell card. And I've done the same work for our creatures, so actually have just copied the game object that is called Target from our targeted spell card. I've created a duplicate off this game object, and I've dragged it onto our creature game object. This creature game object had a box collider, and now this book's collider is attached to our game object that is called Target. I've changed the preview so that it's more suitable for our creatures, and I have saved all these changes to our prefab. So now if we launched the game and if we try to drag this creature, then it will also spawn this arrow with the target and it will let us select targets for are creatures Attack and I've also played with the settings off our line render, and our line currently looks a bit differently. So it turns out that you can vary the thickness of this line and you can select the starting thickness and the final thickness of the slide manually. So let me show you this as well. L exit play mode, and I'll go and find my line. Render game object. And under this stab that is called parameters, where we selected our colors. We can also select this start with and end with, So I think that it's pretty cool. And you can also experiment with these values to make your alliance and arrows look more interesting in the game. And our goal for this lecture is to make a message manager for our game to display messages like your turn or enemy stern or maybe display some other messages. It will have something else to show to our players. So I've added a new game object that is called message manager, and I've made it a child off our visual game object. I can enable message manager so that we can see it better. I've just copied our card back game object and then I've made several adjustments like for this canvas. I have changed its with and it's hate, and I think that I've also changed its scale to be a bit larger. And then I've called this game object that displays our texture the background. Then we also have our frame and the card back decoration that was on our card back. And this message text is also child off our canvas. I've added this outline effect, and I've played with the colors to make this game object look a bit different and not similar to our card backs. So visually, there is nothing new about this message manager. Just another cannabis with some you elements on it and in terms of scripting will have a custom script that will control our message managers behavior. And I'd like to open my folder with scripts Visual and here we should find this script that it's called Message Manager, and we can bring it straight into the same folder in our project. So I'll browse for the same folder in our project scripts official, and then I'll return back to this folder NL. Drag our message manager into our project, and this script gives us some error. So Let's open it in, model developed and check out how it works. And the reason why the script gives us all these errors is it already uses our command system that we don't have in our project. Yes, and we'll take a closer look at our commands in our next section. But for now, let's just check out this stripped and let's try to make it work somehow. So right here at the top of this strip, we have a reference to our text that it's cold message text, and we have a reference to the game object that is called message Panel. I think in our case, it will be the canvas game object. So when we disable the canvas, it means that we are not showing any messages in our game. Another important thing that we've done in our project. I think only ones so far. This script, that it's cold message manager is a singleton. So we have a public static, variable off type message manager, and it is cold instance and here in awake. So when our scene is just loaded, we say instance equals to this, so we'll have just one instance off our message manager, and we'll save it in this variable that is cold instance. And then all the other scripts. They can reference our message manager like this message manager, that instance. And then they can call directly all the methods off our message manager, for example, this public method that is called show message and then in awake. We also say message panel DOT said Active. And we said this value to fools. So if we were editing our scene and we forgot to turn off our message manager, then once the scene is loaded, it will make sure that we're not showing any messages and that we didn't forget to turn off our message battle or our message manager and this next method show message. It gives us this error because it takes in an argument off type command, and we don't have commands in our project yet and actually will not even need this argument off type command in this script. So I have switched to system off managing thes commands that is a bit different, so I no longer need to pass these references off type command to all my methods, and that's why I can just raise this argument. And I can also get rid off sending this comb argument to our 14 method. And I can also get rid of this command comb here. So this way this glass will be much more understandable. And if you have noticed, we haven't used that reference to our command that was called Comb. So actually, there was no need in passing our command to all these methods. But later, we should definitely have this line that it's Gold Command, Dawg Command execution complete because our message manager will show its messages through our command system. So for now, just not because any errors to our script I will common. Tell this line that says command, command, execution complete. And I'll type in to do here so that I know that I've changed something here, and they'll have to uncommon this line later. This glass has just do methods. The 1st 1 is public method show message and all of its parameters. Air now. Very understandable. The 1st 1 is string message. So what are we actually going to say to our players? And the 2nd 1 is float duration. So, for how long do we want to display this message. And when we call this method, all this information in just gets best to our Cortines. So we start a core teen and there's according of type. I am aerator that is cold show message 14. And the reason for having according here, is that we want to wait for this period of time off duration and only then we want to deactivate our message. So here, even before we show anything to our users, we say message, text a text equals two message. So we update the text on our message manager. Then we say message panel don't set active equals to truth. So we actually start showing this'll new message to our players. Then we wait for a certain period of time. So we say yield return. You wait for seconds and we pass in this argument off duration. So we wait for whatever period of time we have in this variable duration and then, after we have waited for this delay will deactivate our message panel by saying message panels that active and will pass in the value off false. So we have checked out all these methods and everything is great. This script is nice and simple, but we don't have any way off testing our message manager Right now, we don't have our command system and we don't have any means off calling this method show message, for example, to show our message and to actually see how this works. Soil right? A couple of flying's of code in this script to test all these mess showing features and then I'll get back to you. So I am back and we're still in this message manager script. I've added just one more method to this message manager. That is for test purposes only. And it's a method off our Mona behavior that is gold update. So in update, we're going to check if we press why on our keyboard, then we will call this method show message and as a message will say your turn and will show this message for three seconds. And if we press the letter E on our keyboard, then will show another message that will say enemy turn. But we're also going to show this message for three seconds. I have already saved this script so I can just jump back to unity, and now we should no longer get all these errors. I'll select my message manager here in the hierarchy, and I'll drag this script onto our message manager for our message. Tex, we have to establish the connection with our text and for our message panel. As I said, I will drag our canvas. So when we want to show the message to our users who enable our canvas and when we want to hide this message tenable, disable our canvas, I can hit apply to apply all these changes to my prefab. So I've also prefab this message manager, game object and now if I launch the game, several things will happen. First, our message manager will disappear and now we foot pressed. Why on my keyboard? Then I will see this message, your turn and it will last for a couple of seconds and then disappear. If a press e on my keyboard, then we'll see this other message enemy turn, and it will also disappear after a certain period of time. Now you can make a more complicated message manager, For example, you can fade your message manager when it disappears through using our canvas groups and using that Alfa value to control the transparency. Or you can use your Tween ing engine to make it appear from some direction or to make a change in scale when it appears and become smaller again when it disappears. I actually think that that's the way they show those messages, your turn or your enemy Stern in Harsh Stone. So you might also do that. But I think that our script is just very simple, and it does the job so will not add anything else to this message manager, and this lecture will be the last lecture off this section in this section. We've done some preparations to finally switched to making our game logic and in our next section, who talk much more about game logic and will add much more functionality to our game, like actually drawing cards from the deck, actually playing them from hand, attacking with creatures, taking damage and so on and so forth. I would like to thank you very much for watching the scores, and I will see you in the next section of this course