Unity Game Tutorial: Board Game - Ludo 3D | Octo Man | Skillshare

Unity Game Tutorial: Board Game - Ludo 3D

Octo Man, Let's make your dream game a reality!!

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
65 Lessons (7h 7m)
    • 1. #1 Introduction

      3:51
    • 2. #2 The Concept

      11:42
    • 3. #3 Setup and Import

      3:57
    • 4. #4 The Route 1

      8:21
    • 5. #5 The Route 2

      5:10
    • 6. #6 The Outer Route

      5:11
    • 7. #7 The Final Routes

      8:16
    • 8. #8 The Bases

      4:25
    • 9. #9 The Stone Selector

      5:55
    • 10. #10 The Nodes

      3:03
    • 11. #11 Stone Variables

      7:19
    • 12. #12 Creating the Full Route

      9:06
    • 13. #13 Finish the Full Route

      3:10
    • 14. #14 Stone Movement 1

      10:03
    • 15. #15 Stone Movement 2

      5:54
    • 16. #16 GameManager Playerlist

      7:03
    • 17. #17 GameManager Statemaschine

      5:16
    • 18. #18 GameManager Instance

      3:08
    • 19. #19 GameManager CPU rolls Dice

      7:54
    • 20. #20 Red Stones Setup

      3:02
    • 21. #21 Check Start Node 1

      6:50
    • 22. #22 Check Start Node 2

      4:19
    • 23. #23 Leaving the Base

      6:53
    • 24. #24 Update Node GameManager

      5:23
    • 25. #25 Check Possible Move

      8:00
    • 26. #26 Check Possible Kick Move

      7:36
    • 27. #27 Making a Move 1

      5:07
    • 28. #28 Making a Move 2

      9:43
    • 29. #29 Adding the other Stones

      8:43
    • 30. #30 Switch Players

      9:30
    • 31. #31 GameManager Update

      6:49
    • 32. #32 CPUs can move

      3:03
    • 33. #33 Return Kicked Player

      6:13
    • 34. #34 Protect After Kick

      4:31
    • 35. #35 Recap

      5:34
    • 36. #36 Re Roll when 6

      3:21
    • 37. #37 Hopping Stones

      14:23
    • 38. #38 Hopping from and to BaseNode

      3:13
    • 39. #39 Check for Win

      6:20
    • 40. #40 Human Input 1 Dice Button & Statemaschine

      10:37
    • 41. #41 Human Inout 2 Selector Management

      7:26
    • 42. #42 Human Input Roll Dice 1

      5:37
    • 43. #43 Human Input Roll Dice 2

      7:49
    • 44. #44 Human Input Roll Dice 3

      10:17
    • 45. #45 Human Input Roll Dice 4

      5:01
    • 46. #46 Human Input Move Stones

      8:34
    • 47. #47 Dice Model Setup

      5:35
    • 48. #48 Dice Make it Physical

      4:52
    • 49. #49 Dice Dice Sides

      5:17
    • 50. #50 Dice Script 1

      6:20
    • 51. #51 Dice Script 2

      5:13
    • 52. #52 Dice Script 3

      5:16
    • 53. #53 Dice Script 4

      4:29
    • 54. #54 Dice Roll Dice 1

      9:55
    • 55. #55 Dice Final Steps

      6:47
    • 56. #56 Info Window

      12:48
    • 57. #57 Random Player Starts

      2:36
    • 58. #58 Main Scene 1

      9:55
    • 59. #59 Main Setup Toggles

      10:19
    • 60. #60 Main Setup StartButton

      5:23
    • 61. #61 Load Choosen Players

      4:15
    • 62. #62 Save The Winners

      7:55
    • 63. #63 Game Over Scene

      5:11
    • 64. #64 Game Over Screen Update

      7:30
    • 65. #65 Conclusion

      4:33

About This Class

In this Course you'll learn how to create the board game Ludo 3D with Unity Engine. Board games a quite popular even on mobile or pc. I will show you step by step how you can create Ludo.

This course is a Beginner course, so if you have trouble in any case, write me a message or Q&A, and i'll help as best as i can.

If you are beginner, you might have some trouble to follow, but the videos will guide you through the complete course. Don't forget you only become better if you repeat things and keep on learning!

So we create Systems which will give us the freedom to:

C# (Monodevelop)

  • A path system to create our own playfield

  • A statemaschine to handle all players / cpus

  • A node system to know who is where

  • AI which is able to play completely alone

Unity (2018.2)

  • we create a playfield

  • we create a GameManager

  • we create a main menu scene where we can pick who wants to play

  • we create a game over scene to see who are the first 3 players

Course Material

I provide the following Material with the Course:

  1. 1x Node 3D Model

  2. 1x Stone 3D Model

  3. 1x Dice 3D Model

  4. You have to write the code on your own, i do not provide the final scripts!

All other graphics for Menu's, Icons, Images or Buttons need to be created on your own.
All Materials i provide are for education only and should not be in your final release!

Conclusion

In the end of this course you will have a fully functional Ludo 3D Game.

So what are you waiting for?

Let's make your dream game a reality!!

Level: Beginner
Video Course Length: ~7 hoursĀ 
Unity Version required: 5.3+

Transcripts

1. #1 Introduction: Welcome to the introduction video off a Ludo's three D tutorial. Serious what we will create in this complete tutorial serious is a four player game which can be played by CPU or human. We're gonna go over toggles and talk of groups and how we can actually make use of those especially make use off the settings were going to do over here. Then we give us this pull the possibility, of course, to start the game. And whenever we're starting the game, we get some notifications and choosing randomly who has the first turn as well as what he has ruled. Even if we see that on a physical dice over here, whenever the physical dies, is acting off course the CPU no reads the information from the dice and knows how far it can go. We're gonna create all this hopping animations. We're gonna create the passes. So are they know where they have to go to. We gonna create some game overseen later on to tell the player who has actually one off course we're going to see this. Meanwhile, we gonna make sure that we also have the positive possibility for human input and let me show that pretty quick. So you gonna Yes. See what? Actually a human player can dio, for example, I want to be the yellow human player over here as a green starts for us the second time. This is totally random. So keep that in mind. When evergreen is done, I'm the next one. I'm yellow player over here. I get the possibility to do some input. Like with this little rule dies button. I can roll the dice on my own. I don't know what's coming. And since this is completely physical, we have no choice or no chance to manipulate this one. So whenever there's coming input for me as the yellow Player, I can absolutely check this one out. Once again, the CPU knows all the rules. Are we gonna tell him all the rules about? Okay, if the atar starting notice full, then you have to Yeah, move somebody else because you cannot go and throw six and go in the same spot. And also it tries to go inside over here. Also, it is able to measure who is who. He can kick out of the game, actually. So whenever somebody is closer, you will actually try to get this dude out. So now I have a six over here. I can choose one off my players. Whatever I want. Doesn't really matter. I'm gonna pick maybe this one and is going out automatically. I can roll the dice again for human input. And now I have the possibility, Teoh, send out my player five steps over there, and then the blue player has its next turn. Whenever you're done was the course. You are able to play against other human on the same device, of course, as well as play against only CPU on Lee. Let the CPU run the company game on his own. The dice also has a reroll possibility whenever it's stuck somewhere or whenever it not returns anything and we can basically take care of anything on our own. Now you can see was a six. I have the possibility to go out with the 2nd 1 or move with that. I'm gonna move out since Well, probably why not? You know, And then now I can decide if I want to stay here and take this or this. So they're all these options are going to be shown for the player to know. Which stone can he actually use? Once again? All of that content will be teached in this course. So don't wait longer. And let's make your dream game a reality CEO in the course Bye bye. 2. #2 The Concept: Hello and welcome to the course. My name is optimum. An in This is the concept video about the Ludo game we're going to create in this connects couple off hours off this particular video course. So let's dive into it at first. What is Ludo Lou is an old board game where you have a base with your let's say player stones. And once you hit is six or dies a sex, you're gonna lend on the first passport of a year. So your yell at your stone is going to go out of the base. What we can now do is with whatever number we're going to dice between one and six, we gonna go, Abol these Littlefield's over here, and we need to make a complete way around the Playfield ones. And whenever we're hitting this last tile off the outer route, I would say you're gonna go into your Yeah, let's a garage or whatever it is called. So the game idea in this case is you need to get all your stones into your garage. So this is the main idea. And the point is, all of the other players are going to do our aim for the same goal. There are some rules inside the game field. For example, if you are going to be here with your stone and somebody else is coming to your field, your stone goes back to the base no matter where it is on the outer route over here. Same for the other ones. You can also do the same to these guys. So if somebody is sending like, the red guy is going to be over there and you hit it directly with the number which is matching this field, he has to go back to the base and start from the beginning from Hiss. Start field, of course, And going the complete round until he's able to get this. And who is ever filling this base or this Garage Fields was all his Stones is going to be the winner of the round, and all the other ones can basically come afterwards. Like whenever the 2nd 1 is going to be 2nd 1 certain insert one and the last you know it's going to be the last one. So even if he's not matching or actually fitting inside his garage, Okay, so now you know what's going on with Ludo. In this case, I have a mini version over here as on my on my urge. But usually this is going to be played with four stones instead of two. This is just for let's say, protesting purposes. And of course, for you how to learn this once again. In the end, we're gonna have four off each stone, basically for each color of the base. And that's what we're going to dio. Okay, so let's talk about the mechanics behind the game. How what? We're going to dough in this particular course, What we gonna learn off cause and what we after gonna zoom out a bit? So what we're going to start with is the game managers of the game images basically keeping tranq off? Who's going to be actually the next player who's the current place and so on? And so force. Also, we're going to create a state machine based on different states. The players can or have to be in, like one state in particular can be ruled the dice. Then we have a waiting state where we are waiting, for example, for input or the calculations done by the CPU we're gonna talk about that in just a second , as well as probably waiting for humanizing or human inputs whenever we have a human player . So this is what that is. State Machine is doing it, switching the states between whatever we're currently in. And of course, go bank it, Teoh wherever it has to be, switching to the next player and all the other stuff is going to be like that. So this is all what the state machine is going to be about. Nothing more, I would say. Also, the game manager keeps track of all the possible players on and the player in some kind of player list. Then we're gonna have each player each entity, I would say, Oh, each player has his own stones, a name. And, of course, what is the type off this particular player like human or CPO? So end. Of course, all of these stones are going to be this part over here. All the stones? No, about all their own routes. They're gonna be calculated automatically based on this starting field off the space and whatever all the notes are going to be is like this is note number zero in this case, when your player, you know, play a yellow And of course we're gonna take care of all the steps. Meaning what is the dice number? We have actually rolled and then account everything downwards. So we're reducing steps as well as reaching our point sooner or later. So the stones keep track off our off themselves report back to the state machine whenever they're done doing this job, like moving from one point to another and so on and so forth. And so the circle goes on. So this is what we're going to create code wise. And let's talk about pretty quick about the CPU because this is going to be a resident resting one. I'm gonna skip the or keep back the human for a second. So whenever we're super you player, we want to make sure that we are able to rule the dice. And what we need to know now is what is going to be the role number. So CPU knows, Okay, I have roll the sakes or I don't have rolled a six. If we have a role, the six we need to make sure that nobody is on the base field. So if one is on the base healed, then we're gonna make sure that we're testing. If the note is empty, like the ones again, the base field is going to be this one of a yes of the very 1st 1 for the red one. That's going to be this for the blue. It's going to be this for the green Off course is going to be this. So whenever this base noticed empty, we can actually send out the next stone. So we talked to our stone, which is currently the next one. We're gonna pick the tone and sent this one out by code. Then we're gonna do a reroll because we had a six. And this is also another rule which we can make. Use this and that way. And there are several possibilities for doing this. So in this case, when we're going out, we're gonna do reroll so we can actually make another one. Reroll means we just go back to the rule dice functionality like basically, we go from the state machines part back to rolling the dice instead off switching the next player. So whenever the bass note is not empty we're gonna have to possibilities for that. So the 1st 1 is we're going to have the same idea off the stone. So it's our own stone. Then we need to make sure that we're gonna check for with the with another stone, basically. And I need to tank. What are other? Yeah, possibilities to move another stone instead of moving out. Because we need to make sure that the basis always clear like we don't. We shouldn't have one stone whenever we're trying to go out on the base. But we keep the base as it is, so we can basically keep it. Also on this the space Also, there are other rules which are saying okay, you never have to stay on one based tile or on the bass note in this case. So there are several possibilities to play Ludo in total. So we gonna attack if we can kick somebody. So once again, the CPU is checking, cannot kick somebody with any of my already outplayed stones. And if that is possible, of course, if it is capable, then we're gonna move the one woods can do the kick. Otherwise, if there's no kick a ball we're gonna check if there are possibles. We're gonna basically do this in here. And you, you make use off the next possible stone. Or in this case, is there are more than several possibilities. We're gonna move around them one so that we can to keep this randomize basically. And then when we're done with that, we going to switch the player. But we can also, if we have, let's say we moved or we had initial six over here. We could also perform a reroll once again. This is something we can or you can later on decide on your own. Since you will understand how this is going to work, usually I gonna go and switch the player even if I have rolled a six. So I keep that Ah bit, let's say more. Yeah, more interesting, especially for small games. It is probably better to switch the player early. Once again, you can also keep the six rules so meaning if somebody yeah, rules the six we can or had ruled the six before. We can also use a reroll. So basically, we're gonna do the same s year. We're gonna move instead of moving out we're gonna move our stone. And instead of switching the player, we're gonna see, um, what's whatever the input has been or the number has Bean, if it has been a six week into the reroll, if it not has been a six, then we're going to switch to play. This is also possible. Nothing fancy at all. So And if nobody is in the base, we're gonna tank and once again go from this node, like when we have one in the base. And if we don't have one in the base, of course, we're gonna check for all the possibilities and kick a bulls and tone and so force. And if we have another number than sex, then of course we're going to do the same route from here. That's why I painted the arrows to this point. So basically, this is what the CPU was going to dio, and once again, we need to make sure that we have at least one in the base. Otherwise, this complete part is going to be unnecessarily so Ah, this gets skipped and we have none in the base. Of course, we're gonna take all the outs plate. Ah, here stones and gonna make sure that they are movable. Okay? And when it comes to human, then we're gonna need some inputs, actually, So it for us, we want to make sure that we gonna get a button activated when ever the human has its turn . And whenever we're pressing this button, we're going to rule the dice, Of course. So whenever we're hand having a sex, we want to make sure that we highlight every possible stone, no matter which one. So even if it is outplayed or is still in the bays, depending on that, basically, we're gonna make use of the same rules as the CPU does. We're going to highlight those. And we also want to do is of course, we want to make sure that we are making them selectable like we can actually click on one of these stones whenever they highlighted with a circle or something around them, and or any other kind of highlight system that you can play around with Dad light on. And whenever we are doing an input, we're gonna perform the same action. And of course, there's the same calculation of a here, like as we have done over there. Whenever we're done with the movement, of course, we want to make sure that we're switching the player or we're gonna do reroll depending on if we haven't used to six or not. Once again, this is what we can take care off or talk about later on. Nothing fancy at all. If it is not a six, we gonna make sure that we gonna check if there's any possible turn at Also, once again, we highlight the possible. But at the same time, we'll also see if there's no possible thing. Of course, you want to make sure that we're switching the player as well as whenever we're not rolling the six. We still want to highlight the possible ones and keep on the same route over here. So nothing fancy was that? I guess so. The player input is going to be the easiest one since it basically just copies parts off complete year. Scipio calculated stuff over there. So this is our roadmap for our complete yeah game, actually, and there might be some rules we're going to implement later on. Or, of course, if you have any questions to implement several different things feel free to ask them in the comments or whatever it's called a Q and A section, for example, or you can just leave a message for me. So let's start with the course. I hope you gonna get the idea over here and let's dive directly into it. 3. #3 Setup and Import: welcome to the course or welcome back. Actually, in this part, we're gonna do the first basic set up. So first off, what do you want to make sure? Especially if you're a beginner in unity. Make sure that the consul window is always seen as well as the game. Move you as well. So, seeinyou. If you like the Senate, as I am using it for your free to copy and paste, sir, just basically you can drag around all these pieces around wherever you want to have them, or wherever you have thinking, you're going to make use of them. So I gonna direct my consul here. Game viewers on the bottom left seniors in the top. This is important because you want to, because this is going to be a raise. A code heavy course You want to make sure that you always see the consul And if there's any arrow appearing, usually you only see this in the very bottom gray row and ah, we want to avoid that were probably missing one of thes. Also, we're gonna see everything in debug mode whenever we're debugging. Things that were instantly see at the concert is giving us the correct results. So keep that in mind wherever you put the inspector the project window as well at the hierarchies, completely up to you. For me, it is going to be like that. I always have my inspector here on the right so I can see the full parts off. Yeah, off the inspector and con scroll down at new content to that s and so on and so forth. So all of that is up to you. And of course, you gonna have to think about it on your own. What you want to do now is you want to under the course material full them and or a zip file inside you're gonna find to FB X files, a node and a stone. What you want to do is whenever you have exported that you want to create a new full and name it three D morals. You want to make sure that all of this content is going to be clean up and you do not mess up your complete part of the here. So once you select this read immoral solar, you can drag in the note and the stone FB X files into that and they will be important imported automatically. I'm currently, by the way, using unity to care 18.2. So if you're using a Newell the version, make sure everything fits to your needs. In my cases, since I have ambit material on the node, I need to make sure that I go to the materials tab and choose use extra external material libraries and because I gonna have to apply the changes whenever it comes to that I have a border. Your material now in this border material stole the same for the note. There's my texture. So if you don't have that, of course, make sure that you export that correctly from the F backs or just use ambit media total. So it depends on the unity version. Everything is different. Some of these are doing or some older versions are exporting these materials automatically . Once again, this is up to you. What you also see is that the border is a great Keller Over here, you might want to give it a white tint, so you don't have any problems in seeing those fields for that. So whenever you don't was that you can't do the same for the stone. As you see, there's no material on it at the moment. You can use legacy material, etc. As well if you like to, but you don't necessarily have to. It will be called no name, since there's nothing on it, and you want to make sure that it is completely white or basically doesn't really matter about the color. If you don't want to use the known A material or you don't like no other name, you can always go and hit F two to read. I'm it, as well as giving it any color or whatever you like. And please, if you don't like this three D models I have delivered over here, you can absolutely go and create your own ones. And once you're done was importing your own or mine, we're gonna go to the next part 4. #4 The Route 1: welcome back to the course in this part. We want to create our first outer route or assets a script for the outer route to start ways. What you want to do is you drank one of these notes or no tiles into that, and you can see that the pivot point is going to be resin on the top. So this will always be at 000 and position. So whenever we're putting a stone on top of this, yeah, which gonna have It's a pulque pivots on local pivot directly on the bottom. Over here, this will always match. So what we now can do is we can basically drink this around wherever we like. And please, Of course, we can match the grid off the unity grid as it can see its one meter by one meter and my fields, or this ones are going to be like this as well. They're also one meter by one meter. I can snap them by holding down the control key. And of course, I can duplicate them and direct them wherever I like to. So what I can do? I can now design the playing field on my own and you can do the same. You can ah, basically think about them. Even make ah straight or let's I Diagne Elaine's or lines, whatever you please in like this is once again a design decision you laid on have to make on your own. But we're gonna start with two tiles at the very first What I want to create. Now it's around. So the stones No, where to go next. And we gonna have a list off these particular stones or let's say it's transforms, which is going to represent the position of that. So we can actually hope from this point to this point with our Playfield Stone. At first, I want you to make sure that we're creating an empty game object you can. But you don't have to can resent this one to be 000 so we can actually put all our tiles as child objects to this route object. And whenever we're moving that we gonna take all the tiles, Wizard. Also, whenever these are a child of it, we can loops for them. Let's do that. I gonna add those two notes now to this game object, and I gonna name this one to be the common route. This common round will be the outer route, as I explained already in the Pro Vo. Or let me pretty quickly go into this represents this outer route over here. So we can basically design that however we like to once again we can make it a four by four . So this will be longer, so five on each side, But this we're going to stay the same. But once again, this is the design decision we have to make anyways on our own, or you, in this case, on your own. What? I want to create them with the script which is sitting directly on this common route which is looping through all the child objects and creating this route automatically for me or for us. So in that case, we're gonna go to the assets, will the right click and creating new folder, and we're gonna name this script since all our scripts will be now land into that, there are a couple of scripts we're gonna have to create. Not much, but we want still make sure that all our yeah things were working on always organized. What I want to do They want to create a new season of script, Of course. And I name it route if there's any Ah, naming convention problem was newer versions off unity. Make sure you re name this one toe whatever you like. So this is going to be any route we're gonna create in a second also what we want to make sure that we add route to the common route Game object once again, the empty one. So let's open this one. Nothing more. No develop or visual studio. Mono develop is not You had developed anymore basically. So you probably are using visual studio ready. But if you want to make use off Monta developers Ideo you can go to an older version. I believe it's somewhere in Unity 2017 Something is going to be the last model developed release and probably you find some other ones as well Maybe a single build anywhere. Okay, so once again, you can use everything you like in please. Ah, we don't need update in here because we're using some and lets a gizmo stuff as well as creating some functionalities at first this route need to know everything about its child notes. Like all this note fields we have created already in this case too. What we want to store is there transformed values in an array. So on the res created with the square brackets over here and we're gonna name it child notes and and the line was a semicolon, its usual. Also, we're gonna create a list which is basically nothing else than a ray. But it is dynamic, so we can always clear stuff into or put a new continents on. It will always reduce and increase the links off that. So unless it's normally, a dynamic array of ray is usually aesthetic one. So you cannot direct the, um, changed the lengths of an array because you have to pre set the lengths already. Okay, so what we need to do it is important that this is a public list because later on, we need to request some things over here of, like, basically positions and all this notes where we want to talk to at least once. So I'm gonna name this And this is the list of type transform, of course, because we're gonna store all the transform information, and we give it a name, so it's going to be our child node list, and we need to initialize. That was new list of type transform, open close parentheses. Close the line with this in my column so we can directly excess it. Now. What we want to do is we want to fill the list of nodes based on the tired notes for that as the help of function, we're going to create a new void. Fill notes open close parentheses for function itself an open call. Curly braces to do so. First off, we want to make sure that we're clearing the child node list. So, child note list Don't clear this will just empties or empty the complete list because we're going to look several times through it or probably have some old notes inside. We don't want to, especially when were laid on building this game together. So we want to do is we want to add to our child nodes array all its ah, your possible transform components. So what we need to talk to is we want to get components with an S over here in between. Make sure they're gonna uses get components in Children. And the type, of course, is going to be the transform type. Because we have a transformer ray open close parentheses. Close the line with a semi colon. So now, when Phil notes get called child, not get the list gets cleared and the transform tired notes over here gets filled by all its transforms. Basically, in start, we want off course, make sure that we feel the nodes. So we're gonna start the function whenever the game starts and do this just once. Next one is we want to make sure that we only add the correct notes to our child note list because that's the one we want to access later on. What we can uses a four loop or for each I gonna show you how for each look works. So for each open, close parentheses and now we need to talk to it. So for each type transform, we're going to give it a name. I gonna name it, maybe child in. And now we want to take the Titan with Ray so entire notes. So for each transform type in the in the child notes yeah, array. Over here, we want to perform something in this case where we want to make sure sent. If this current child were looping. Throw is not equal the same one as the route. So there start transform Onley. Then we want Teoh. Add all this to the tight note list. So take note list, don't add. And what do we want to add? Is going to be the child we're currently looping through? Once again, we want to avoid that. The route itself is going to be inside that list because the route is not part off the actual year note list. That's why we need to actually make sure that this is not part off this particular child note list. 5. #5 The Route 2: welcome back to the course in this part. We're going to continue our route. If you have saved as probably I expect you to do it. You're gonna have now the route script with a child note list with size of zero. What I want to do is I want to automatically fill that list right now. I mean, it would whenever we're starting, the game would automatically start to feel the notes inside this list. So, as you can see, the first note is going to be this one. The 2nd 1 is going to be that. So this basically works already on start what I want to do the one toe basically visualize that part with an Andhra gizmos function. So what we're gonna create now is a void and call this on drawer gizmos. It is important that this one is going to be 1% Lee correct. Italy written. So it was a big go big D and Big G and of course, was a Z and in yeah, in between. So what I want to do is I want to draw some lines in between those notes so I can basically see who is connected to who and how do we do this? I create i gizmos dot color first, I can't in this one and I want to make this one to be colored on green. You can take any color you like or you can even skip it so all the lines will be actually white the next one I want to perform its feel notes Since I want to make sure that the list is automatically your filling itself on whenever on drawer gizmos is called so and now it Once this list is filled, I want to look through all the notes which have been filled already and draw lines in between those the easiest ones using a for loop. So we're going to create a lot of four loops over here. Follow basically can be created by typing out four and tab the tablet button twice on your keyboard will be automatically creating this for look for you. So what we want to do is we want Teoh say Okay, we're going to start with a letter. I is going to be represented a number zero. And while I a smaller than our child note list dot Countess of the lengths off the list. We want to increment I by one. Whenever we're doing that, we're gonna loop now through all possible child notes or poor for every part of your child note and all. And see if we can draw a line between those points on those notes before we can draw a line . We need the vector from the current position to the next actually note position. In that case, we create a Vector three and name. It may be pause or current position then we say is equal to child, not list in square brackets. Now we need to set the current looked through index. In this case, it's I because this is the index where we are starting at and zero, by the way, is two zeros element in the list, of course. And then we want to take its position. Since we have the child knows load full, off, transform information, we need to make sure that we are putting this one into a vector and actually store this in pos. Well, we know want to do is only if the list is longer or actually I is higher than at least zero . So we haven't least two notes inside of that, we're going to draw a line. In that case, we say, if I is bigger than zero, only then we want to draw draw that. So we're not starting at the first eyes. But at the second now we want to create another vector, which is going to be the previous notes. Although note were coming from actually by looping through is equal to the child node list in scrap briquettes I and then we need gate this by one, and then we're gonna say Don't position. We basically can also do it the other way around basically doesn't really matter. We can basically draw from the current one to the next, but we need to make sure that we don't overflow it. That's why I go the negative way. So and what we want to do is, of course, we want to draw our line. So we say gizmos a daughter draw a line and now we need to have two vectors, as you can see. So we want to draw our line from our previous position. So prev calmer. And then to our current position, it's going to be pos. Don't forget to save and let's go back to unity and check it out. The list now should be automatically filled with all the course suborning notes inside of ah, this route list. And as you can see, no fancy stuff at all. And we're gonna see a green line coming from this center point and going to the next Centrepoint. I hope you can see this, but I guess so. Whenever we are now dragging around this piece is this line will always be drawn in between the first and the 2nd 1 When I duplicate this one Right now, you can see that these are now connected to each other. So this way we can make sure that our route is going to be correctly drawn in off course, all tiles are correctly connected to each other. 6. #6 The Outer Route: Welcome back to the course in this part. We're gonna create the first game route and, of course, make sure that everything fits our needs or your needs. Basically, it depends always on how you want your little game to look. So once again, you have the possibilities to actually keep all the fields next to each other like so. Or you can also go into take a space. It's more one in between basically doesn't really matter. Same for the height or the size of the game field at all. You can make it so that you only make use of two Ludo stones, as I have shown you end being escape like in my concept that you like this. But this is not going to take long to finish one round. So you want to give the player more playability. In that case, we can also go in and create a way bigger Playfield. This side is going to be just one side where the base is going to be somewhere here and in here. They're going to be three like that. So what we want to do is of course, we want to make six on one side off here. I guess it depends once again on how you want to make it. So if that is a base field that we need 1234 So until we are basically having all this fields inside of that so and the next field can be now here. So all these fields will basically hit the center point. Except the center itself will be free. And you can also do it this way. So you're gonna have more space in the center if you need something. Well, probably I gonna create it this way. So we have four on one side, and number six will be on here. Now, we're gonna do the same over there, so we need to make sure that at least four are going to be connected. And maybe we're gonna ignore this one. So once again, all of that is a design decision on your own. But I believe the batter toys is going to take it this way. So we have six on one side, and the next one is going to be over here. I'm gonna explain in a moment. Why? So what I know do is I hold on control D and I duplicate so many fields that I can create a complete rout as I like it to be. So in that way, I need to make sure that I don't have any doubles. So this is important later on, and I want to make sure that I create across like, once again I want a four colored field here in between. And then I want to go to the next one and again, depending on whatever I want to see later on. Why, however, I want the game to look, I gonna make use of that. You can even create your very own little variance. Basically bike designing the playfield. However you like it. If you are unsure if you have duplicated one or more too much on one particular field, you absolutely You should go and check that out once again. I gonna try that out right here. So if I'm happy with the result or not probably you need to start all over one time because you may be messed up was something. But this is a good learning thing over here. Cool. So now we have our outer route and what I now need to do is of course, I need to create more routes like the routes for all our winning quaint or for the stones we want to play into. So we're going to start here. 1234 And this is going to be the end once again, I believe my field is going to be it bit too big at this point. So probably I gonna end up with doing the other way. As I explained before, for example, taking away this field and bringing everything else back over here like this one, I would go probably until eat those two and gonna take the other ones over here and bring the complete playfield wherever I like toe. And if you like, diagnose and total, you can also put that together. So as I probably gonna have to make use off, gonna snap that complete playfield a bit together. So it's closer, and I only have one empty field over there, and I need to do the same for the other ones that I want to shorten them as well. In that case, I have like 12345 per side. So 12345 it's going to be. This one would be too much. So basically, I take these corner pieces away, delete them so you can see the updates automatically. And I gonna bring all the other ones together. Same here. Gonna delete those two corner fields and take thes and bring them over here as well. And the last one is going to be this one. And I can select all of these points and snapped, um, into the center. And I have a field which I'm probably more happy about then I have had before. 7. #7 The Final Routes: welcome back to the course in this part. We're gonna create the other four routes we're gonna make use off in that case is going to be like the red round, the blue, the green end. First off, you want to make sure that you put the route completely together and check out if everything is absolutely correctly set it up. So basically, you select the first known and all you take your arrow keys. I hope that works, and you're gonna go through that list if you see there's any double over here. Meanwhile, you're going through that, make sure you're gonna raise this pieces. Would you have doubled? So you're going to go and check all of these out and see if we are going to be at the very end? Do you don't need to take care of the note name at this case because you cannot do anything against it except renaming all of them. So just keep that in mind so and again, this naming convention doesn't really matter at all, except for a later on, probably seeing what's the correct tile. So again, we're gonna create an empty game of Jenga on a probably name it Rent route for being a red route. Of course. We need to know what is the corner off the red route. I'm gonna zeros this one out of the here. So basically where this is going to be located, this empty game object does not matter at all. You can put it directly on the start where you want to have the red road being on. So what do we do? Of course. We add the routes trip to the red route. And of course, we're gonna take a node and put this over here as a child, object to the red route, and we're gonna make sure that we drank this directly over there. Duplicate this. So that's going to be the 1st 2nd insert and force. What you can also take now is some colorization possibilities. In that case, we're gonna create what? Take the materials holder asked. We created beforehand, or basically, unity does it for it. And we create a new rant material we can attempt this on. Basically, bring this, um, onto our note. There's one thing you're gonna notice in just a second. The border is not anymore represented onto our tile In that case, we're gonna need to make sure that in Albita Channel we're gonna add our border color once again if you want to have it more bright and not so shiny. Actually, you can always go and play around with the speculum highlights field. So you probably don't want to have any speculator ity on that. Same for reflections. You may or may not want to put in reflections onto your fields. Just so you know, I'm gonna take the other stories as well take the red material and drag it onto it. And boom, I'm done with the red one. I can basically duplicate this one, but I better don't do that because I have to struggle was Korpi pays and bring all the other sinks around. But what we can do first now is we're going to duplicate the red material. Just hit control de then f 24 rename and we're gonna name it may be green. I'm not quite sure which one is going to be the next, but doesn't really matter. So what I do is ago, it was the color picker over here to be the Greenfield once again duplicate green rename it f two, maybe blue. Once again go was to color Picco to whatever blue collar I like Maybe a bigger door down or whatever one doesn't really matter and duplicate this once again and renamed us to be yellow orange, Whatever the colors are you prefer and I gonna bring this to make Maybe here, Lawrence Yellowish color tint. Once again, this is the design decision you're gonna make on your own are gonna create now the yellow route or Green route basically doesn't really matter. I don't know which color is going to be the one. We just need to know this later on. So we're gonna create the green route in this case, I want to make sure that I at 1st 0 this one out into into the why and the said, Well, you're probably not the same for that. But I want to make sure that I snapped them into our that one to be like in the center point over here. So I go to add it, snap settings, and I want to make sure that I snapped all the axes off this particular object and then a direct this one into where the place where my next fields going to land in Go to my three D model soldier, you can close or keep snaps headings open. Doesn't really matter at Dragon Note inside. Make it so that it is part off green route and I gonna zero this one out of here so it snaps automatically where it has to be. I duplicate this tile or by hitting control de actually, you'd really completely activate that. And of course, Green Route needs our route script. So we go to the scripts, will the and put the route on it automatically will be around. Now we can take all these notes once again, make sure we go to materials and bring on green to this. Now we gonna duplicate that or actually create the yellow and the blue one as well. Pretty simple. Gonna shrink that together. Rightly create anti There's going to be our I don't know, yellow route over here. We're gonna make sure that the Y axis is going to be at the 01 We're gonna drag it a bit of their snap all axes to zero Fife and everything. Gonna make sure that I bring another new route or node in this case to your yellow route, Make sure zero this one completely out as well. Make sure Yellow Road once again gets our script route and gonna duplicate the note over here. And bring this where it has to be. Of course, as we have done before, select them all and make them yellow like this. And finally, we're gonna do the same for the blue route. So we create another empty one. Name it. Blue route over here brings us where it has to be. Make sure we snap all access. So it's where it has to be correctly. Gonna go to node, Bring this one onto the blue route. Make sure we're gonna zero this one out over here as well. So we don't have any strange things. Blue round brought us somehow at the minus two, which is probably not correct. So we're gonna take Blue wrote or I gonna do this. So if you have any mistakes done, no problem. Just correct them. And of course, I duplicate the last note piece of here on, like, three times. So we know all of these notes are going to be blew off course of a blue route needs our yeah route script again. So everything has its green lines in between. So we're gonna go toe 1234 And of course, we want to make sure that we double it or actually select them all intent, um, to be Polu like this. And since we now know this, we gonna know that the base field off the blue base basically is going to be probably here . We can also put this directly on this corner, so basically, it doesn't really matter where we're gonna put those fields at all. So we can basically do the yellow one here, the blue here, the rent can probably be here. The green can. I don't know. This is what we gonna need to decide on our own. But I gonna do it this way. So this is going to be the red bass notes are gonna put red material on it as well. This is going to be my green one. So I know that this one is going to represent the yellow one and the last one of the hit this it's I know this one actually is going to be here for my blue one. So everyone has his own start field its own Enfield all off them need to go at least one round completely around before they are able to go to the next route over they. And that's four now, everything we need to do for the yeah, actual playfield so far. 8. #8 The Bases: welcome back to the course in this part. I want to implement all the basis like all the base fields, as well as do some clean up in the hierarchy because sometimes because of the good amount of notes over here, it can be messed up quite fast. What you want to do to create Justin on other empty game object. You maybe want to zero this one out, like on going on to reset, and I gotta snap this maybe into the center of the Playfield so I can and basically name it hashtag routes. So when I do something with the hashtag and front for me, it's easier to see later on what's going on. What I can do is I can take old routes and make them basically child off routes. So all routes are going to be in here. Every road has its own base or child object over here, and all of these notes are going to be under that. So I keep the routes or actually also the hierarchy extremely clean, and I can do the same for basis, so I'm gonna create an empty one. Resented position, maybe a 2000 and can also direct this one into the center even if I don't have to. And I can rename this one to hashtag basis once again. Again. Ah, do upper case. Lower case doesn't really matter as long as you know what's going on inside of that so late on all the basis may land into the basis one as well, Right? Click create another empty and I got another name. This 1 may be a red base, so all the red based pieces will lend into this as well. I'm gonna reset this one to be ever anywhere and put this anywhere here as well. I'm gonna create some new nodes and going to bring them as being part off the base. No, off the red bass note so we can make them basically or put them wherever we like to. So they may or may not to look good at the position where they are. Once again, this is the design decision on your own. Looking can keep more space from basically from the complete playfield. You can take the parent object and direct the parent object now around and the nodes will just follow wherever you are. dragging this one. You can snap this one as well as the other ones. Nothing fancy was that at as all or at all. And now basically, we can before we tend to us. We can even go in, duplicate this to simplify the process for one other bases. Because this is not so necessary to keep that. Ah, single, I would say so. I'm gonna bring them all over there, wherever they have to be. I know this might look a bit strange, but actually to get this Ah, well, let's say symbol out of the way. We can probably also put the somewhere else. Or maybe we're gonna put this, like, over there. So all this basis may not form this assemble. So you might want Teoh get rid of that symbol in any way, like doing this. Maybe this way. So since we don't really care where it is, as long as we don't, you know, have any strange symbols we don't want to see in our game. Okay, so this looks quite better, and now we can rename them, So this is going to be our green base. And it is important for you to keep on a renaming things however they are supposed to be. That's going to be on a yellow base. I gonna lie to take away this. Ah, yeah, This numbers in the back as well. And this probably is going to be about blue base. Once again, you can create as much basis issue like Teoh. Same for the other one. For those Sekoff, Ludo and Court Total. I want to make sure that all of these are going to be on their own. So I'm gonna select them all that make them child off basis. And there we go. Now we just need to go in and tend all the notes. So we're gonna take the red bass note. And of course, it's rolled the red material on it like so. And we're gonna have a green base. Of course, we're gonna take our green ones. Then we have a yellow base. We're gonna take all these notes and make them yellow as well. And we're gonna have the blue base. We're going to take all the blue notes and tempt them to be below pretty decent. Now we're basically done with the main set up off the complete playfield 9. #9 The Stone Selector: Welcome back to the course in this part. I want to create one of the stones and set it up so that we can make your use of it later on. First off, I want you, Teoh, go and implement, if not happened already. The selector PNG file. So first off, I created folder and call this one textures. So basically, any textures you we gonna make use of or you probably want to make use off is going to land into the taxes folder. I go and switch this one to be a sprite to do I and of course, or throw down here bid and apply the changes. So I see that the rest is going to be transparent. Now, I want to make sure that since this is going to be our selector, I want to have this on some kind of plain or better 1/4 which I can rotate later on. Meaning whenever the selectors active, it just rotates around itself before we can do that. Of course, you want to make sure that we are creating one of our stones somewhere in the scene. So I'm gonna drink one stone. 2000 over here that does not contain any color and stuff. We're gonna talk about this a bit later on. And as a child object off the stone, I want to make sure that I create a three D object called Quad. As you can see, it has a strange rotation from one side. It is transparent from the other. Disapprove Izabal. What you want to do is you want to rotate it in one of the other direction so you can see that this one is going to be directly well seen with white on top. Now I want to make sure since I can see it sometimes flickers over here. I want to lift this up just a bit. So you go do not have the flickering. I mean, it's just as you can see. Super small number Syria 0.9 is more than enough Or is there? Is there one Teoh? Maybe it makes one more understandable. So we don't have any flickers anymore. And what I want to make sure is a creator material for our selector. So I created new material and I can name this one selector. The selector just gets our PNG We have explore imported like this and we go from rendering mode to from OPEC to cut out which say that you're using doesn't really matter. So as you can see everything transparent, it's getting cut out completely 1%. Now we're gonna rename this quantity to be a selector. So later on, I know what's this part is going to be? And then I dragged the selected material onto the quarter. As you can see, the selector now matters like almost 1% to the size off this stone. What I know want to do is I can't basically took the materials a selector as I like and please based on whatever the stone is going to be about. And also, I can animate this and to any make The selector is basically raza simple. We go toe window animation animation on There's going to be this window over there You're going to create a new animation. So in our assets folder we created new animations Wilder because probably there might be more laid on. We're gonna open this and store our yeah animation of here as a selector Animation, you can name this once again as you please. And like, as long as you know what it is, we're gonna add a new property of type, transform rotation and select the plus. Now we basically go and, ah, define how long we won't have that to happen. You can now go and scale this one. You can rotate it. You can do it backwards for was all of that depends on your own. I gonna select the small record button over there. I go to the last frame off the animation, and I was a bit tricky for me to show you. But what I want to do is I want to rotate this one the selector by 1 80 degrees. Ah, in this case, 3 60 I'm gonna hit E for rotate all down control and snap it so that it dis matching 3 60 degrees in the ant. Also, you can see this on the that value is going to be 3 60 at this time. I deactivate that since I'm done with the rotation. But when I play now, it's going to be not the one I want to keep it on, going over and over and over, not easing in an easing out. How can I do this? I go to curves on the bottom Over here. I hold on my middle but mouse button to drag around this I risk roll out with the mouse wheel so I can't see where the ease in and ease out is coming from when we now select one of these keys. We have the small grey handles over here. We can take this handles and direct them up and down. Same for the other way. We're gonna be so that we want to make sure that it's like looking like a sore over there. So that's where this where we gonna get rid off all this easing in and easing out. Make sure you be as precise as you like. And please, once again, I believe this anyhow, a possibility to straighten this out by zooming in again and looming out again. I believe this is the way where you can ah do all of that stuff as best as you can Once you have that sort ooze shape. Basically, you're good to go now when we impressing play on this animation, drink it away so you can see this in over here. I'm gonna press play in the animation and you can see it basically goes on and on and on, and we'll always rotates at the same speed. That's what I want it. 10. #10 The Nodes: welcome back to the course in this part. I want to create a note script which is basically sitting on every possible game field where a player or a stone can move along or is going to be located. At first. Off, I go to my scripts will create a new see ships gripped called this node. And of course I want to open this one up in Mona Developed or there's your studio, whatever you please and like once again and want it open, I want to make sure that we get rid off. Starting update. Since we don't need that, we just need to things or two informations for our stones and for the field itself. In this case, the 1st 1 I want to have is a public. A bull is taken, so this is going to be ah, bull, which you can later on on runtime change to be is taken or is not taken being when it this false, we can go with a stone on to that. So we need that bull to determine if we can walk to this particular note or not, for example, also, it depends on what the stone idea is going to be. But that stuff what we're gonna take later on, this one is also taking care off. What is the type off stone we gonna have on this node? But since we don't have a stone script at the moment, I'm gonna create this pretty quick as well. Just create a new C sharp script and call this one stone, since our note will have to contain stones. So I'm gonna type in stone over here, and they might just still I need to make sure that the compiler has done running. Of course, otherwise we might get a narrow here and there, but I guess we shouldn't have any problems. Also, you can check the bottom right corner whenever there's something moving, like a SoCal image of something that the compilers still working and running. So you need to wait until this is done. And since note is done ready and we have the bullets tanking and the stone stone, which is going to be the stone next later on, going to be sit on this particular node. We're good to go. Don't forget to safe everything, by the way. And now what we do is we go to our routes. So and you pick basically all nodes over here, make sure we add no to it. If you don't like this approach, you can type and note over here, and every possible note would be highlighted over here inside our seen basically, and we can select them all the undependable or independently, without taking care off any off the parent node or parent objects. And what we do is we drag node onto this. I can take away this note symbol over here and to see everything which we had selected. It's unrelated to the points or actually to the apparent objects. That's everything we needed to do for the notes itself. 11. #11 Stone Variables: Welcome back to the chorus in this part we're going to start to create the first year most important things for the stone itself. So for one stone, which is also laid on going to be for the other stones. So the first thing, of course, we want to make sure that the selector is a probably another color. So we basically can see this one later on. Whenever we do human, I'd inputs. But on the other hand, we usually don't need to select at the moment because we're gonna create everything CPU wise for so meaning we gonna create the non player character at first. So it's easier for us to adopt that light on for human idea input. So the same actor, basically, I want to create or go into the material that I want to make this one just black. This is a personal thing, so you can do whatever you like in police. Of course, I also want to get rid of speculative highlights and reflections since I want to have this one just plain blank. If you don't like the look of that you can even use, I believe so in other Shader for that like it under to Shader or something different, which is basically just giving us the correct stuff over there. So what? The position at the moment off the stone is is basically really not important, I would say, because at the moment we are just trying to get the first informations into the stone. So let's open up the sea ship script off stone if you haven't already. And let's put in some things, we gonna make use of all we need for this particular stone. First off, I get rid of starting up it, at least for the moment later, when we're gonna fill these back in our stone needs to know every route he can go on. This means at first the common road which is going to be the outer one as well as his final route, which is going to be his garage. I would say whatever her fire, the final notes are basically these ones here. So when this is going to be a red stone, it needs to know what is this out of route And what is this like? Let's say final or in a rout over there, we need to combine these later on and put and notice together where he knows how far he can actually go in this particular stone. So what we're gonna do is we create two routes first, so public, this going to be off type of route. Now we just name this one. Let's say the common route, something like that. So that's going to be the outer one. Then we're gonna have the other one, which is going to be the inner one, like the final road or whatever. So it's going to be public route, let's say in a route or final. Basically, I guess final might makes more sense. I don't know. Doesn't really matter how you name it as long as you know what this is going to be. So, once again, this is the out, uh, route over here. So keep that in mind, and what we need to do is based on these routes, we also need to create a list off nodes which is basically containing all the node fields inside the common road and the final, not a route in this particular case. So we create a public list once again, this is doesn't necessarily have to be public, but to see if everything works, it's probably better that we're going to create this. There's going to be off type node. So all information about each of these notes is going to land into every each stone, based on whatever the current route off this particular stone is going to be so And we gonna name this may be full route once again. Doesn't really matter how we name this. So this is the full route for one particular stone. Once again, we need to initialize that as a new list of type node, of course, Open close parentheses and close the line was a semi colon. So all of that is going to be about routes. I'm gonna create a head over here was in square brackets, so I can name them and they don't have a good overview inside the inspector. So I'm gonna name this routes. I'm gonna show you in that it's just a second what this is going to be about. And I can copy this on for the next one, which is going to be everything about Node. I'm gonna do this because we need to fill in some information into at least one stone or actually in every stone we're going. Teoh make use off in our game. So first off, we need to have a public node, and this is going to be the star note here. So basically the bass note in this particular case where we are going to send our first I stone on toe whenever it's leaving, then we have a three other note. So another one is going to be a public also of type node. There's going to be the base note. The bass note is going to be the note where the stone is starting at. So node in home base, I would say we need this No, too late on. Bring this back whenever Stone gets, you know, destroyed from another player or kicked from another player than it is going to lend back onto the base note. That's why we need this. Then we're gonna have a public node, and in this particular case is the current note we're sitting on. And then we have a final note, which is going to be the last note over here, which is going to be the goal node. So the place where we are going to and that's basically ever saying we need to do for this particular notes that there's one more thing which is going to be private. One is going to be our current route position. So the position our yes, Stone is currently at. So this is basically at the moment everything we need for that particular notes. Of course, we can also put in already the selector. I'll probably go and put another one over here, another head of for being for the selector this is going to be the one which is directly sitting also on the stone itself type game, object on we just name it selector. So on start later, when we can just deactivate this and whenever we need it, we can de ia reactivate it and so on And so force. We're also gonna have some bowling's for that particular stone. In that case, I maybe create another head over here and gonna name it bulls or bull leans, which are going to represent something like two or force. Basically what we need to know is is our stone out already or not? Something like a bull is out. What? We also need to create is a Bullen is called is moving, which is going to protect movement based things. Like whenever something is still moving, we cannot move anything else and we need to find a one is goingto be for human input, which is cold has turn. So this one of the here is for human input. We gonna talk about all of that a bit later on because it's going to take some time until we get to this point. Okay, So and that's almost everything we're gonna have at the moment. We also have some steps and index fields we are going to create whenever we are actually needing them. In the next part, we're going to go forward and fill our full route first and make some, hopefully some first steps with our stone. 12. #12 Creating the Full Route: welcome back to the course in this part. We gonna start to feel the complete notice or the full round for one particular stone, depending on where it's starting field is. And of course, we're gonna lose her that completely through all fields and the total, and finally go into the final round over there. So we have one full route also, What we want to do is we're gonna select I was stone over here and make sure that we add of the stone to it. So, like the stone script. So we have now everything on that like the common road Final route, the full road later on, automatically created on start as well as we're gonna have to fill out all the other notes of here. Like the start based current node basically is a start on the base. Not only the current and the goal node are going to be overridden later on, and probably we're gonna deactivate them so we don't confuse ourselves for the moment. We're going to see all of that since we want to have some debug abilities over there. Also, what we want to have is the selector is going to blend of here into the last field so we can later on start, for example, just deactivated. So it doesn't We don't need to take care of that at the moment. Once again, this is just one humanoid inputs. So at the moment, unimportant. So let's open the stone script once again. And let's create the full route in this particular case. And most easiest one is of course, we have a list of a here. We have a list over here basically in this route script, and we just copy and paste this note components and just put them into this full route list over there. And we're gonna do this and start So we actually gonna add now the start function once again, so avoid start often close curly braces. And in here we call a function so and this particular function is a rez, a simple itself. Type Boynton's. It doesn't return anything on a Just do something for us. I gonna name it, create full route. And basically what we do is we take two full loops and loops. Rule the common route lists, basically and at those a two hour index. So, basically to our full route over there with off wizard type note. In this particular case, how do we do this? Of course, we create a follow up we type and four double tap to create the for loop tap another time so we can directly type into the max one over here. And what we want to get it first is we want to go to our common over common route Don't. And in here we're gonna have the child node listeners can see, and we're gonna take its count. So the amount of tired notes inside the common road that's where we are looping throat that then we want to do is we want to create some temporary index inter jar Gonna name it. Maybe Tom Temp pos for a temp position is going to be whatever I was stopped Nude index s. So how do we know that? Well, it's rather simple. It's based on whatever the current start note is and seen from what is going to be the index on the common road over there. And we can create some help of functions for that to read this directly from the route. Whatever the position is going to be so at first we create a new interject. Maybe over here in between. It doesn't need to be put public. We just need to a store it somewhere a week, maybe a name. It starred Node Index and close the line was a semi colon. And on start, we can basically go into the common route and basically take from the start node and request whatever the index off their particular oneness and store that inside the start knowledge and necks. So how do we do this? We're gonna say starting old Index is equal to and now we need to request this particular note index from the common rode off from of whatever the route is in this case, it is the common route. So we go on into our route a script and go down a bit and create a new public function off type into just so we request an interview, Uh, we can say we named this one request position or something like that. Open, close parentheses, and we need to put in a transformed type off our node transform. Basically, this is what we are going to request and what we need to do is we need to return. Whatever the currently request, That note in next ISS in this case, we return child note list Don't. And now we want to get the index off this particular transform item were requesting index off note transform the one we are actually requesting over here. Don't forget to save the script and do this. It's always and then we'll return it to the stolen script. No one we can do is we can basically request with that particular script we just created or this function we can directly Passover the transform and save that into this note index. How do we do this? Of course, Start note Index is going to be equal to, and now we talk once again to the common route Don't. And in here we should be able to request the position off a type of transform. And in this particular case, we're taking this start Node, Don't game object. Don't transform. We cannot take the start no directly because it is of type Note instead off, you know, off type transform. And we need the note instead. That's why we're needing Go to the game, object off this particular note and find its transform information. So this one is going to be now requested directly from the common road. So the outer one which ever has this particular one. Now, since we know whatever the startled in next is it depends on where we are starting where the blue one is going to start on a different one than a red one. Of course, Now we can take the startled in necks and save that or use that as an indicator for where we are starting to loops. Rule this information in this particular case, we're gonna start with a temp position is going to be where the start note in next is and we implement I in here as well. So if I is zero, then of course it started out in this is going to be the first field. Otherwise, we're gonna add up to it as how long off whatever how long this number off the particular route is going to be. But since we want to avoid an overflow, we're gonna have to say we want to modelo equal the temp position model Lewis This person teach sign, and it means whenever 10 position overflows the lengths off the child node list. It starts once again at zero and adds up still onto that. So and how do we do this? Of course. We're gonna take the outer or the common road in this case, the child node list dot counter. So we always kept that to that 10 position in between zero. And whatever the maximum amount is over here since this 10 position was a start, note in days can always be in another position, so we never haven't overflow. So whenever this hits the maximum, it will restart at zero and goes up once again, no matter how high or how big this one is. And finally, we want to add everything to our full route, whatever we are currently looping through. So full route dot ad. If we want to add something in this particular case, we want to take the common road. Don't child. No list, of course. In square brackets, we're gonna put not I but temp position, which is currently the correct position. Then we want to get the component off Taib note, and this is what we are going to add. Open Close. Prentice's behind this note trying of brackets. This is important. Otherwise you're gonna have an ero. And since we have done that for the common road, we also no need to do this for the final route. So we're gonna take the complete one of the year. Copy this complete for loop. Bring it blanket to lines below and instead, off final route over here, or instead of common road, we're gonna put a finer route over here. Also, we copy this and everywhere where common route now is we're gonna take the final route like this. But we don't need to have this overflow over here or overflow protection because the we I cannot overflow this anyways because it starts always at the same time. And instead of temp position, we gonna put in now, I s an index indicator, which we're starting at zero and go to the final part, no matter what 13. #13 Finish the Full Route: welcome back to the course in this part. We gonna go forward with creating all the function or the first functionality for our stone . But before we can do that, we want to make sure that our full route is going to be completed. In this particular case. In start after we have created the star Note Index or we know the start node index we call create full route. This is important because you want to fill the complete route. Of course, on game start for that, once again, we need to fill in all the necessary notes. In this particular case, we need a least the start note and the route the four route as well as the or, in this case, the common wrote. And to find a route. How do we do this? We select our stone and of course, go into our routes list over there. I'm gonna correct them the bit. And now the common route goes into current common road. This lot off here, the final route, it is dependent on the stone. Since we're currently I can rename this one to be a rat stone. This Redstone now needs the rent route over there, This one. So I gonna put this into the final route. So every stone once again, based on the color, it is going to be different. Same for the start Note. The start note is going to be the red first note over here. So we're gonna have to put this, like, over there into the start. Northfield, we can amazingly make use of this lock symbol. So we lock up with the inspector and we can now select the node, which is going to be currently note number zero. Over here are number one in the list on we put this into the bay into the start. Note. This is everything. For the moment, the bass note once again is going to be one off these starter notes. So wherever the stone is going to be, start at and they don't can lend onto this back whenever we need to. So and now we should be able to fulfill the complete final route. Let's see if that works by pressing start. As you can see, we don't get only now references. If you get in our reference, make sure everything is working completely. Anyhow, the full route does not contain anything, which is funny. So we need to take care of that. As you can see for route is basically empty, and I need to take care of that. And we're going to see if we have star oh, actually stored or Safed almost group, which we doesn't. So I gonna save my script, keep on selecting the Redstone and see what's the final round of the four route is going to look like. As you can see, the first note is going to be this note over here, which can also be highlighted in the hierarchy whenever you select it in the last notes. The last four notes are going to be over here in the red. No terra meter like this. This this and this. So now our list contains all necessary nodes for this one particular stone. Pretty cool. And now we can go forward and move this particular stone based on that say some random numbers to move along that part 14. #14 Stone Movement 1: Welcome back to the course in this part. I want to start Teoh, Move one off these stones, with or on to the final route or the full route, which we have calculated beforehand. What I want to do, They want to take the red material before I do anything else and duplicate this and rename this one. Toby, let's say Rat Stone, why do we do this? Because this one has no texture applied and just a color. I can take this Redstone texture, by the way, are gonna unlock this lock symbol and a take away this board a texture for that. So I can now take this Redstone color and bring this directly onto my red stone. And it will match the same color as the bottom like this border one over there. So I always know, get this is going to be a red stone. Let's dive into coding. I want to make sure that we're starting the move ability for a stone onto this particular part of a day. So open up your stone script and let's go forward with that. So to move our stone where I want to make use off a core Oh, Tina co routine is also called an I e nam aerator. So this is going to be taking care of the movement directly instead of using update when we can basically also do timed action. But we are calling a function like 60 times a second, and I numerator, or core protein, is not related to the update loop. And since we just do a movement over there and and just go on forward, we can simplify that, use it and make reuse off that particular one without filling up update, which is absolutely not necessary. I'm gonna name it. Move, since this is going to be our basic move, basically open close parentheses, like a function. So nothing else for that. First off, we want to protect the island I in operate or call routing to be run twice or even more so we're gonna do a some small if statement over there, which is requesting if is moving. So if we are moving already, then we want to break out of the enumerators. So we say yield, break So the einem aerator will be instantly stopped. If we are not moving, then in the next line, we want to say that we are moving, so is moving is equal to true. This is important to protect once again the I in numerator to run twice. We only want to run this one once Now, since we do repetitive action, we want put a wire loop inside of this. So in the wild loop we want to see is our If our steps we want to go is bigger than zero. But as you can see, we currently don't have steps. So what we're gonna put in is probably somewhere in the top, like in between another indigent, and we call it steps. So this is going to be, by the way, do commands wherever you like, and please to remember what's going on. This is the dice amount, which we have rolled, or, let's say, rolled dice amount, and this is going to become reduced every time we do one step. Just keep that in mind. You can also rename this to whatever dice number whatever this is the like, the steps we want to do next. Meanwhile, we are here in this one and the steps is biggest and zero we want to do some things the 1st 1 is we want to update our current drought position to be the next round position. In this case, we say route position plus plus or plus equal one doesn't really matter which one you're using next one is we want to declare one is going to be the next position in our route or the next position where we want to go to. So we create a small vectors. Ray, over here we call this one next pos for position is going to be equal to And now we talk to our full route. We take the route position we implement or in cream meant it just a second ago We take this s and index or indicator. Then we take the game objects dot Transform Don't position, remember for route Onley contains notes. That's why we need to go an extra step over here like backwards. Since we are done with that, we now want to create another wild loop which is doing the actual movement. So and how do we create that at first? Of course, once again, we say while something is true or not, And in this particular case, we are going to request the position off the stone. If it is already hitting the next position, where should go to it like the next rector over here. So we're gonna need to create another function for the movement. Who let Probably we're gonna do this directly under this. This co routine needs to are just no. Are we at a point or not? In this case, we can create a function off type Bullen, which is just returning to or false. We gonna name this move to next node. And in Open Girls Prentice's, we're gonna put two arguments at first a vector three, which is going to represent our goal position or the next position we want to go to which we actually declare over there. So gold, us or whatever, and the 2nd 1 is going to be offs type float. It's going to be just a speed number. We're gonna put in over here so we can later on play around with these numbers just by calling them from the while loop. Or even I create an open one for that particular case, like a public one, which we can define different things on different steps to what we want to do it. Of course, Since we are in a bull, we need to return a bull, right? And in this particular case, we want to return the goal position and the gold position, not directly about the current position. So we need to say return, go position not equal. And now we create a function for that. And of course, we enter line was a semi colon. The function is basically nothing else than moving from one point to another. Let me explain that usually when you are no update loop, you want to say transform, the position is equal to. And then, for example, we move to want particular vector. In this particular case, we're gonna make use of vectors, read or to move towards and we're gonna have is a current vector the target vector. And of course, that the speed very able in this particular case, our current one would be the our current vectors transformed onto position. Then the gold or the target vector is going to be the gold position. And of course, we're gonna have a speed like Kama Speed times a time. Dotel to time and we're close. The line was a semi colon. This is basically returning something. Of course, it returns to position between those two points and will always do that. So and what we can now do is if the current gold position represents the same functionality as we have done here, like was usual movement. We can put this complete part into print sees onto this playoff fantasies. So we have a 2nd 1 over here, which is basically enclosing the complete functionality. And we're gonna have the semi colon in the end, and we can destroy or delete this one. So maybe that makes it easier for you to understand. So we gonna move our current position from our current position to the gold position with this particular speed And when this transform position is basically this position, then we return a true and that means we can leave this particular via loop alone. So now we need to call this off course. We say meanwhile, moved to next point to the next position. If meanwhile, we are waiting for them to be equal, basically, like the gold position is equal to in this particular case, transformed our position. Of course, we need gate This one over here. Then we want to make sure that we are waiting until this is going to be completely done. Also, this takes a second argument over here, which is the speed argument. So we're gonna put an eight f for example, for Raza's rez, a fast one open close print. The curly braces behind that. And in here, we say healed. Return? No. So we wait and return and massing until this and this do match. Then I want to make sure that I have a little space in time so I can say healed. Return new. Wait for seconds and an open close parentheses. They're gonna put something small, like 0.1 efforts. This is just going to be a place holder or the level gap between one movement and the next . So we have something like, it's more break in the movement. What we also want to do is we want to reduce the steps, so we want to negate them by one. So we say minus minus, and we're gonna implement something called done steps and there's going to be plus plus, so done steps is basically how many steps have we done already? And since we're gonna increase those and probably need this number later on, we gonna just implement this at the moment. So in here, everything about steps. We're gonna put another int called done steps and we'll start at zero and increment on its own over there. That should be everything for the basic movement. There's coming way more into the smooth functionality because we need to report to the game manager, which we don't have at the moment. And we also need to set up all the gold nodes or the current notes on whatever is there stone on it or not? But at the moment for moving this one around, it doesn't really matter. We're gonna keep on going step by step. 15. #15 Stone Movement 2: welcome back to the course in this part. I want to show you how a stone is actually moving and how we can do this or how we will do this later on, but a different way. First up, we gonna open up our stone see ship script and we're gonna create pretty quickly update loop. Once again, the update loop is only necessary for inputs. But since we'd never use that or at the moment, we don't make use of this just for debugging purposes or moving purposes over there. So you can see what's going to happen later on. We create this at the moment once again, later when we get rid of it and we never touch it anymore. So in update, we only make use off inputs like a key press or something like this. If we have a button later on, we don't need update for this. Since I don't have the button yet, I want to make sure that I'm making use of a key on my keyboard. So I can say, if input don't get key down, I want to press some button in this case, maybe key code dot space, like the space key or space bar on the keyboard. And I'm not moving, so it is not moving once again, keep in mind is moving as protecting oi number rated. But also, we can make sure that when we meanwhile were looping through, we can touch the space bar. But still nothing will happen. So and this one is the end operator. So only if this and that is going to be the same case. Only then ever sing inside the if statement is going to be performed. I gonna create some steps over here so steps is equal to a random dot range. So we take a number randomly between a range of numbers. In this case, between one witch is the smallest number on earth eyes and a seven, which is going to be the biggest number on the dice. Now you wonder why the hackers there seven Well, seven will be never ruled by random good range. The smallest number will always be six. If you have a 99 sided dies, that this will always only be possible to hit 98. Keep that in mind for random, the range of functions. So since I rolled now any number and put it into that. I want to make sure that we are able to move on to our rule route in this particular case, what we can do. But it is actually we can to make a quick checkup over here. So if the done steps plus whatever the called steps are other, the diced A steps are going to be if these are smaller than the maximum steps and what is the maximum steps? A. Maximum steps is basically the four route dot count. In this particular case, we can just take it so that we are taking the four routes dot count into consideration. So when we are able to move and we're not over doing it because we are still able to move on this one, we gonna start our core protein named move open, close parentheses and close the line was a semi colon is that is not the case. We can also give a debunked line inside the else statement so we can say something like a d buck. Don't log. The number is too high because we are unable toe, you know, do it's number is too high. So now we can basically start to roll a dice with our space bar and move this stone based on the number onto the playfield And to make it even better, I probably also do something like a debug Kleinova here, so debugged or log. So we see a dice number is equal to and then I gonna say plus and put in steps. Okay, lets test out. If our dice is now rolling and our little red player is going to move along, I press play. We're starting at basically at zero at our route position where it is going to re represented by the route itself. Then I press space. I need to make sure that I activate the game view and press space and you can see I have dies the number off too. And he was also moving to fields over here. I can do this again. Well, I should, but at the moment I'm not ableto because in our move einem aerator we forgot to deactivate . It's moving whenever we're done. So we copy this line is moving to be true and move under or outside the out off Ashley wild loop over there And make sure we gonna deactivate is moving or set this one back to be equal to false. Don't forget to save and let's test it again. Going to start from scratch. I roll the six and I lend over there I can roll again. I rolled a five and so on and so forth I had a four to another four, Another three and so on and so forth. And now we want also to check if our yes stone is going to be able to go to the next round here as well. Because, yeah, there we go. Now it's say's the numbers die because we had a five we can retry. Okay, we had a one, and now we had a two, and we was were able to go up until the last point. And now we can keep on hitting the space bar. But none off these numbers will match, and we will never make it over it. Okay, so now you understand how we will move the stones 16. #16 GameManager Playerlist: welcome back to the course in this part. We're going to start to create the game in a gentle the entities we're going to talk about in just a second for stuff, go to your scripts full. Then, of course, creating new see shop script called Game Manager in your versions. Whenever you're naming its correct, you're going to see that the game and just gain going to get some kind of G assemble. This is going to be something, as an indicator for you that this is going to be the game in India, where all the most of the stuff is going to be. You have working in two double click this to open up and model developed for visual studio , whatever you prefer and of course you like to work with and that the compiler run pretty quick so the solution can be loaded correctly. First off, a go get rid of starting update and let's go and start to create the first entities. So what do I mean by an entity? An entity is going to be something like player, which is going to be holding different informations. For example, we can create a new public class inside the game in the class called Entity. Once again, you can name it whatever you like. I name it entity. You get name a player, whatever it iss for you. So and inside this class, I gonna give that entity or this play or whatever it is some specific things. Like, First off, I want to make sure that I give it a name, for example, pull a public string, and now I can name it to play a name. Also, I can give this entity all its stones. So sink off this particular entity s a CPU or human. I'd input base eso everything. Who has the turn, for example? And so it's a force is going to be stored in this particular entity, and we're gonna update this or make use of this particular entity depending on what we're currently at. So this entity also of course, needs to know all his stones. So, for example, this entity, when it is the Red player in this case, it needs to know all its stones. The easiest way we're going to create a ray off stones and we're gonna maybe name it my stones like this also I'm not sure if we're going to use that pride, but for the moment we're gonna take it. It's going to be public bull we're gonna name it has turn. The next one is what we need is an Inam myself. We don't need the EU number. It is easier to set up. I'm gonna explain the him in just a second. So this Inam is called player types and open close curly braces is going to define different player types. In this case, it's can be a human or a CPU. You can also you ah, name this one and pc, whatever your police Nike again, um, name mine CPU. And to make sure that this is going toe work are gonna need to have a public excessive for this player type of for this in, um, in this case, So we say public play a types and give it a single name like player type was a small letter in this case. So I know this is going to be the excess of very able. So this Inam is basically nothing else than a list off into jazz with strings as an indicator. So instead of having a number like 0123 We can give that particular indicators or index numbers the name. And so in the inspector, we're gonna see a drop down menu well can pick from Or actually we can define if the player type is going to be a human. Do this. If it is a CPU, do that. If it is no player because it's not playing with us, for example. Then of course, we can put this in here as well. Like no player at all. Maybe wasn underscore over here. So I like to Ah, right more mine, old ball talking or actually upper case letters and eso. No player basically means this particular player does not play wizards and it gets like overrun. But later on, for example, like, it is no playing wizards. And the last one is, Of course, we're gonna set another public bull later on whenever we have one. So is this player has won already? It doesn't do any turning, gets overhaul or hopped over once again inside to the complete play loop. To make use of this entity are gonna create the list off entities which is containing all this information we can also make a ray. Basically, doesn't matter. I liked lists, so we're gonna make use of one. So this list is off type entity and we give it a name, for example. Playlist doesn't really matter how you name it once again, up to you and this is equal to once again we gonna initialize that already as a new list of type entity, open close parentheses and close the line was a semi colon. There's one more thing. What is not fitting over here into this entities before we can actually make use of this entity list since this Ah, actually, our own class. We need to make sure that unity knows what it is doing. Was that so? In this case, we need to say or tell unity. So say this is going to be a serialize herbal class. So is system that serialize it'll otherwise we are unable to access or even read the data from this entity class from, or was in the list itself. And we are unable to do that. Anything was that. Don't forget to say the script and let's head back to unity and let the compiler run once again. The indicators in the bottom right corner. Whenever the compiler has done running, we're going to create a new empty game object, and we can name it, maybe hashtag whatever it is called game manager. So the game manager once again keeps track, has already explained in the introduction video on the concept that is, the game manager takes track off, who's has the next turn and so on and who other active players and all the other stuff. Someone's drank the game manager onto it. And let's take a look to the player list. As you can see at the moment, we can see a playlist of their own since a size zero. In this case, whenever I hear the one over there, I can open Element zero, which is the first element in the list. And I can't give it, for example, the name rat Player on dust. Rhett. So all Red Stones are going to land into this element list off the size of my stones. So if I force pieces of stones, of course I'm gonna put all the four insight. If I have a smaller playfield are gonna put two inside if I have to. Our Whatever the amount is, you can increase and decrease the size on your own. And of course, we can say, Are we a plan type human CPU or is it no player? So we don't need to take care of that. We're gonna start with CPU, since this is going to be the next bigger step. Basically, we're talking about 17. #17 GameManager Statemaschine: welcome back to the course in this part. We want to continue our game manager. Meaning we need to create a state machine, which is taking care of all the states all the entities can be in and of course, going to become switched whenever something has happened. Or whenever we need to switch this entity or this turn in this particular case, they're gonna do commend over here something like everything about our state machine is probably going to be over here. Estate machine is basically nothing else than a statement off a different Inam types. In this particular case, we're gonna make use of anin, um, where we can actually take from pick from a do something like that whenever it is like inside the update loop. In this particular case, then we can react to whatever is inside that particular state. So how do we declare one? Actually, it's going to be nothing else than the player types in, um, over here. But we're gonna do our own just for the game manager. So we know what is the current state where this particular entities currently being in Okay , So how do we do this? Of course, It needs to be a public off type once again in, um and we're gonna name it. Maybe states. Now what other states our player can be in. It always reacts toe one single player, basically all the player is doing the same, especially when it comes to CPU. So we're gonna have a state called waiting. So whenever we're waiting with just idle, we don't do anything but wait for any change. Next one is, of course, we have a state where we are going to rule the dice and we're gonna have a another one, which is called switch player. So what does that all that stuff mean is, of course. And here we just have an idol state where we don't do anything and wait for any kind of input from somewhere else, which is doing the state change. So, for example, when we start to do anything, we're going to roll the dice, Then we're going to do everything which has to happen on rolling dies. And meanwhile we inside basically, we go and just roll the dice quick and then go back to the waiting state. Whenever everything is done, we're gonna switch the player or roll the dice again. This is the CPI. When I already explained this one, Raisa, in the very first video about the concept, I hope that is going to become clearer whenever we're filling all the state machine inputs and everything we need for that. The next one is of course, since we want to have access to actually see what's going on over there, we want to make sure that this is a public state. Oh, are states and we guys are gonna give it a name. State. So this is once again Oh, a public excessive for the state machine in the update, Lou. But we're gonna create a switch statement which is able to switch between all those three states. So let's create that pretty quick. We create the white update, um, close parentheses and, of course, open close curly braces. So this is the update. Look, we're just running 60 times a second, and we can create a switch statement. We just keep on rolling and rolling inside the update, and probably most of the time, just don't do anything but idle because most of the time that they do will hang inside the waiting state. So what we create It's a switch statement to switch the state's in this case, we just create a switch and we're gonna declare whatever we want to switch. In this case, we want to switch the state up close curly braces, and now we can give the switch statement any different cases. So we say case. So in whatever case off, for example, in case off rule dice, then we said colon, and then we leave a space, and after we had done was that we need to break the case. So this is how we create a switch statement, which always all possible states based on this in, um, basically, what you can do is you can copy and paste that stuff over here like two times more and just a change. The state's name. In this case, it's going to be the waiting state. And probably in this one it's going to be the switch player state cool. And now you know what a state machine basically does. So whenever we are in the state off, roll the dice, we're gonna do something. If we are in waiting, we they're gonna do something. If we aren't switch player. We're gonna do something. And all of that is handled once again in the update loop. And Ole, most of the time just goes through the switch statement. If you want to make it a bit, let's say more. I don't know, visible for you. You can also always use curly braces as a pair over here just to make sure you're gonna fill all the content at correct spot. You don't have to do it, but you can. Also, you can put in a default state at any time. But we don't need any default state because our default states probably the waiting or the rules die state in this case. 18. #18 GameManager Instance: Welcome back to the course in this part. I want to make sure that we have access from the game and or to the game energy from anywhere in the game. What we need to do is we need to go to our game energy script and in the very top or wherever you like, But I usually do it in the very top. I gonna declare a public static gay manager class and give it a name. Instance. So what we do is we do on we create aesthetic instance off this particular game manager and we declare this particular this one screw whoever that is sitting Toby, this particular instance and how would we do that? Before the void update, I gonna put in void, awake, open growth parentheses, curly braces. Of course, he s well, And what we now need to say is instance is equal to this. So this is going to be the easiest and quickest way to make or give ourselves access from any point from any stone from any route note whatever we need to the game manager incense and talkto everything inside of that. This is later on important because we want to talk to the state, for example, to update it accordingly, inform whatever the stones are going to do at what particular case or were particular spot . Also, don't forget to save as always, and what we can also do is. Then we get to create a small integer pretty quick, which is declaring, What is the active player at the moment in this Guys, we just create a public in today. You don't need to do this public, but for for testing purposes, probably it's better. So we're gonna create the public in active player. So since we have an entity list or play a list of here, we can take this active player number and talk to the index off this particular active player inside this entity or player list. So we always know who's the next active player later on. We also need Teoh have something else like, for example, a bowling which is called switching player. So we want to make sure that we have spent whenever we're switching the player, we don't do anything else but that and probably we gonna very late on, we gonna have some human inputs in this case what we need to have are gonna do some commence over here so we don't forget them. Is a a button or a game object for our button, which the player can They don't press to actually roll the dice or just any kind of input as well as a interred, um, which is going to be the ruled human die. So whatever the numbers, the human has ruled because this is the number we need Teoh later on. Take with us and bring this to somewhere else. But this is stuff. We're gonna take a look at a bit later on whenever the CPU was working already. 19. #19 GameManager CPU rolls Dice: welcome back to the course in this part. We want to do a CPU rule to dice, and after that we want to switch the state, as we have created last in the last video about the state machine. Let's dive into it and open the game in the gym. And what we need to do is we need to create some help of functions. Of course, for us. At first I want to make sure that we create a rule, die sanction and according to whatever the input is going to be like, whatever the roll number is, we're gonna see what is going to be the actual thing. The CPU shoot Dio Before we can do that, we also need to declare if that is a CPU, which is doing this simple because later on, we need to make sure that the humans do have their own input. So before the switch statement, the 1st 1 we're gonna do a small if statement we need to tank. What is the active player based on the one player list? If player list in square brackets, active player don't and now we are going to enter the entity directly and Now we can see what is going to be the player type. And if the player type is equal equal to entity player types dot CPU only then we gonna dual the input within the state machine. So I'm gonna take the complete switch statement, cut it out with Control X, and put it directly inside this Prentice's or Curly braces from that, if statement now we can actually create the rule dice function, which is going to be created outside of the update low because we only perform this once and switch the state. How do we do this? Of course. We already have done this on the stone directly. We're gonna go easy first and later on, we can do any roll dice, mechanics. Whatever you think you are, you can think off. So we call it We want to roll the dice. It's of type void. Since it doesn't return anything, we create a new inter John, let's say ruled, dies or let's say diets number whatever it doesn't really matter is equal to. And once again you know what's coming off course random that range between one comma seven ir explained already why we're using the seven instead of the six. Now, depending on what is going to happen on what the rule said, IHS, we need to check against that first. Meaning if we have rolled a six, we're gonna need to do different stuff then when we don't have ah six in that case. So if our diets number is equal, equal six, then we need are gonna commend this out for us over here. We need to check the start note. So whenever we are mere actually rolling a dice, we want to make sure that we're checking If the start note is going to be empty basically and if it is the same stone on that, we're gonna need to basically make it free. So the CPU knows what's going on and was what it has to dio in this case. It needs to make sure that it is, Yeah, taking another stone in this case, it instead, off taking one outside off the base. Okay, And then we have the second rule. Of course, if it is not six or basically smaller. So if dice number is smaller than six, then we need to check different things. I gotta tell it or call it. We need to check if we can kick somebody, so kick out off the off the play and bring it back. So thank for kick is coming over here and off course. All of that is based on the rule dice number, but we're going to create this functions over the time. So what we're gonna do once again, rule dies who rule random number between one and seven. We check if it is the six or is it is a smaller than the sex. And according to that, we're going to call two different functions which are going to do different things. We're gonna call rule dies basically from the rule Dice State. But since I want Teoh a sense is the CPUs that are raza quick and doing all that stuff. I'm gonna put in some small delay in this. Gays are gonna make use of another co routine over here. I e numerator. Let's say roll dies a delay. I want to serve and delay before I do anything else. Or before I roll the dice. In this case and in rule dies, DeLay are gonna put a small weight like yield return New wait for seconds. You already know that. And they're gonna put in maybe some a seconds like 123 something like that. So we know. Okay, the next Ah, yeah. CPU needs to wait at least two seconds before it is going to roll the dice. In that case, it caused rule dice after the two seconds are done. What we now need to do is of course, we need to start this particular core protein inside the rule die. So whenever the state switches to rule dice, we're going to start this co routine. Eso That's what we're gonna do. So we call start co routine often close Prentice's role dies and open close. Prentice's behind that since this is a function and after that, since we want to avoid starting the core routine twice, we want to make sure that we switch the state. So we set state it's equal to. And now we have ah, drop down here. Oh, actually, we can switch or take one of thes in this case, we want to go to the waiting state. This means that whenever we are starting was ruled in the dies at the very beginning, we gonna start iCal routine, switched to the waiting state and see what's going on. Let's test this one out. We can also debunk that. By the way, for Nieto, there seemed to be a typo. Oh, of course. Ah, this is needs to be not the role dies but the role dies. Delay are gonna copy the name over here sends a roll. Dice is off course of type void or not on off type co routine. So start co routine roll dies. DeLay once again will stop the delay over here, then will wrote the ties. Give any number back. Once again we can put a number and hear end, of course. Or actually, we can also debunk that particular number and see what the CPU does. I want to show that to you once again, based on the state we can choose over here. So let's assume our game starts and we are starting in the role Day state. And this first player entity is off type CPU only then it is going toe work. So when I press play now, it should roll the dice after two seconds. And then, as you can see, it goes to the waiting state. Once again, we can put a debug line in here to see if that is going toe work. In that case, we can say d buck dot log on close parentheses and say, dies rolled number. And then we can put a plus behind that And can de Bach or once again, put in the dice Number s and interject over here at the very every back. Or you can whatever you please and however you please and like to do this, I'm gonna get rid of maximizing places so I can see the consul rez a simple. And whenever I plus play, we're gonna wait two seconds and then we're gonna see dies. Rule number four in the state machine hoped Bank to the waiting state. When we going to do this once again, we're gonna pick roll dice. It is going to do. The rule dies and switchback automatically instantly toe the waiting state. And this time we would have ruled six. So as you can see, this can be automated basically for the CPU. And now we can do all the fancy calculations based on these numbers 20. #20 Red Stones Setup: Welcome back to the course in this part. We want to check if the bass note is going to be empty. That means how many stones we gonna have. Probably one off our stones is sitting directly on the base node. So how going away or what we actually need to do is we need to talk to the note and see of one of our stones is going to be on it as well as if there's anything else, even if that doesn't really matter, since we're gonna kick anything which is not off the same idea of a year. So in that case, the first thing is our red Stone need to be duplicated, and we need to make sure that the game manager knows that Red Stones are going to be. Yeah, actually visible what I want to do. They want to snap this one to the first base. Notably this first Redstone and I want to duplicate the several times So all of these going to have a red stone. Also, what I want to do is I want to give all of them the bass note already or that year. The bows bass note. Since they know that this is going to be the start. Note is going to be from them already. They just need to have all off the own bass notes. Meaning we can once again take the lock symbol over here, locked the selection and select the note where the US guys are sitting on. And now I take the second note of a here. Put this into the bass note off this particular stone. I could deactivate the lock symbol once again. Take the next one. Activate the lock symbol. Take the node where this one is sitting on and bring the bass note to this particular stone . Same for this one. I'm gonna deactivate. Activate, select the basement it is sitting on. And, of course, drag it into the bass note. Deactivate this. Take the other one, activate. And, of course, take the other one over here, which is sitting down below. And, of course, direct the bass note inside of the slot off the basement for the stone and deactivate this little lock symbol. Now it's since all of them know where the base is going to be. We are absolutely able now to check through all of them as long as the game energy knows what are the actual stones for this particular color. In that case, I probably move the game and a job it at the top. So all the red stones are now over here. I cannot lock this one as well. Or gonna. Let's say I reduced the number off the stones in here in my selection, since I know this one is going to be rent can make a selection off all of four stones and direct them into my stones, and there will be added automatically and the size will automatically set itself. So was that set up? We can actually start to check out if this bass note is taken from one off our stones, Otherwise, it wouldn't be actually possible. 21. #21 Check Start Node 1: welcome back to the course in this part. We want to make sure that we're checking if this start note over here is going to be free or not. And according to that, we gonna react differently. So this is one of the first rule sense the CPU is going to get as well as we can lay on take the same functionality for humanoid inputs or human inputs. So open up your game, manager. And once again, if we are dicing or rolling a six over here, we want to do the check. So And for that, we're going to create a little helper function for us, which is going to do the calculations for us, of course. So it for us is going to be off type void since it doesn't return anything and we can name it check starred node or whatever you please like once again. And what we need to implement is, of course, the ruled dies amount. So we say int dice number. You can call it basically whatever you like once again. So, basically, we take this dice number and bring this into the start, not function or checks that no function so Now, At first we want to tank. Is anyone on the start notes? So we say I gonna do commend over him. Is any one on the start node So And for us, How do we do this? At first we want to create a bull, which is going to be a stay at force until it's returned to Truell. So I gonna name it, Start node full. And I said this one to be equal to false. Whenever you're creating local variables like this one or temporary ones, you need to set them to something. Otherwise, you may get an era later on. Well, we now do. Is we gonna live through all our current stones and shank? If the current stone or the current note, they are currently sitting on its matching the starting note. So once again, I would do we do this? Of course. We create a four loop. Probably we can also make yourself for each. But four loops are literally faster than for each loops and also more safe in yeah, making use of them. So if we are checking, we're going to check the player list, Of course, in square brackets, whatever the active player is going to be. And what do we want to check is to complete my stones list so we or in this case, it is an array. So we're saying my stones don't lengths, So we're gonna lose through the complete player list based on the active player as an index indicator through all the stones were gonna have in total. So what we want to do is if we are once again checking now this current node with start note, we're going to get a match and then we can set the bulling start notice full to be true. How do we do this? Of course we say if playlist in scrap briquettes Active player, don't my stones and then we gotta take I as an indicator or in next I is going to be the letter were looping through at the moment. Always say dot Current note is equal equal two. And now we're gonna take the same player again. So playlist in scrap briquettes, active player dot My stones in square brackets I a dot And now we want to make sure that we're checking against the start note over here. So if that both saw the current notice matching the start note. We do know that one off our stones is sitting directly on the start note. In that case, we can set start note is equal to true. And whenever that is going to happen, we can literally break out of the fall up. So we say break because we already got our match. Otherwise it's going to continue until find something. Or even not once we know that. So you can once again give some command Over here. We are done here. We found a match. So whenever we had done was that once again, we can now react to if we have found something or not. So we can say if start notice. Four Start note full is true. In this particular case, we gonna say we are gonna make a comment over here because we're going to reuse dysfunction . We want to move a stone based on whatever that is going to return. We're gonna check that out in the one of the next videos. Els if that in this case, the start notice empty are going to make another command tear start mode is empty. That we want to do something different. And what we want to do is actually we want Teoh leave the base if we have at least one stone which is not out at the moment. So we can say I gotta commend this out because we need to create two more help of functions for that as well. So if Ed Liest one is inside the base, we want Teoh, Bring it out. So we say, Leave the base once again. We need to tackle these stones once again by looping through all of them and check if at least one of them is going to be inside the base. And if that is so, we gonna make sure that we of course, bring it out of the base. And then we set the state to be equal to states dot waiting. Since we already perform something as well as we want to return because we don't want to go further in the complete extort note function, meaning whenever we're returning here, we don't go further. In any other case, that means if none off these are going to matching. So if we actually have a full start, not would do something Otherwise we're going to return whenever we have Not something. And if all of that does not return anything, we can also say that we're gonna actually move something else. But all of that once again, is going to be part off the for loop. We're gonna go create in the next video. You can already tested out. But basically nothing will return in this case, we But we would get a true or false. Basically, if somebody is directly on this note, you shouldn't have any problems in here and no Eros. And then the next one, we're gonna fulfill this check on the bass note or start note. 22. #22 Check Start Node 2: Welcome back to the course in this part. We're gonna continue Teoh, actually check on this particular start note whenever our stone can or could leave. First off, we need to go once again, back into a game manager and continue in the else statement which is doing, like, all the calculations for us. First off, we need to loop. As I said before in the last video, we need to lose through all stones once again and check if one off the stones is not out. How do we do this? First off, Once again, we're gonna do a four loop of a here. So for tap twice. And of course, what we want to check is through all the stones. Don't Lang's so basically the same as we already have done over here. But we measure for different things in this case. Once again, we gonna put in playlist in squared records, the active player, as before, don't. And in here once again, we go through all my stones built lengths. So once again, we want to tank. If one of these is out and then we want to make sure that this is going to leave the state this leave the base part is going toe land inside the swallow up over here. So now we gonna do the if statement check. So if and now we want to request to the stone if it is out or not. As long as the bull is public, the bull is out, which we currently have on the stone. As you can see over here, as long as this bullets out is going to be public, we can directly excess it. But we want to assume that this one is not going to be public, brought private. And so if that is private, we need to have help affection for that to give out the correct bull, actually. And of course, what we do is we return a bull. In this case, we create a new public pool and we've name it. Return is out. That is meaning we just request if that particular stone is out or not. And so what we just do in here is we return. Whatever the state off is out ISS. So when that is going to be out, of course, we might want to make sure that with this returning force otherwise it's returning to, depending on whatever is out is going to be once again. It all depends if that is going to be public or private. Let's assume this is one in private that we want to request. This is out. Toby only requested inside this public bowling to protect the bowling itself so it cannot be changed by something else but a function. For example. In this case, we can just read it when we go back to the game. And don't forget to save the stone script. By the way, since we have this new function added over here now we can request that. So we say if playlist inscribed records active player, don't my stones in square brackets and now we go toe the index I, which we're currently looping through or taking wizards. And now we want to say return is out. We request this bowling over here, and of course, it needs to be open close. Prentice's since it is a function so but what we want to do is if one off this is not out. So the 1st 1 we find, which it's not out, we want to send it out. So in that case, we're gonna open close curly braces over here. And now we're gonna take a leaf. The bass part like state waiting. We're gonna put this over here. So in that case, when we have a stone which is not out at the moment, we want to make sure that we are leaving the base. If all of that does not match, like after this for loop, we want to move a stone. I gonna take this command and bring this after the follow up so we don't miss it out later on. So how do we leave the base? This is going to be part off the next video. 23. #23 Leaving the Base: Welcome back to the course in this part. We want to do the actual step and move the first stone out onto the base. Note. There are two things we need to create. At first we gonna go to our stone and we need to create a new move function or, in this case, core protein. Also, we need to create an access er for this particular coach protein. So what we do is we say public Boyd, leave base. So this is the excess of which is going to be accessed later on from the game manager and everything inside needs to be off course performed. What do we need to set is at first we want to go one step. So we said steps is equal to one. So we only moved once inside the move out functionality. Also, what we want to do is we want to say is out is equal to true. So we set the bowling is out equal to truth to this particular stone we're currently moving . Then we need to make sure that our route position is going to be equal to zero. And here we need to start the core routine since we don't have that corroding at the moment , we need to create this. So basically what we do is the same stuff as in the more functionality or in the move co routine, but different because we had reporting differently to the game energy back and setting up stuff different. So let's create that for now. Let's go and copy the complete co routine. Move under that. You want to create this? Or maybe you want to create this directly under leaving the base up to you. I want to rename this one Toby, move out. So I know that when we're moving out, we're basically performing the same stuff, but was a different para meters later on in reporting. So what we now want to do is, whenever we're leaving the base, we want to start co routine open, close parentheses, move out. Open goes parentheses, enclose the line was a semi colon. So now we're leaving the base starting to co routine moving one step. If we're moving already, we don't do anything. And after we're done, was that or meanwhile we're doing so we gonna act divide round position. But in that case, we don't do this. We don't have great the route position, because here we set the rob position to zero. So we deactivate or actually commend this out for the moment. That's where the differences are going to start in the creation process. So in that case, we gonna go to the route position, which is, at the moment, zero. We can also type in a zero if we are well, actually unsure off course. Then we're gonna do the move to the next position, which is going to be the first position in that no matter where we are, basically doesn't really matter. Then after we had done was that we need gang steps by one, so it's turning out their own. We're leaving the while loop as well as adding up to done steps after that. Of course, we need to report all of that. I'm gonna make a command report back to, let's say, the game in a gym. Also, we need to update the note we're currently on or where we're coming from, So this part is going to be different later on inside the user move function or co routine as well. Let's say that and let's go back to the game manager. So in here, whenever we found a stone which is not out, we want to move to the next or we want to leave the base. So in this case, we can just call this particular function Leaf base, which we have created beforehand in the stone. So in that case, we call playlist inscribe records, active player. Don't my stones in square brackets, I as the index we're currently looping through still don't. And now we talk to leave base the function we just created over here. So we are going to leave the base. We're changing the state bank toe waiting, and then we return. Now, the last thing we need to do is of course, we need to make sure that we're calling checks. Start note with the correct eyes number. In that case, we're gonna take the tech start note functions, and we put in the dice number, which wherever the dice number is going to be, Usually we shouldn't do that or we don't need to do that because this is always returning the number six. But since we're taking a another function later on, like when we're moving a stone differently, like over here. When the start knows for examples full, then we need to the state's number to bring it into the move stone function, which we're going to create a bit later on. Don't forget to safe this game manager as well as the stone and let's try it out. Usually, we should also make sure that in the game an eternal we are doing a rule directly to a sex . In that case, we gonna commend I was dice number just for second over here and set dice number directly over here in. In that case, we're gonna once again create a new dice number and said it equal to six. That way we can make sure we are now not rolling a dice directly. Once again, this is just for debugging purposes. So later on, we're going to get rid of that and go back to this random ization when we are now pressing play checking. If gay manager is set up correctly, we gonna press play our first numb. Our first stone should leave the base and go on to the first field that's tested out. So we're rolling a dice. We usually should have set a six. The rolled my dies number is six. And now you can see the first stone in the list were moving to this part off here. Now we basically should go into a reroll and so on and so force. But that is part of one off the next videos. 24. #24 Update Node GameManager: Welcome back to the course in this part. We're going to update the note as well as the stone information based on the note that's going to open up the stone once again and we're gonna move down until we're hitting our move out. I nam Aerator. Yes, I in the last video just commended out that we need to report back to the game in a just well, as update the note when which ever were hitting at the moment. That's what we're gonna do now. First off, we want to set our goal note to be the current node. But also, we need to make sure that we attacking if the goal node is taken so we can probably kick some other stone, which is not going to be the current one from the field and send it back to wherever it has to be or go to. But that is what we're gonna do later on. First off, we want to make sure that gold note is going to be equal to the full route. Inst grab records route position. So the route position currently is zero. So we're gonna take the first note and set the stone school note. Toby, this one was that we can easier excess it right now and do or dual the updates to it. We're gonna do the reporting light on. So we're gonna bring this may be down here, and also I gonna put that here. So now we're gonna check if we can kick a stone sec for kicking other stone. We're gonna do that in a bit. So first off, we can already put the tank over here. So if the goal notes since we already have catched that if gold note is taken So if somebody is on there we want don't go and check their something else to do. In this case, we can return the stone back to the pace, whichever it ISS. So return. I gonna make a command over here to start bays note and that gays, once again this is for other stones says it's not for the current stone. We're gonna go over that, probably in the next video. What we now want to do is we want to set the goal note Don't stone to be equal to the stone we're currently at. So we say is equal to this Also, we want to set the goal note dot is taken to be equal to this or in this case, true. Now we have done was updating the goal note. Now we can copy that it to our current notes. So current node is equal to gold. Note. Now we have all the from information in our current note, and now we can reset the goal notes of gold. Gold is equal to now, so he's just empty. The goal note and that we're basically done was setting up the notes whenever. Once again we're moving out of the base. And now we can report back by, for example, giving the game manager the possibility to re roll the dice. Why do we need to re roll the dices rez? A. Simple because we have rolled the sex, right? So what we now can do is we can talk to the game manager daughter instance dot states, and we can set the state to be equal to gay manager dot states dot ruled ice. And that's the good thing about being a CPO. Now we can ask the automate the re rule. Meanwhile, all of that stuff is going to happen, and that should work. Who rendered Lee and perfectly the downside is once the first has moved, the second is going to go through, and the start note is going to be full. In that case, we can basically go and make a D buck line over here to just to check if all of that works . Debug. Don't long open close parentheses there. Start note. It's full, and then we are basically done over here because we have to move another stone, which is actually movable. So let's test it out. Whenever we don't have any problems over here and the consul, we gonna press play the first stone should roll a six, of course, and move out. Then the next one is going to rule another one, and it say's the start Node is full, and it's going to repeat that because it cannot do anything else, but also, whenever the start notice full, he's not rolling another nerve. Actually, another one. That's cool. So now we know that we can go out, but we can only go out once because this start notice full taken from an own player. Another player would not have any problem here because he would get kicked out of from or to wherever he came from. So now we're gonna be able to go forward and make sure that we're moving than player from the start field whenever it is possible, toe, actually get all the stones out. But for that, we're gonna need some more code, of course. 25. #25 Check Possible Move: welcome back to the course in this part. We want to make sure that we are able to move our stones. This is going to be add Split it point like once we need to make sure that we are able to kick somebody and also were able to move at all. And that's what we're gonna create right now. Since once again, whenever I was start notice for we need to move any stone as well as whenever the starting with this MD. But there's nobody in the base any more than we need to move the stone as well. And that's what we need to create. Otherwise, we are unable to move anything. Right? So I'm gonna close this one pretty quick over here, and we're gonna create our new function over here. I'm gonna name this function void, move a stone. There are several perimeters we need to check at first off. We need to implement, as I said before the diced amount or dies number. So whatever we have rolled, we need to take from the Czech start note and bring this into the move stone function. We're going to create true lists off type stone which are different. First off we declare it list. Of course, it is going to be off type stone and and here we gonna create a name for that? Of course, this is going to be a list for moveable stones. There's going to be a difference to the next one, and we need to initialize that to be a new stone list. So new list of types don't open close apprenticing Close the line was a semi column. You can if you lazy Copy that, of course. And bring the next dough NIST over here, And this one is going to be a move. I got a name it. Move. Kick stones. That means this archaic herbal stones are basically a stones which have the possibility to kick somebody body out of the game. Since we want to have a rather clever CPU, basically, which is able to kick out other stones, we want to give it the possibility to do that and as well check for this particular part. Now, what we want to do is we want to fill these two lists over in the next step. So I'm gonna make a command to fill the lists So what? To get what we do again with loops Rule the act of stones, of course. So, in this case, again, playlist in square brackets, active player dot my stones dot lengths. So we go through all the lengths or through all the stones, whatever from whatever the current active player is in our case once again. Still the red one. Only Morgan won't now want to check is if these stones are actually a playable. So meaning if they're not inside the base, this is there going to be the 1st 1 So if there's one in the base, we ignore it. So in that case, we say if playlist inscribed records active player dot my stones and then once again open close square brackets, I dot And now we want to request Return is out. Once again, we want to use the same bullying to see if at least that particular one we're looping through is out in the playfield. Basically, if that is the case, we want to make a move. Of course. So at least we want to check at first if we are able to move. So I gonna make a little command over here since we need to write two more functions on the stone side. So first here, we want to say tank for possible kick. So this is the first function over there, and then we want to make sure if there is nothing we can check, Of course. Want to go and continue or add to the move? Kick stones if there is some. So then we're gonna have another if statement over there, which is going to be the next one. So if the next or the current stone we are looping through is not saying we are actually able to kick somebody, we just want to make sure that, at least is movable. So check for possible move in this case. And once we had done was that Of course we can go and continue. So let's go over to our stone and check four. Kick a ball moves first off. I'm gonna close the move out over here in the leave base. We don't need those at the moment, and I gonna create two more functions. The 1st 1 is going to be off course, the public and it will return a bull. So if something is true or false. The 1st 1 should return check possible move. And of course, what we need to implement is the dice number, which we already got from the other side. So we need to implement this and of course, need to check forward in from the current position off the stone to the next position. In that case, what we need to do is we store a temporary position off type integer, and this is going to be the current route position, plus the dice number. Once again, we add basically to route position here needs to be as equal sign. So we add route position together with the dice number we're gonna set in. And now we have a temp position which we can request directly on the four route if that is going to be bigger or smaller. In that case, we need to make sure first that we're not over doing the lengths off the four route. So if the temp position is bigger or equal the full route dot count. So that is the case. We just want to return force. Since this is not a move, we can do So we say return force if we are passing this check so the length is basically possible inside the four route lengths. Then we go forward and return. Whatever is taken is toil actually talking to us. So return is not now. We need to negate the result. So return full route in square brackets, temp position. So the one we just created, the dot is taken and of course, close the line was a semi colon. So once again, we mean need to make sure that the temporary position which we calculate together from the current role position off this particular stone, whatever stone it is we're currently checking strew plus the dice number is matching the length off the four route or at least a smaller than that. If it is bigger than that, we're going to return false. If we're passing that so we would match, we going to return whatever is taking us returning. So if it is we're taking is going to be true. We need gate this and say it is not a possible move. That's where we need to negate this because this one is taken otherwise would return the wrong value and it would go to this particular position. Now we need to create the other tech possible one, which is going to be a public, full tank possible kick. And of course, we need to implement two things over here. At first we need to know the stone ideas. So int stone I d. As an argument over here as well as we need to know the diced amount as we did before. So dice number open goes curly braces over here, and we're good to go in the next part. We gonna go and continue on to check possible kick. Don't forget to save the script and let's see us in the next video. 26. #26 Check Possible Kick Move: Welcome back to the course in this part. We want to continue on check for possible kick. That's open the stone script as well as may be renamed. Check the possible toe. Be check. Possible move. So we have checked possible kick of a year so we don't confuse ourselves into what distinct are going to do. Also, you can always once again do yourself a favor and command lines out. So you know what this function is going to be about if you need Teoh. So you remember later on what you have done. Although what we have done over here what we were taking care off. Now what? We want to do it. We want to check for possible kick herbal stones. In this case, basically, we're going to start the same way as we did in the tank. Possible move. We gonna store 10 position and rob positions are gonna copy that as well as check if we're over doing the full route F Els, we're going to return the force. Of course, whenever the 10 position would be bigger than the four route in that case now, of course, we need to check if the four out is taken. And if that is the case, we need to check What is the current stone I d. So we going to do if open close parentheses, full route in square brackets, Temp position dot is taken. So if that is true, the next note we want to go to is taken. We need to now check for the stone I d. Otherwise, we are like when it is the same i d We are unable to kick somebody because it's our own stone. That's how we avoid it. In that case, we're going to implement another if statement, we can also put everything in one line basically doesn't really matter. So we can say if that is the case. If the stone has taken end. If the stone I d. We gonna actually request over here if stone I d. Is equal equal the full route Inscribe Rick Kids temp position dot Now we talked to the stone, which is sitting on that dot and now we get the stone i d. From that particular stone, which is going to be on it. Currently, it doesn't seem that we have implemented the stone I d anywhere so we need to do this. I gonna put this in the very top, maybe above the routes. So we laid on can see this one easier. In that case, we create a new end and call it stone I D. And we don't do anything over here. But we need to make sure this is this public because we need to set this later on inside the inspector. Now we're gonna get go down once again, and now we kids should be able to talk to the stone. I d. Over here. Now we compare the incoming stone idea with the current stone idea, which is sitting on the four road 10 position Note, basically. And if these two met, we know that we have to return false, because this is not a capable stone. Also, when that is not the case, we need to return. True, because this has not done any match over here. It means we need to return through at this point because the full route is taken. But the four route is not, or the stone ideas do not match. Then we know that we can return through also, whenever we're outside of that, like if that is not taken. Basically, we want to make sure that were returned force at the very end because none of these are actually matching over here. And we need to make sure that all requests over here return at least a true or false. And since we have a real actually a request over here, we have two requests over there. But we don't have an overall request. We would get a reference aero or something inside the boat or something like this is not going to return every way. Basically, we're checking this bull four. So in the very last we need to return False. Don't forget to save two stone script and let's go back to the game manager in here. We can now implement these functionalities for doing this requests. So first off, we need to do the request for the kick Herbal Stones. This is important that the kick is coming first, So if now we once again talk to playlist in square brackets Active player, don't my stones in square brackets I dot and now we should be able to check for possible kick check possible kick function up close Prentice's and now you see it requires is stone I d as well as the diced number. Where do we get the stone? I d from off course, we go to playlist in square brackets Active player Don't my stones in square brackets i dot stone i d And then we say comma. And after that, we're gonna put in the dice number we have ruled and requested before. Now we need to up close curly braces once again And now we can actually add this found. So depending on if it is returning to a force, of course we can give back a possible kick. So once again, we think that this is returning to or falls. And if that is going to return through, we gonna add this particular stone we're currently looping through into the move kick stone list. So move, kick stones don't add open close parentheses. And now we add playlist in square brackets, active player dot my stones in square brackets, I So this is going to return or bring the correct stone into this Also, we want to make sure since we found something which we can make use off, we want to set to continue and go over to the next step. Since this for loop is reacting to Contin u and we don't need to do all of that stuff again because at this point, we already added to move kick stones. Otherwise we would have moved kick stones and movable stones at the same time. We want to avoid that. So we continue at this point if we haven't found a kick a ball stone off course, we want to make sure that we attacking for the next possible move. In that case, we can basically take the complete function and just copy that. Pace it all over here. In that case, the tank possible kick needs to be check possible move. But we don't need to implement a stone, I d but just the dice number so we can get rid off this part. Once again, you can have over with the mouse. And you see, we only request the dice number. And of course, when we have found something and it returns true, we want to bring this particular stone we're currently going through to the movable stones list. So we say movable stones don't add playlist. Active player. My stones in square brackets. I we don't need to continue at this point because it doesn't make sense. And now, in the next steps, we need to make sure since we now know which we can make a move kick and immovable actually a normal move, we can continue by checking the lengths off these two lists to make the correct move in the end. 27. #27 Making a Move 1: Welcome back to the course in this part. We want to make sure that one off our stones is going to be moved. No matter if it is a kick, move or adjust the usual move. So let's open up our game manager and go to the movies. Stone function where we have actually filled the complete lists was movable or move clickable stones after the four loop, which is going to be over here we're gonna command out, or I gonna do a command over here, perform kick if possible. That is not the case. We gonna perform a move, if possible. And if we have none off the song, none is possible. We want to make sure that we are switching the player so the next player can have his turn . Okay, so first off, let's check for a performer kick of possible to do that, we just count how many movable or in this case capable stones we do. We have. If that number is bigger than zero, actually, we can perform a kick. So if move kick stones is bigger or in this case dot count is bigger than zero. Then we know we haven't least found one stone which is able to kick another stone out. But since we want to randomize that a bit so it's not only performing one, but we have, like, several different one. We can randomly pick from whoever is possible to kick and just kick at least one off that. So I'm gonna create a random number. Int num is equal to once again random dot range You know that already between and now we go between zero comma and now we take the move. Kick stones don't count into consideration. So if they are to incite, he will pick a number between zero and one off course since one is the last element in the list and since we're starting at zero, that's going to be the one which is going to be zero or one in return. And now he picks from one off these stones randomly. So how do we do this? Of course. We need to talk to the move, kick stones in square brackets numb. So we take the number which we just rolled before, and now we need to start the move. Since we don't have the start move, I gonna actually create that pretty quick start, Start the move and we don't have this function. But we want to implement the dice number in that as well. Once again, the start malfunction is currently not available. We need to create this in the stone. Since we're talking to the storm, we can go Prada quickly, go over there and just say public. Start the move. Open close parentheses, int. And now, once again, we request. Actually, it's off type Floyd. Since you don't return anything, we going to implement the dice number in here as well. Currently, we don't do anything but just keep that empty since the move is going to be just raise a sample. So once again, don't forget to say it's the Stone script. Since we have added that and now the red one is going to go over there or actually destroys itself. And what we want to do is of course, you want to set our states to be equal to state of waiting since we're waiting for the move to be done and that's everything over there. But also we need to make sure that we're returning here so we don't perform everything, which is coming after. So whenever we return, we leave the complete move stone function. At this particular point, this is absolutely pull you needed. Otherwise we would also perform another possible move as well as switching the player. All of that is nothing what we want. So basically, now you know how the 1st 1 is going to be. Of course, the 2nd 1 is basically the same. We just copy this F statement are gonna put this in here. In this case, we gonna perform the movable stone start count. And of course, we copy this name and bring this also in here, since we want to count the Movable Stones. Same for here. Movable stones. And we're good to go. So basically, we're going to do the same. We gonna do start the move. So basically the same functionality on the other side and off course, we go to states that waiting as well as return at this point. And once again, finally, we're going to switch the player at this point later on. So the next one is able to do something. If there's no possible move, we can also debunk that at this particular point. So we can say debug dot Long suit switch player. Something like that. So we know. Okay. In here. We gonna perform everything when move kick stones is worse. Movable stones is smaller than actually one. Don't forget to save the game in the deaths. Worse the stone if you haven't already and we can go and start to create this start the move function over here. 28. #28 Making a Move 2: welcome back to the course in this part. We want to actually start to move the stone to whatever the next position is going to be whenever it's not a six or even a six doesn't really matter at this point, since both off these were ways are going to work the same way it's open up our stone script and go to the start. The move into dice number function. First off, of course you know what's coming, right? So we need to set steps to be equal to the dice number over here, so we know. Okay, we rolled whatever number is going to be, and we want to perform the move. In that case, as you probably also know, we need to stop the core routine called Move and, of course, open grows Prentice's and close. The line was a semi colon, so now we are going inside the move. I numerator over here and perform our steps until we're done with that. You know already that it's working because we tested that in the update loop over there. But we need also report back to the game manager as well as a setting up everything correctly so the notes are actually setting up themselves also whenever we're done. Was that how do we do this? Of course. Basically, we're going to do whatever we have done in the move out script or move out coating. First off, we need to set our goal note to be equal to the full route in square brackets in this case route position. Since that is the position we are currently at, then we want to check, of course, for possible kinks or update possible kicks tank. Possible kick in. That case we request is gold Note. Don't is taken. We're gonna do the kick for the other stone over here. Kick the other stone once again. This is not going to be the same kick checker, actually. Ah, as before, because we only perform this whenever there has been the other possible kick already returning a true in this particular case. So just keep that in mind. This is just performing it. So ah, to make sure that he's kicking the stone, we're gonna create an extra function for that as well and return it back to the base where it came from. Now we need to Of course, update the current note as well as the goal node afterwards. So first off we say the current node dot stone so the stone or the current, nor were basically coming from is needs to be zeroed out. So it's equal toe now, so it deleted out of it. Also, the current note don't is taken is equal to force, so we need to make sure that this one is an empty one. Once again, this is well, we are coming from. So now we're gonna need to set the goal note. Don't Stone is going to be equal to this particular stone. Of course, Now we need to say also the Goldstone goal node don't is taken as equal to true. And now we gonna copy all the content back to the current notes so we can say current node is equal to gold note. And of course, now we're going to reset the goal notes. A goal node is equal to know this is a bit back and force, but actually, we make sure that we don't have any doubles or triples or quadruples. That's why we're cleaning the current note first. And then we're gonna set up that we can also do it the other way. Basically, doesn't really matter. But now you know. Okay, whatever the current notice where we're coming from, we sent this 1 to 0 and set this one free. So it's not taking any more. Then we're gonna take the goal. Not because we have that's already over there and a set the current stone, which we are having over there to this particular one and set taken to be true as well. And then we just copy the goal note onto the current note, reset the goal note, and then we're back to normal. And what we now can do is we can basically check for a win condition at this particular point as well as, of course, report back at all to the game manager. So for that, we're gonna after a possibilities. As I explained before, I gonna do a command over here, report to game manager again. So what we can do is we can't do switch the player. We don't have that at the moment. I'm gonna make another comment. Switch the player. As I explained already inside the very first video about the concept we can do bulls like it? That doesn't like something. It doesn't really matter if it is a six or not. We still switch the player because we're doing a normal move in that case, or we're gonna take care of the number and a store that somewhere, like maybe a like anywhere. If that last number is going to be six, we're gonna do this going to do a re royal. Otherwise, we're gonna do the switch to the player. So there are several possibilities at this point. I believe you get the idea over here so we don't want to re rule the dies at the moment. We just want to make sure that we are switching the player inside the game in it, and that's what we need to create. Also, in the next or one of the next videos, go back to unit. You don't forget to save every script and see of the consul is clearing up correctly. And there's no debugging aero or anything else, any typos and so on and so force. And then we should not be able to move out. I was stone. So once again, we don't have to switch the player state over there. We can go to the game and it at the very top where we are rolling the dice. And now we should be able Teoh, actually get rid off this number and to do this one over here once again. But I want to show you that all that stuff is going toe work just was one Picula player. So we're moving out the first stone. Then he's re rolling the dice. He cannot move. So since the start node, once again, it's full. And he should know. Take this stone and bring this over here to this position. But since we're not calling the move function, we need to do this pretty quick. Once again, Scroll down in the game Manager, where we need to perform the move. A stone needs to be performed inside the check. Start note. So wherever I have this command, like if the start notice full, we gonna call move a stone open close Prentice season. Of course, inside. We need to talk to it with the dice number. And once again, if the start nose is not full and there's nobody left inside the base, we need to make sure sure that we're moving the stone of the very bottom over here as well . Don't forget to save the script and let's try again. So our CPO should move the dice for us over here. Then it re rules the six and goes to this point pretty good. Now he re rolls the dice. Well, she should. But since suggested a usual or normal non kick move, he's not going to do this. He's still staying in the waiting state of there because we didn't say that. He has to re roll the dice in the eye, numerator off the movement once again Now, usually it should be that he can once again, depending on the rules you want to implement re roll the dice and do another six go here, check for everything taking and so on and so force and she should be able to move forward. I gonna give it a chance to or you the chance to check it out. Once again, I'm gonna reduce all of that a bit. So instead of switching the player, I gonna reporting out of the game manager to re roll the dice so you can see this player alone can dual the movement. You can go to the enema rate a move out and take the the possibility over there I gonna just talk to the game and the general instance Don't. And I want to talk to the state is equal to, And I want to set this one to re roll the dice so we can't see all the possible moves until we're reaching the end. Let's check it out. I gotta press play. Don't forget to save once again, we're gonna delete this line later on. Now we wait until he's moving the 1st 6 numbers. Now he is re rolling the dice, sending out the next checking who is possible to move. And the only one possible wants this one. Now we can re rule and since he is now randomly taken, one or the other doesn't really matter. But at least it has to be free. He's going to be able to do all the moves. Once again, he's picking randomly from these two points now he could do sties to, but also the 1st 1 And now he's doing all the re rolling until he is actually able or not able to do anything else. Once again, he's doing all this randomly. Were only ruling. Six is at the moment. So now he has the last one out, and now he's able to move like every stone. Except there's one right now accordingly. So this one should be also be able to go until the last point and one day or the other there, almost the last 10.1 day or the other. All of them are razor close over here together, and that's everything we need for our gameplay. I guess. Now we need to implement uneven numbers as well as different players. 29. #29 Adding the other Stones: welcome back to the course in this part. I want to create the other players as well. Since, of course, we want to make sure that they are all playable and have different ideas to check. If kicking works, it's well, if you are selecting now all the Redstone's, you're going to see that in the very top. You're gonna have the stone idea over here. You can keep the 1st 1 a zero or just change it. Toe one. It's basically up to you now. What I want to do is I want to duplicate at least one of these and make sure that I create a green, a yellow and the blue player. You can do the same. Just duplicate this and bring this all over the place to this point. And you also might want to go into the materials for the if you haven't already and create another green, another yellow and another blue material without the albedo off the grid, like off this border, actually, So when you have that, of course, you can or should rename this one to be green Stone. In that case, it's going to be number one. Also, you want to drank the new green material. In my case, it's named green one. Basically, you can also name it Green Stone. So if you don't like green one, we named this one to Green Stone. So you always know what's going on. Same for the blue. Once again, you just duplicated, as I have probably have shown already with the red one, and you're gonna update them accordingly. Oh, this needs to be yellow. Just don't. So now, since you have that you cannot duplicate the green stone over here like another three times and bring this somewhere on toe. The bass notes, of course. Make sure that all these stones do have another start Note as well as all the other bass notes are gonna select them all pretty quick. And I make sure that I can basically lock the selection as before, take this one as my stud naled and bring note 12. Now into the start note over here. Once again, the calculation all starts from this note overflows until his reaches the last point over there. You're gonna see that once the game is running. Same for the bass note. You want to make sure that All these guys do have a different base node right now. I'm gonna do the same as we have done with all the red ones to see what is going to be the base. Note off that particular stone. So we select it, lock the selection, select the note, and bring this into the bass note. Unlock the selection. Select the next one. Of course. Locks of selection again picked the note and bring this one into the bass note. Same for the next stone. Unlock and lock us again. Selected note directly behind the under it. And to make sure you pick the correct bass note. Same here. Unlock lock. Take the corresponding bass note and bring this over here. Also all the green stones. I want to make sure that I select them and set the stone. I d to be different to the Red Stones in this case are gonna pick too. So, stone I d one is going to be on this town store ready to then yellow is probably three. And this honest war, you can give it any idea name as long as all the stones do contain or have the same I d in this case. So now we're gonna need to create a Yellowstone as well. So I gonna keep on public 81 of this Green stones snapped them toe one of the scripts over there. I gotta make sure that of course I gonna rename the stone Toby A Yellowstone. Of course. I need to make sure that I unlock the selection before I can rename this. Otherwise, it doesn't make sense. Yellow Stone. No one can actually give it the next material going to be the Yellowstone material. Also, once again, you can now already actually change the stone, ready to be number three in that particular case, if you like to. And also, you want to make sure that the start note is going to be this first note. So again, you can actually locked that. Take the start note and bring this over here into the starting outfield off this green or yellow stone. In this particular case, unlock the selection again and go back to the stone. Now, we just need to once again copy this all over three times again and check out or update the bass notes. So I'm gonna duplicate this once being the CIA, the medicate again duplicate again. How you do this is up to you. Eso here. Keep in mind that you need to upgrade or update all of this base notes one at the time. So again, I'm gonna take the 1st 1 Lock the selection, take the bass note off the yellow base. And, of course, bring this into a bass note. Same here. Unlock and lock the selection. Take the bass. Note this case number one and bring this all over the place. Same here. Lock or unlock and lock again. Bring this one into that. And same for the last stone over. There you go. Unlock and lock. Thanks. Us note. Over here. And bring this into the bass note. Ah, yeah, off the corresponding stone. So that should be everything for the yellow one. Once again, you can always again unlock that, and I check all the stones out once again. Especially. It needs to be a need to make sure that all the stones do contain the same stone ideas. Well, it's the same Start. Note once again. You can also check this for the Green Stones again. As you can see, something has changed over this are gonna need to rewrite all of that inside the stone. I d from the green ones. I believe it's because of the selection I had before. And these ones need to be all stone I d. One. And finally we're gonna go over into the green until the blue ones. So I'm gonna take one of these stones, a double IQ ated, and bring this all over the place. And, of course, make sure that it is matching the bass note field. Then I can go and rename this because this is going to be the bluestone. Of course, I need to make sure that I add this one as a stone I d four and the bass note or the start note is going to beat this one. So I locked the selection again. Take this field and bring this into the start note off the blue one nationally. And now we can duplicate that as well. Let's give it another color. First bluestone color. And now I can duplicate this 13 more times an update, the basements. So I'm gonna copy that bio once again, Control de, bring this all over the place until I four blue stones again. I take the 1st 1 locks a selection if it isn't locked already, and then update the bass notes accordingly. So this one does get this bass. Note this one once again, unlock and lock again to take the correct one is going to be this. We're gonna take this one. Unlock and lock again. Take the other bass note. Bring this one over here as well as the very last stone over there. Unlock and lock the selection. And, of course, take the first base note and bring this over there. Unlock the selection again, just to make sure select all of the stones and make a check. If the start more note is going to be correct as well as the other ones, Finally we're gonna need Teoh change the final routes for all of these. Since once again, the Green Stones over here, they need to contain or get the final route, Of course for the green one. So the green route in this case, So select all the green stones and take the green route and bring this over here to final road. So this is finished as well. Take the yellow ones, the Yellow Stones in that particular case again. And make sure that the final route is going to become the yellow route. So go to roads, check on Peck yellow route, and bring this over here. And the last step off course is going to be for the blue ones. These need to know the blue route. So I got a copy that, or actually drank the brew route into the final route. Now we're done with that, and we can save the game, Of course. Once again, just to make sure. And if there are any problems, we gonna notice that later on us. Well, no matter what. 30. #30 Switch Players: welcome back to the course in this part. We want to actually start to switch the active player, meaning once the red play in this case is done with his turn, we want to make sure that the Green Player has his turn. And then the yellow, the blue and, of course, start again on the red one. Also weekend late on dice, Who is going to be the first player? But that is nothing off that particular at the moment. So go into your game and it just gripped and we need to create, like, at least two new functions. The 1st 1 is going to give us a small delay before we're switching the player. So probably a second or two, and also we're gonna protect that anything else is going to happen. Meanwhile, this is important, so otherwise, maybe some or the other state is going to override another state. So that's what we need to have a delay at least of two seconds. Once again we have, the rule dies. Delight was two seconds. Then we're doing, the rule dies and everything which is going to do the move and all that stuff, and meanwhile, were moving. We want to avoid that. We're doing anything else. That and also we don't overdo it in total. In that case, we're gonna create an I enumerated for that once again, a coat protein which is going to do or we call switch, plan open, close parentheses and then Kohli braises we wanted first check. If we're currently switching a player for that, we're gonna use the bull we already have created. So if switching player that is the case, of course I want to break out off the I numerator. So we say break. Ah, in this case, yield brink because we're gonna have to create always yield statements for court routines to work correctly once we're done was dead. Of course, we want to send switching player to be equal to true. And, of course, at the very end, before we're gonna forget this are gonna copy this one. And at the very last, we're gonna set this one back to force, so we know we can actually go into which another player whenever we have to, can. Now what we want to do in between the true and the false over there. Of course, we want to do the little waiting. First off, we say yield return. You wait for seconds and probably we're gonna put a number like two seconds is that it's too long for you later on. You can change that now. What we want to do is we want to call a function to sent the correct active player set. Next player. This is what we're gonna create right after the switching players. So we say Boyd set next active player, something like that. We can also name this one switch Active player doesn't really matter. Once again. This all up to you how you want to name that and how we want to create all of the's. First off, we want to implement or increments the act of players so Active player plus Plus, this is important. Otherwise, of course, we overdo ourselves or we are not actually am doing Anak to switch. So we're going to start at Active Player zero in this particular case and we want to add to it. But since I will play list, what we went once we have set it up correctly is not longer than four. We don't want to overdo it and That's why we need Teoh asked Lee keep on protecting the overflow. And the easiest way in this case is we're gonna say Active player model equal. Once again, we make sure that we don't overdo it and start once again at zero. Once we hit play list bought counts of the maximum list amount of this. So whenever we're hitting the playlist account, then we're going to start at zero once again, so we don't overdo it with that was active player. So now we want to check how many at available player we have so available means if we have more than one available player who has not won. So because otherwise the next function with the next statement is going to go and create a stack overflow. So first, let me create the statement for the where the stack of a flow would happen is going to be We need to tank if the playlist in square brackets active player don't has one. So if this one has one already we created has won quite a while ago, we want to make sure that we're going to the next player, right? So in that case, we gonna us call the same function set next, next active player once again. So the one we are currently in and off course, we want to make sure that we're returning and don't perform anything which is coming next. So when one particular player is already has already won, we want to recall the same function. So again we start all over, see if we're protecting ourselves by overflow. And, of course, check the next player if he has one or not. If not, of course, we go forward. So But once we are hitting the sort play or there's only one player left or nobody probably we're gonna create a stack, overflow it this particular point. And ah, this is not cool because we want to make sure that we have at least two players still won't . We are still playing in this case. So what we can do is we can create a small indigent and check for available zor count available up. So we're gonna give it just a available is equal to zero. We need a once again set local variables already to something, and now we're gonna do a check for available player. In that case, we're gonna loop through all possible players. That's true, like the complete plant list and check if one of these has one or not. In that case, we're gonna go and say we go and loops, repay a playlist, Sadat count And what we want to thank us, of course, if playlist in square brackets I don't And in there we have has one which has every player has that. If that is the case, of course we want to implement or in cream int active player or, in this case, available player, so available plus plus. But we don't want to check if they have one. We want to know if this nobody has one, so we need an a exclamation mark in front of that. So if the next player we're currently Jenkins who has not won, only then we increments available, that's cool. So now we have a secure check to make sure that no, but we haven't least this or that amount off player being available, and also we can implement this inside. I will request. So if we have or this current one has one all ready and available is bigger than one Onley , then we're gonna do and switch the player of he and return. Otherwise it doesn't make sense. Because we are basically done Was the game. Of course, because everybody has one except the last one that, like the player for in this case, I don't want to do an else check. So else, if available is smaller than two, Of course, we go back into the waiting state, so basically go into an infinite ah waiting ST Loup. We can also do anything else. In that case, we at first go into a state don't states waiting. This is important once again. So we don't reroll do anything else or any fancy and off course. We want to make sure we're going to return over there. So also what we can do it. Since the game is over, we can also shame show a game over screen. You might want to Partick or take ah, something with that into consideration, as well as to make a note over their game over screen can be shown over here. Not necessarily. Go to the waking state Depends on how you want to show the game over screen at this point because all the player are basically done was playing the game. So the cert one just entered and the Force player just is the loser. So you know that also, you can later on store who's won first, next and so on and so force. And that's everything what we're gonna do here. So whenever we're setting the active player and were passing by all of that, and we don't return at setting the next player as well as not having only one player left or even less in this case, at least one. Then we go and change the state to be equal to states. Good rule dice because the next player, whoever the current player is on ex players needs to roll the dice, of course, and that's probably everything we need to do over there. There's one more thing, of course, we need to do. We need to call switch players there, the switch player functionalities like set. It's next active player. I'm gonna copy that and, of course, bring this into our switch player. I m aerator or karate? Nope, across Prentice's and close the line was the semi column, so we call that set switching back set the next act next active player and depending on whatever the state of the next player is going to be, we going to roll the dice or go into the waiting state if there's nobody else here which is able to win. So when was that? We can basically go into the game manager and set it up so that all the possible players in the game are actually having stones and stuff. 31. #31 GameManager Update: welcome back to the course. In the last part, we were able toe dual the switching player content. Now we need to make sure that our game manager knows all current players. So currently we're creating the CPU players so all of them should be able to kick themselves out and stuff like that. We already created the complete functionality for this. But now we want to make sure that we are actually setting up the game and it just so that all the players are correctly set it up as well as they are able to play the game. Right? So what we need to do is we need Teoh, Doublet, Kate or asset. Create more players for our list at, as you can see at the moment we only contain a red player was his four Red Stones. And we know that the player type is going to be CPU. But that's it. Nothing else. We don't need no anything else. We don't know the green, yellow and blue one. What do you want to do is you want to go and pick the next one going to be the green one? Otherwise it is going to be like a strange here set up over there. So when you're having your red one in the first corner, the next corner which is going to be this one should be the green. So I'm gonna create, like, a screen new players and, as you can see or in this case, and told her we need four. All are red at the moment, so I'm gonna take the 2nd 1 And the second, as I explained, needs to be the Green Player. Otherwise, you have, like, this is going to be first and probably the second dessert. This force. We don't want to sort them out later on. So you make sure you want to go from this corner or whichever corner your first is. You go to red, green, yellow and then blue and back to the red. So everybody has the same chance to win and stuff like that and of course, do pressure. So what we can do is the stones can be reduced to zero, and don't forget to hit enter, So it's updating correctly. Now we gonna Calamba that with lock symbol are gonna select all green stones and bring them into my stones list. from the Green Player, and that's basically it. So now we go to the next one is going to be the yellow players are gonna name it yellow. You can also name them. Play a 1234 Doesn't really matter for me and for your student as well. We're going to reduce my stones to zero. I'm gonna take all the Yellowstone's and bring those into my stones. And lastly, we're gonna take the blue one over here. We named this one to blue Go Make sure that we reduce the number off the stone is 20 Pick all Blue Stones and make sure I direct them onto the name my stones. Now everything is set up and we know that we have no four different players. So the game and it doesn't know that and he's able to play the game without us. But before we can do that, of course, we need to make sure that all the functions are set it up correctly. What does it mean? Our stones, for example, probably want Teoh not go and roll the dice again because we're gonna need to switch the player whenever we're done with our move once again. This can also be dependent on if we have a rule. The 6/4 this particular player or not, So we can implement this in a bit later. So in that case, whenever we're done with, our outperforming dies. We want to make sure that we're calling the state switch player. Also, don't forget to say so, stone and go to the game manager where we have on the state machine which is currently sitting in the update loop. As you can see currently, we don't switch anything inside thes player. So what we need to do is we need to call this court protein switch player. So we say, start core routine, open close parentheses, switch player. And, of course, often close parentheses. Enclose the line was a semicolon. Once we're starting the car routine, we want to make sure that we have set the state to be equal to states. Don't waiting s usual. So we always go back into the waiting state. Once again, this is just idle. Ah, this is just idling and waiting for the next input. So most of the time, we're going to stay inside the waiting stay. We just call this one's go back toe way to call this. Go back to weight and so on. So we protect any doubles or triples a quart. Trible calls on particular functions. Keep that in mind. Don't forget to say the game, Energia. And of course, we now can go and rule real numbers, meaning whenever we're going into our rule dice white function instead of just and only giving us six is we can also just to a normal role, as we did before. I commend out the inter dice number, but in that particular case, when we're using this, we may or may not have a kick out off the Playfield. Rez is simple and easy just to see if that stuff it's working, which means we probably need to go and change some of the rules. However, there's a little type of, I guess, over here, which is going to be the switch player functionality over there. I'm gonna go and see what's going on with that name. Oh, I have a type over here. This needs to be a nine AM A rate or not, I innumerable number rubble. Don't forget to save. If you have done the same type of I'm sorry about that. It was just the type of nothing fancy at all. Now, you shouldn't have any arose as I had. You can clear the console and he can basically start the game. Also, you can always see now who is going to have a turn and what they're going to do. We don't debunk everything, but most of the time, that should work correctly. So dies rolled number six or number four in this case. So the green one should be the next one. But anyhow, this player is not switching the player. And that's what we have forgot as well. We need to implement this after we don't have any match or any possible Turn One. We do is, of course, we go to move a stone. And the Valerie last where we I have already commanded this one out. Should switch player, which probably sort of quality anyways, but it doesn't. Why ever is we gonna need to call move a stone from somewhere else as well. And of course, we don't have the check for kick in this particular case. So whenever we're no moving the number over there, we don't do if we are able to do any year, any turn, at least. So what we need to do is in here. We need to go and call. Ah state don't want sent to the States to be equal to switching player like this. So we're going to start the co routine from this point as well. And of course, in the very last we need to create the next function which is coming when we are not rolling a sex. 32. #32 CPUs can move: welcome back to the course in this part. We, of course, want to finalize that that whenever we're rolling another number than the sinks that we're going to activate them, moving onto this or even go back to switch the player because there's no possible move and the super easiest one of theirs. We just call move a stone because this is going to do all the checks for us creating the list of movable Zinke cables. And if one of these is going to match, we're going to do the move. Otherwise, if there's no movable possibility as again we created in the last video, we gonna switch the player anyway. So if normal these articles or even movable stones available, we just switch the state to switch player and to start all over. So in that case, we gonna do a check for a check for move. In this case, we're gonna say, move a stone, open close parentheses, and we now need to put in the number we have just rolled with the dice. In this case, the dice number. Don't forget to save, and that's check that out. Also in your game Manager. You want to make sure that all the notes all the players are set to be CPU. So go to game in the opening more and see you that the player type is completely CPU y. So gret green, yellow and blue should know BCP for you. If there's something else or deactivated mixture, you are going to do that or you actually have all of them set to CPO. When you have no Eros and stuff like that, you can just go in, simply play and see what's going on. The console is most of the time, giving you d buck lines like Okay, the player. Six. Roll the dice. Number six. Now, As you can see, the active player changes to one whenever you have to came in. Interactive the player one in this case or in this bags case player Green. Just roll the wrong number, and now all of these are going to go and continue playing on their own. So play a rant had a four, so he was able to go and move for four words and so on and so force. Now all of these CPU players are going to try to reach the goal. Note in the very end, so meaning whenever this is full, of course he's going to the next one and so on and so force and since, therefore player in total, this going to take some time until the play. The game is done off course and at least one of them has won because also, there are lots of stones over there. You might want to go and check all of these play abilities and check if one or the other is going to go and ah, do the play mint as one more thing we forgot to implement, which is going to be whenever one is getting kicked. He is removing back the stone toe, this Ashley Bass note over there, and that's what we're going to implement in the next video. 33. #33 Return Kicked Player: Welcome back to the course in this part. We want to make sure that one or the other player is going to be able to kick player out off the playfield and bring him back to is a bass note. Open up your script and go to the stone in here where we are saying we want toe kick the other stone. If the goal node is taken, we gonna have to create a function for that and of course, excess. The other stone. Since we're still going to be inside one stone, of course, we can create a function for that directly in stone. We just need to make sure that we call the other one for us off. I'm gonna create a public void, return to base function. We don't need Teoh put any arguments inside that. But what we want to do is we want to start a co routine that since this is going to be active movement, we also going to make sure that we are making use of our move to next note. In that case, the note is going to be the base note. What we want to do is we want to create it first, Another I numerator or cool routine. So I numerator and I just name it. Return open, close parentheses, of course, as usual. And of course, open close curly braces we want to do is whenever we're returning some stone back, we want to reset like everything this particular stone has on it. First off, we want to reset the route position. So Ralph position is equal to zero. Next one is we want to set its current note to be equal to know so it is currently not on anyone. It can also be said to be the base note, but basically doesn't really matter. Same for the goal note, just in case we're going to going to set this one to be equal to know as well. Also, we want to reset its that this stone is going to be out. So we say is out is equal toe false? Because it's not, you know, in the game anymore. And of course, you want to reset the done steps and so done Steps is equal to zero as well, meaning we haven't walked anywhere, and we can literally go on now we want to initialize the movement. So we say vectors, Ray, we're gonna store that pretty quick and effective three and to talk or request the bass note position when we set this one equal to bass. Note. This is the note we already have. Don't game object. Don't transform. Don't position, though. This is going to be the note where we want to go to and what we want to do is, of course, while we're moving to the next note. So while move to next note, we're going to implement, of course, to go position as well as the speed. In that case, we're gonna take the bass note position. That's one comma. And now I put our rez a high number like 100 f onto this. I'm gonna explain in a moment. Why? And of course, whenever we're doing that, we want to yield return now. Meanwhile, doing so so yield return? No. And of course, closer line was a semi colon inside the curly braces. So why do I put this high number Overhears raises simple. Meanwhile, were returning this stone. It is possible that meanwhile getting rolled, it is not back in the base already, and it could get give us a big flip flap around between those stones because we are setting this one already back to that and it can be ruled a number from the next player who's has his turn. And when doesn't this actually this Ah figure or the stone has not returned back to the base. It probably has some strange behavior. We can actually go and protect this one laid on. And we're gonna do this directly in the game and a job, and we're going to test it out in return to base. Of course, we want to start the code routine, which is called Return. So open, close parentheses. Return was a big are probably doesn't find it directly and open close parentheses and close the line was a semi colon once again. So whenever we're now calling returned to base, it will be returned to the base, requires the bass note, of course, and moves back to it wizard as a high speed of 100. Now we need to make sure that return is called or in this case, return to base is called. Whenever we're moving and kicking people out In this case, we want to kick the other stone, so we return to base. But we need to have some indicator because we don't want to return ourselves to a base. But we want to take the stone, which is sitting on the goal node and sent this one back to the actual Yeah, his own base. So we say, goal note dot stone. And here we cannot say don't return to base and close. The land was a semi colon. So whoever the other stoners who was sitting currently on the goal note is going to be this one over here. So we're gonna say the other gold or the other stone needs to move from his. Yeah, actually note back to his base. In that case, we also return, or Ashley reset the current goal note and it's getting over written later on by this stone anyways, So that's how we do it over here inside the move I numerator as well as we need to do the same one in the move out. I numerator over here. So we say in here once again. Goal node dot stone, don't return to base open cost fantasies and close the line was a semi colon So now we're sure that the Stones are going to return back to the base once again. They're doing it at the moment. Raise a high speed, but we can protect some overflow. Also inside the game in a job. 34. #34 Protect After Kick: Welcome back to the course in this part. I want to make sure that we're protecting the game in. Just switch things. Switching states. Whenever we're moving one off the kicked stones back to the base at the moment, we just say, OK, we're gonna do this Reds a quick and return them as soon as possible, was the fastest we can, and even higher numbers would work. It's well, but this is the raison secure way. How we can do that better, actually, is we going to implement a bull which is going to be, or taking care off that we are only doing or be able to perform a move whenever the school is true? Otherwise, of course, it doesn't make sense. So once again, we need to make sure that we're protecting, like the states or the functions inside the States. With this particular bull, we gonna make sure that this one is the private bull, since we don't want to directly have access to that and want to make sure nothing can happen. So we're gonna name it bull and maybe something like turn possible. And I want to make sure that I set this initially to be true. This is important because we want to make sure that whenever this is true, of course we want to perform. What we also can do is inside the rule. Dyson's, which Blair functions or switch statements in this case, is over here. We can say if turn possible. Only then we gonna perform start core routine and switching the state. Meanwhile, this would be false. This is going to not leave the state. So we're gonna wait until turn possible is becoming true. Same here. Insights which played to whatever we are commonly in inside. Whenever we're in switching plan, we should switch a player. At the moment. We want to make sure that we're only switching a payer whenever the turn is possible. Meaning whenever the stone has Bean reported that he's able to go or he has been a landed inside the space so we can go to the next turn and switch the player. Now we need to have some connection to the stone or the stone to the game manager. So it was can talk to it and say, Oh, by the way, currently I'm now I'm able to turn or I'm not able to turn to something or actually make make sure you don't do anything because the turn is currently not available. How we do this, of course we create a public function for that of type point. We gonna say we name it report turn possible or something like that. So you know what's going on? And we want to send in a bull off course because this is what we want to dio, and we gonna be able to bring it something like possible. I don't know. We can name it, whatever we like. And in here what? Whenever we call this function, we want to set turn possible equal to possible meaning. We're gonna send a true or false inside of this function and set to impossible based on to this so we can actually make sure that the game in Georgia is not making any this any problems later on, whenever we're moving the stone too small for except want to slow Now we need to go into our stone again Inside the turn. I nam aerated. Whenever we have started this one, we want to report to the game manager first so we can say game and digital instance report to impossible and currently want to say no. We don't want Teoh actually have a next turn. So please wait before we do anything else and we return false over here or actually request or set of false whenever we're done was moving to our next state and we are actually out of the while loop. We can report back to be true. So actually the game indigenas Okay, I can go forward. The next turn is able or available for us because turn is possible once again, Don't forget to save the game and it s well, it's the stone and now you are absolutely able to test out everything. You can also change the speed now extremely down, if you like to same speed as probably the move so you can get an idea off what's going on? 35. #35 Recap: Welcome back to the course in this part. I want to read a quick want to do a recap. Meanwhile, I let the game run and you probably see some action as you have seen this green one just got kicked out from the yellow one, so I want to recap. Credit, credit, Quick what we have done so far. We created a game and a germ, which is containing like a player list. Was all that Stones names and the type like CP or Human or even known no one is going to play it. We're gonna talk about that once again. But later on, then we have created the functionality off Active player, which is like Who did is has actually the current turn or even the next turn. Also, we have the CBO created at the moment, and let's talk about this pretty quick. So the CPU was able to roll the dice whenever turn is available. And, of course, whenever use a ruling, a six and he has a least one in the base. He's going to check at the start, noticed empty, so like the color field and sent out the next tone of it is possible as well as go on reroll if he has not an empty start Note. As you already see, you gonna check? Well, he's going to check for the same i d. And then is going to move on A. Depending on if there is a possible eternal, even not like, if there's a capable or even a possible. If there is a capable, of course is going to kick him. How to. If not, he got do and perform a possible one, meaning, if there is one which is actually has left the base already as well. Asses able to perform that and it takes one off those which are currently outside and are able to do the turn. And after we're done was that we basically go into a real rule. Since we have actually done as six Bundle at the moment, we are not always doing it. We are only doing that if the start note is actually empty into the reroll over here in here. When we're doing that, we are basically switching the play after rolling a six. We have not implemented a re rule as a possibility, but we can easily do that Same for If we don't have a six over there, we gonna basically do the same for possible tax off checks for a kick, A bulls or not give kick Couples as well is doing all that stuff. Same here when the start notice not empty. And it's not the same idea idea. Of course. He's going to send out the stone to kick whatever is going to be on and does the re rule. So that is what we're currently doing. And of course, our CP use are playing now. All alone, we get gave all those stones inside the play feuds of the game in It does know every CPO and everyone who is going to be inside to play a list and updates everything accordingly. We do not move the 1st 1 Whenever there's a capable over there, we move a random one off one off the possible kicker balls over there. We're gonna move around one same for the possibles. We're gonna do random. We pick one off the stones which are able to move. And, of course, do the perform the turn. However, we like that. So that's what the current state is as it can see the game takes quite some time to to move on, even if the CPI use are going to play alone. And that is because we put it in one or are the other yield statements about two seconds to wait before it's doing the role and the switch and so on and so forth. So if you want to have a fast up gameplay off course, make sure you increase the speed off the waiting like you can reduce away eating in between those. So in the next couple off videos, we gonna create the human inputs. We probably want to take a look pretty quick into this. So we need to have some kind of input for, like, a button where we are able to do the dice rolling on our own whenever turn is available off course. And basically we need to highlight the stones, which ill we are going to make users the selector, so at the moment or the selectors are active. But we gonna change that states or make them all in a the phone start, and then we're gonna wait for the input and perform the input based on that and of course, do the same switch or reroll depending on the six and the same. For if we don't have any six and there is a possible we're gonna still high like that. Otherwise, if none of these are working, we have no possibles and we go back and switch the player once again. All of that is going to become Ah, yeah, We're gonna work on this in the next couple of videos. So we have basically a fully running game at all, and then we can and the very, very last parts we go over and probably implement some user interface. Some, I don't know, some menus and all the other stuff we probably need before we go and play the game. So that's the current state we are at. You probably have checked out of the complete playability for all the CPI use. Maybe you have experienced one of the other CPO playing quite some long time already. Maybe we gonna put a time or in top. So we see how long a around actually takes until the first CPU or player. Whatever is able to, you know, win the game, remember, we can give it some speed ups in between, so we don't have to wait too long until, for example, the CPU has done a move. But once again, all of that is coming up in the next couple of videos. 36. #36 Re Roll when 6: Welcome back to the course in this part. I want to make sure that whenever we're rolling a six, meanwhile we are outside. We gonna have a re rule, so as we already have whenever we are leaving the base. So how can we do this? We gonna goto our stone. And as you can see, whenever we're starting a move, we take the dice number wizards, and we can easily take this also was in or incite the start co routine move, function. So what we can do is at the I numerator can basically have also any kind off argument in here. In this case, we gonna put in a Integra cold once again dies number. So what we can do with that dies number we can compare this dice number to make sure that we're switching the player of it is not a six. Otherwise, we're going to re roll the dice as we already do and move out. But in here we just put in an if statement. So if dice Number is, for example, we can say equal to sinks, or we can smaller than six, for example, smaller six, we're gonna do switch, play a statement over here. So we're gonna talk to the game manager and say, Hey, go into do switch a player. And we can also put in an else statement over there. If that is not the case, which we can also do in a kind of expression, basically doesn't really matter. We can say we're gonna take this complete port over there and set this one to rule the dice . So since that is not smaller than six, but equal, it should just fire. Okay, I gonna have to go and roll the dice. And since we're now talking to the game manager, move with the dice number, we need to make sure that whenever we're calling that functionality that we implement the dice number in here as well as an argument. No, it might need some time to check this one out. If we have, like, rolling two times or six or even, maybe more or less. We need to check this out once again. Since we are having still the update load loop over here and I'm calling the move function . From that, I want you to make sure now completely delete the update loop inside stone because we don't need this anymore. Don't forget to say so. Stone Stone Script and check out. Is there still any Eros inside the consul? Clear it. If you are unable to see something and if nothing is going to happen over there, you're good to go. And I should be able once again to check this one out, see how fast and so on and so forth. These players or these guys are going to be able to re rule, dies whenever they are sending a six, but not going. Teoh, take one outside of the base once again. This can take quite some time until you reach that point. So you probably want to implement the speed off the yes CPU in total. So they're probably moving faster, dicing, festive thinking faster, switching player faster and so on and so forth because you are absolutely able to do this 37. #37 Hopping Stones: welcome back to the course in this part. I would like to implement something where the stones are doing more like a hop movement from one piece to another piece. So currently, we're moving our stones, like, straight from one note position to the next note position. We be basically keep the same concept, but in that case, we're gonna lift the stone by code for a specific amount. We can define this to a specific amount as well as of cause how fast we want to do this week. Still keep them the speed movement possibility over here. So let's go into a stone. And currently, when we are moving once again, we're just moving our position. From our current position to the gold position was the speed. And of course, with the time to tell the time value over here, what we want to do is we want to move in some kind of an Arctic. And to do that, we need to implement Some are very Abel's which are defining this Arctic as well as doing some calculations on that. First off, I gonna put in something, maybe directly under the ah select over here, going to make a command arc movement. So we need to have a least two are very able to which are defining the arg movement. We can also put in three Doesn't really matter. The 3rd 1 would just be a speed very able. But the 1st 1 is going to be of type float and I name it amplitude. This is how high the stone is going to be. I gonna set this one at first to something like 3.5 f. So this is going to be the height off the amplitude, like in which the Arctic is going to be moveable. Also, we need to have another one which is going to be Since I cannot use time, I got my new make use off. See time. This is the time between which is going to be implemented. How fast we're moving from one point to another in real time. Basically, we're gonna talk about this a bit later on. We can set this 1 to 0 a zero f doesn't really metaphor those number and these are the boats were going to tank in inside or calculation to correctly calculate the arkus or the Ark biased movement once again, we do the same. We return a bull for that. But we do the movement different. So we don't return a straight movement like move towards a point. We need to go and do the Ark Lib movement. So in that case, we gonna name it, maybe move in arc to next note something like that. I don't know. So we're gonna move into in a are it could to the next note. And we do need to two positions or two informations about that. That furthers the first is going to be a vector three, which is going to be our start position. So where are we coming from? We need to do that when we need to implement this, because otherwise we don't know how the ark is going to be calculated next one, as we need another vector, which is going to be our goal node in this particular case or gold position. Ah, I got a name and gold position to not confused on myself and open close curly braces. So these are the most important ones. Also, we can put in a speed very able over here, so something as we have done before flowed speed. We can also once again take a fixed one and bring this one in the very top. So at the first point, we want to make sure that see, time is going to be increased by so plus equal the speed very able We are going to send in times off course time, no delta time, and to Delta time is going to increase over time, no matter what. So we increased the sea time based on the speed and the time that at the time, so the runtime or the ah, he has the current time to whatever the next time iss. So this is basically the calculation for our curve, I would say so. Um, actually, we need a indicator for for how long we need basically, from the start position t to the gold position, we take the see time as like, a step from one point to another to look up correctly between those So speaking off Europe , we need to create a new vector in this case of vector story, and we can call this one something like my position. We need to will calculate this position each step and this is going to be equal to affect the three their daughter blurb. And now we're learning between two points. So look means linear interpolation. You can also see this linearly import inter Pilates between two factors. So what we have we need to love between two points. So in this case, we're gonna start with the start position. Then we say comma and then we have our goal position. That's going to be the point where we want to go to and we want to do the blurb by flute t in this case time which is going to be our see time over here some now we can always go and read Calculate. Based on this time, whenever this is going upwards, we gonna have alert position is stored in this vector. Now what we need to do is we need to update the why. Well, you like the upper vector and buy whatever the amplitude iss and of course, times, some asthmatic calculations. So we at first go and update my position. Don't Why so the why exes. Once again, it's the up access in this case as this is off course, not working for two D If you're currently creating a duty one, so you don't need to take care of that. So my position did. Why we gonna need to update this plus equal whatever where amplitude is in this case, as you 0.5 and now we're going to implement a sine wave. So we say mass f dot sign s I am. And what we need to do is we need to clamp at first a c time between zero and one, so we can say mass f dot Klempner. And here we gonna have kal emp there. One we clamp of afloat value between zero and one. And what does the value were? Clem Ping is actually the sea time para meter. We just calculated beforehand. And then we're multiply that by pie. And now we're gonna put in mass after pie. And what you can see Noah's. This calculation is nothing else. In a circular calculation, right. And now we need to return. This position in this case is going to be our goal position. I guess so. What? We want to return now. We say return. And in this particular case, once again, it's the goal position. So gold pos is not equal to. And now we do the love between those points. So first off, we're gonna to the truths and braces or Prentice's as we already done over here. So what we need to return is, of course, transform Your position is equal to, and now we're gonna se vector the three dot love. So once again, we need to look that linear interpolated between those two points by a number, T or Time t in this particular case. So we say from our transformer position where we're currently at to our target position or in this case, gold position and then we're gonna put the time in this case, it's going to be seat time. Don't forget to end the line was a semi colon and yeah, that should work. Now what we now need to do is when we want to do this particular hope, we just instead off. Ah, you're talking to move to next note. We gonna have to go and call moving arc to next note as well as reset. See time. Meanwhile, we're moving, so let's open our move. Function in here will move i e numerator or co routine and wherever we're doing Now, this particular move we no need to implement the the note were coming from to the note where we want to go to and then we're gonna have, like, every scene. So in that case, we can also say our current node is going to be the node on the position where we came from , Basically, route position minus one or can also be the base note basically doesn't really matter. But currently we don't make use off the base note directly. So that's why we are only doing this. Meanwhile, we're going to do the direct move over here. So what we need to do is instead off creating a while loop with a move to next. They're gonna command this pretty much out over here. I'm gonna create another while loop. In this case, we say, while open, close parentheses. And then we talked to move in arc to next note. Then we need to put in to positions over here. Once again, we needed first the goal or the start position so I can create a new Vector three over here . Start position or something like that is equal to the full route in schooI briquettes. route position minus one. Since once again we have included in cream entered Rob position over here already. We can also say we can negate this one. Then we're gonna take the game Object. Don't transform daughter position. So once again, this is going to be where we are currently coming from. And the next one is going to be where we want to go to. And now we say we want to talk or go from stop position, comma, next position. And now we can also implement a speed in this case, maybe eight F, as we already did was the other ones. I forgot to close. The line was a semi colon. And meanwhile, we're doing that. Of course we need to reeled. Return? No. So instead of having the summer cooling over here, we need to put this directly inside the curly braces. So we say yield, return? No. And whenever we're done was that Of course, we go forward and wait one second and so on. And so force. So that should be it for moving, not straight, but in an arc. There's one more thing we need to do about the sea time. Whenever we're done was one step like over here. Whenever we're setting steps to be zero, we also need to set see time to be equal to zero. Just keep that in mind. This is important over here. Otherwise it just makes we it's There were things that's once more mistake I made. Of course, we don't want to go to the gold position. Whenever we are moving from one point to another, we want to make sure that we're taking my position over here. Since we're moving toe my position and the loving off my position happens between start and goal, don't forget to save, and that's check it out. First off, of course, I'm gonna start the game again. And I lifted up my amplitude just to make sure I gonna see at least any impact on that, as well as reduced the speed to one. So whenever somebody is starting to move and has at least a six and another number, we should see some rez. A high jumps between those two notes wherever they are starting to walk on. So yellow came out and now I see he's doing rather high jumps. This is happening because I once again increase the amplitude to 0.5. This was just for testing purposes. You should be still at 0.5 and you should see that the interpolation works quite nice. That's everything you need to do to move in an arg by hopping between one point and the next point. Once again, you can keep on a storing saving. And of course, it can keep on testing how you want to hold high. You want to have this particular Yeah, amplitude. Once again, the amplitude is like half a meter high. Since my fields I one meter by one meter, the stones are going to hope, like half a meter high and then go downwards once again in some kind of a sine wave Moved mint once again based on the amplitude. If you want to have a smaller of higher amplitude, you're absolutely able to set this one on hand directly on the stone, and every other stone is going to make use of it. This is also by the way, whenever we are kicking somebody out, he's going to go back and, like hoping half a meter high with the same amplitude and moving between those two points when wherever he came from, I can see he is doing the movement Raza slow. So in my case, once again, since I reduced this one back to one Ah, whenever I'm calling moving arc to the next note, I gotta bring this one back to eight. That should give us a raise. A fluid movement right now with the same speed as is basically moving out. If it this once again too fast in case of moving like when it is hoping to quick and then you can once again go over and reduce the number from age to whatever the number issue like . So in that case, it can be something like four was six whatever or even common numbers shouldn't be any problem at all since we have some type off float which we can actually make use of. So I'm gonna wait just a second more to see at least one guy hit hoping around over here, whenever some players doing actually rolling a sex and once that is going to be done, we can see what's going on and how the hope is actually looking as well as how fast speeds going to be, and now he's going to start. Raza Quick H seems to be quite high, but the hoping looks prairie nice. The speed to before. Don't forget to safe and let's go continue in the next video. 38. #38 Hopping from and to BaseNode: Welcome back to the course in this part. I want to show you how you can also implement the movement arc from the base note to this. And as you actually assumed, the bass note has its own position, Of course. So we just need to make sure that we're changing this speed as well as the arc to move from whatever the next position is. So whenever you're opening your stone script, you can see and move out. You can basically do the same as we have done all over the place over here in ah, the normal movement over there. So basically, what we did is we just call moving arc. And we just created to start position as an extra. In this case, the royal position minus one. Since we implemented this or in cream meant it this before we're doing the next step. What we can do now is inside the move out. I enumerated where we're moving out. We, of course, can give some space over there. We're gonna deep or commend out the first, why Look, we have created and now we can basically define another vector three, which is going to be once again. I will start position. Well, we are coming from In this case, it's going to be our base note a door to game object door to transform your position. As I already explained before, I guess kind off. And now we just call the Wild Loop. And of course we want to do is we want to move in an arc to note or to the next note. In that case, we gonna once again going to take the start note as the or the start position, which is going to be the base note position. And of course, the goal node is going to be the next position over here. And then we once again can give it a speed off five F. And of course, whenever what? Meanwhile, we're doing that we gonna yield return? No, as we did before as well. And so now we're able to do the same movement of the dam. Also, once again we had done was that. And after probably the yield return, wait for second new Ah, 0.1. We want to make sure that we're resetting seat time to be equal to zero. Otherwise, once again, we have some strange behavior over there. And now we can basically take all of these movements and make use of them once again. Don't forget to move or Dick Amore commend out the while loop by while we are moving the normal one. Because otherwise, once again, strange behaviors are going to happen. Trust me. So that's everything we need to do to basically make the same movement or the same movement . Found tonality whenever we're moving out. So we do a hop over here to our next one. I got tried. Teoh, make this one visible. As you have seen, this guy was hoping, like out off the basis. Well, and now he's moving in, hoping steps as he should. Same for the green guy. He just hoped out usually or as usual as he has to do so. And now we have all these stones hopping around between those yeah, positions, actually, based on once again the speed and the sea time, which is going to lift it up over the amplitude 39. #39 Check for Win: welcome back to the course in this part. I want to make sure that we are able to see if somebody has one or not. And so we need to actually update the gay manager off each particular player if he has one or not. And based on that is going to be, you know, overseen or actually over hope. As you probably remember, we were actually checking this. Meanwhile, we are switching the acts of player. So if we don't have one, of course we're gonna have another available over there. So this is going to help. I will play a manager or a game manager Teoh set up up correctly. So how do we check this? Of course. Our stones. Every time they do a move or they're done with the move, they need to report if they have actually won or not like if all our year stones or in this case, the complete final route is going to be completely fulfilled with stones. So once again, how we do we do this, we gonna create a little help of function for this, of course, once again, to keep everything or raise organized and what we're gonna do? Is we just check if we have one or not. And returnable in this particular case, so what this is going to do? It's just returning to or folds if we have one or not. And then, of course, giving us the correct result and we can return the correct answer. Basically, to that I create a ball function over here, which I name win condition. So once again, the wind condition in my case probably yours is different later on is going to return of all final road pieces are going to be taken. And how do we do this? Of course we looked through them and check that out. So we're gonna create a four loops once again, type for TEP twice. And then if I find a route dot tight note list and that counter we gonna go through the complete final round tighten or less than four in total inside, you probably know that already and when we want to check us if not the finer route dot child node list in square brackets Isa were looping through the complete child note list off the final route. Then we gonna get the component off type note. So don't get component, since this is going to be off type transform as you can see over here, whenever I hope have over, you need to make sure that you get the component off type note over there on this particular part. Often close parentheses dot And now we need to request if that is going to be taken. And once again we need gate this If that is not taken, If any of these is not taken, then we return false. And of course, what we can now do is whenever we are basically nothing found or whenever that is going to be true, basically or at least one off that is going to or all of these are basically reporting that we're returning force in that case because at least one off them is not taken in this case . We gonna return true at the very end over here. So we make sure that the bull is actually at the very end whenever the four loop has not found any matter, actually has not breaking out of that because it already has not found being a taken one. Then we're going to return true meaning all of them have been taken at this particular point and we can take this as an argument or as an indicator, or no need to do is, of course, meanwhile or after we're done with our move, like before or meanwhile, were reporting to the game manager and probably before we're doing the switch state over there. We want to update this one here as well. So we gonna put in a win condition check over here. So before we actually update this one, no matter what this has been happening, whatever number is going to be once again, the switch statement is taking care off. If somebody has one or not, just in that particular moment, it is updated. So what we now need to do is of course, we need to call the function wind or the bull win conditions. So if wind condition, actually, if that returns true once again, all of them have been taken. Then we want to report of the game images so we can say gay manager dot instance. And now we want to report it to it like update that, But since we don't have a report function for that, we want to make sure that we're creating this from pretty quick inside the game manager. I gonna go resident over here, and it's going to be a public once again. Avoid. And we want to have something like report winning, close parentheses and what we can do is just update the playlist Active players. So playlist in square brackets, active player on when we need to do is of course, we need to say it don't has one is equal to true. So we just set this one here to be true because this is the way we're reporting that. And so we cannot to take this X this actual ah, player to be the next act stiff one. And we can say eso some You. Why something like that? So some you are whatever you please and like once again, there are hundreds of possibilities. You can even play firework off particles and so on. And so force for this particular first player. Or actually, this is going to happen for all other players as well. So basically doesn't really matter. And once again in stone, we now just need to call the report function. So don't report winning open close parentheses and, of course, close the line was a semi colon. Now, once again, you have some time to test this one out. And once. Whenever this is going, Teoh, do the wind condition check. It's going to return true once again whenever all the final new route notes are going to be taken. We returned through and then we know Okay, this particular player is done. He's in the goal. Was all four? Yes. Don't in this case and that pretty much everything you need to do over there. Now you can go back to unity. You check if the compilers, any problems as well as any errors are going to be in the console as always and usual. And when they are clearing this and nothing reticent site you absolutely good to go to keep on and go forward. 40. #40 Human Input 1 Dice Button & Statemaschine: welcome back to the course in this part. We want to start to create all the inputs for the human. So whenever we have a human player and we set it up so late on from a menu, for example, when one of these people or one off these year players are going to be human, then we want to make sure that we have our own input for this particular player, which is going to be the playable human meaning We need some kind of input possibility for rolling a dice. We gonna have several possibilities for that. Of course. Depending on once again, how are we going to do this? So for us, I gonna or for this particular moment we got creates just a little button which is calling the function to rule the dies. And then we're going to do all this information about the humans. What we need for that is that first, of course, a button which is going to be ruled as well, a several functionalities as well as a different state machine just for human inputs, because these are going to be, let's say, a bit different over there. So what? We want to do is we want to open up our game manager first, and we gonna go where we probably where you have probably already commanded out human inputs of there. So we got I had a commander V that we're going to need a game object for our button so we can literally create this one already. Just name it to public game object. And now again, name it whatever role button or dies button. Whatever you please like once again, this is just so we have a possibility to trigger rolling the dice. There are hundreds of possibilities again to do this also, I want to have something like a ruled human dies over here. Already created this one in one of the last videos which is just of type into jam. We can make this one public. If we need Teoh. Probably. We're gonna change that. They don't and hide it in the inspector, they are once again, it depends on where we're going to go. So next one is inside. Update week currently requests if our player is going to be a CPU type, but we don't request if our players going to be a human type. And according to that, once again, we gonna need to have a different state machine. And I go through that pretty quick. What you want to do is probably go and take the complete statement and copy that and go some lines deeper and paste it in here. So I'm gonna shrink this together because we keep the CPU type. But what we want to have and here is, of course, a human input type. And what we're going to do is here. We gonna do several different things. First off, we probably need to take care off. That turn possible is going to stay as is. But we do not take rolled eyes. DeLay in this consideration over here, we're gonna need to instead of going Teoh. Yes. Start the score routine over here. We need to activate our button. So the button we are going to be over are going to have over here. We're gonna create the small helper for that are gonna go down quite a bit. And at the very end, I'm gonna make a to a slash is that it can actually take some minor symbols and maybe put something like human input just for me as an indicator that everything which is coming after this particular point, there's going to be only stuff for human input. If you don't like this way, you can also create a region. So regions are basically just called as you can see hashtag region and he can give it a name, human input or whatever you like and off course there's another one. It's called end region that so this one. So everything between here inside this region can also be clamped together. When you do that, you can see that there's going to be that small human name over there. So once again, if I put year a human input or whatever name, I like to end calamitous together. You can see inside this region only human input is going to happen. So it is up to you what you want you to do or how you want to do it. You can just make something like that. Just paint over the complete one, and you're gonna notice. Okay, this is commanded out that there's going to be human input or you're gonna stick to regions . Regions can sometimes be but picky, so probably want toe white that at the very beginning, But later on, you can absolutely go with regions no matter what. So what we need to do is we need to activate our buttons. So and as I said, we're gonna create just a little help a function for that which is off type buoyant, and they're gonna name this active a two button. It's just easier to set this one. We can also put in the bull to be true or false. So later on weekend, just easier access this particular button. So this is going to be a bull, and we probably name it, I don't know, on and inaugurals, Prentice's or Coley braces Over here, we just put in a stuff like Rule button don't set active and whatever we want to set active isn't going to be. This type is going to be whatever on ISS. So on this true off cause the robot in is true of it is force. Of course, a robot in selective is going to be set to false. So what we can do is that is actually recall this one over here. So activate button. And then we say we want to see this. So we want to have a true one whenever we are able to rule a dice. So whenever our turn is possible and we are able to roll the dice, then we want to go and act Activate this particular button so the human can do it in an act of click onto this button. Okay, So what we also want to do is we probably want to deactivate any kind of highlights which we might not to do at the moment. But I gonna make a command. So it's called De Activate highlights. Ah, once again, it might change in later on. So we gonna later on highlight specific units which we were probably able to activate or deactivate. Maybe we're gonna do this. Deactivating highlights whenever we had done was discerned two the turn. So and what we also want to do is this once again keeps the idol state Nothing fancy to this. But what we want to keep here is off course. We want to keep on ah, going with the start. Cortines, which player? But also we want to make sure I'm probably It's too late at this point. But maybe we need to deactivate the button eso and the activate button. And probably also we gonna deactivate the highlights as we already commenced out of here. So there are hundreds off possibilities where we can put these. Maybe we're gonna do this whenever we oppressing onto the activated. Pardon. So these become obsolete at this Points. So just so you know, we need to do stuff like that sooner or later, no matter what. And that's everything we need for being a human input state machine. We need to activate the button. And now we can start to ah conficker or set all the possible Turin's as well as we can a deactivate the selector and start as well as activate or deactivate in Start over here, which is off type point once again, if you have that function still, yeah, make use of it in here. We can just say roll button dot Said active to be false or we gonna make use off our factory created activate button open close parentheses, falls. So we deactivate this button on start. So no human in port is going to happen as long as it is not ableto do us through the rule die state over here. So once again, keep or create of this avoid start activate button fools and then you're good to go. Don't forget to safe. And now we can go pretty quick and create that button. What we need to do for that is rather simple as well. We just go and a right click inside the hierarchy window. We should know, not have any problems in here in like any typos or such. The consul's should be empty. We're going to create a new you, my button over here. And whenever we're doing that, the button is going to be somewhere created. We have basically no, really? Yeah, impact to this. So what we need to do is of course, we're gonna bring This may be somewhere in the centre at the very first, so we can see this better. What we need to do is the canvas needs to be said pretty quick in the canvas scaler from constant pixel size to scale with screen size. Otherwise, you may have problems and wrong positions later on as well. Now we can take this button. We can rename it to roll dice, but and we don't go and cover anything at the moment. But that button And you can also tent this one to green, yellow, blue, whatever you please like like push this button. I gonna put a name over here like or actually attacks, which is called Rule Die Ease. Where's an exclamation mark? Maybe. And also, I might go into Ah, best fit. Bring this like, two completely. Don't over there and maybe I gonna make it Bolt. So it's absolutely good to see over there in to demote whenever you're going to select the studio. But you can also set this one being anchored over here. Teoh, when you hold on old key, the bottom right for me. I gonna try that actually out. And but you don't want to do this on the text. You want to do this on the rule dice button. So once again, go a select roll dice button. Go to Angers. Hold down old and snap this one in the bottom right corner. Once again, you can also put this over here or wherever you like. We just want to make sure that we have the possibility to roll the dice from any point in the game. if you don't like the size of it, of course. Feel free to read. Yeah, re arrange that. And you can also set the tax to be reparable. So it's probably going to be like one line under the other. Or if you go now, just, you know, hit the enter button over here all up to you once again, however you like and police. This is no problem at all. Now one last thing in the game Manager. You want to make sure that the Rule button game object is going to sit inside the game manager In this case, we just take this roll dice button and directors over here in the Rule button slot. In the next part, we go and continue. 41. #41 Human Inout 2 Selector Management: welcome back to the course in this part. We want to make sure that we are deactivating all the selectors own Start which are going to be this little row taters and on the bottom as villas puts on functionality to deactivate them or completely inside the game in just well, since whenever we're done was human inputs. We need to deactivate all the stones from that particular yeah, human player. But the only thing is what the only way to do it is from the game energy because he's the only one who knows how many or which are the stones. We cannot do this directly in the stone because we don't know who the other stones off this particular color is going to be. So that's Ah, part which we need to do directly inside the game energy. So let's open this one up. But start with the Stones group for us, open your stone script up for us, and in start, we want to make sure that we are deactivating the selector like just we deactivate this by using set active. But since we also need to have access from outside later on, we're gonna create a little help of function for that as well, If you like to, you can also do something like a double slash and comments stuff out of a here, like once again for human input or human stuff, whatever. Because everything over here is going to be on. Lee poured off that will as well. So I'm gonna make something like this is well, you can also once again use the region if you like to us. I explained in the last video all up to you what we want to create is it for us a public function which we can access from outside later on as well, Like from the game manager. Antolin name it set selector So and we need an indicator Or actually we need an argument for this off type bull and it's going to be something like active or once again on s well as we already used and the other one so we can use something like that. So if that is going to be on off course, everything we want to do is going to be on a swell. So I gonna talk to the select the game, object directly so I can say selector don't a selective basically as we did with the button before, in the last video as well. We want to make sure that we set this one to be active or to whatever on ISS. And ah, same here. We're gonna have the attribute or the bull called Has turn we wanted to sent has turned to be equal toe on as well has turn is going to be used later on to unable functionality like when we are having the possibility to collect on to one of these selectors or actually on one of thes yes stones that we need to make sure that has on is true. So this is four like Hess turn is for having the click ability, I would say I don't know how would you explain this better? What we go through that. So whenever it's stone this later on, like highlighted, we again we gonna set this one as has turned to be equal toe on. So we and we know or actually we can say this particular storm, which only has has on on it, is the only way Teoh be selected from us by human input. Once again, we're gonna go over that a bit later on. Once again, I commend this one out. Over here it is for human input. It's a bull. Head off ahead, Stern. If you don't have a police, make sure that you add it now. So now we have Don't was setting the selector, actually. And what we can do is in start of course we can deactivate any Select that we have. So in that case, we call set selector, open close parentheses and now we're gonna give it a false So on start, Whenever the game starts, every stone no de activates its selective. Let's test it out. So don't forget to save everything. Of course, whenever we are starting our game now, we should see no active selector. As you can see, you can also check this directly by clicking on any of thes stones and see this selector. Here's no great out. You can also see over here it is not enabled at this point. So this is important for us because once again, we want to make sure that we only highlight away human Yeah, Stones Was this elector whenever the input is possible? Okay, so now we have all the selectors instrument to set to be false. Now we want to go to the game manager and create a function to deactivate all select Chris . This is also part of human input. That's why we are going to create this function over here as well. So it's called on once against off type point and we're gonna name it may be a deactivate sit electorates or highlights. You can once again named whatever you like deactivate selectors and open close parentheses . We don't need to put in any arguments over here. When we know want to do is we want to loops row at first active player list or at the actual playlists. And then, of course, make sure that we deactivate like every possible stone. So we need to do it a nested for loops in. I like one follow up inside another follow up. I'm gonna explain that. So first we create a for loop where we airport going through our complete playlist cell playlists, adult count In this particular case. So how many off war all this players are going to be inside? All of them will be looped through and the next one is we need now loops through all the stones, like the stoners, per selector or per player. But to do that, we need to create a nested for loops. So we type for again Tep twice again. And of course, this is going to be a This interview is going to be called J instead of I end. When we're looking through is the playlist in square brackets And now we're gonna take I s an indicator So they've won for the first loop over here. So we know. Well, now we know Ah, that we're going through one off each player separate Lee And then we say, of course dot my stone startling. So we go through every player and through every possible stone, and then we are able to de activate those and always say playlists inscribe Ricketts. I don't know. We want to talk to my stones in square brackets J. And finally, we're gonna say set selector. And then we set this one to be call to False. So what do we do? We look through every possible stone in every possible playlist or player and basically sort through all four players and deactivate them all completely no matter what or which one is currently active. We can also give the possibility to only do this when ever one specific active character has bean. But we need to select or make sure that we are protecting it to not overflow, which might be not a good idea at this point. So once again, we deactivate all selectors and which are in the game completely. So I gonna rename it to deactivate all selectors. Don't forget to say if we gonna make use off the activate all selectors a bit later on, whenever a turn is over and once again in human input has been done on once again. This is part off one of the next videos. 42. #42 Human Input Roll Dice 1: welcome back to the course in this part. We want to continue with the human input. So what does it mean is we want to make sure that every that we know which human is on which Stone is actually being able to be moved. And since we have created such a functional ready for the CPU, we basically just copy and paste stuff all over the place. But beforehand we want to make sure that our game Energon knows that at least one off these players, probably we're gonna take the red one because he's in the first or in the first reappoint or first position here, I gonna change this guy to be a CPU player. So we gonna have it easier now to d back whenever we gonna go through and do something that we know. Okay, We're gonna have to stop at this particular point and see once going to happen. For example, when we don't have this one s CPO, the rule dies. Button will never activate, so we don't have any possibility to press on this particular button. But now, when we are changing this guy to be human and press play, we should have a rule button, and you know, we should be able to click on this as well, just with the mouse. So what? We now conduce? We can connect the function to this particular button to roll the dice, check who we can move and then to perform the move according to the input off the player. So for that, once again, we need to go and create some functions inside the game. Indigent. It's going to be one big function, I guess, because all of that is going to be checked from top to the bottom. We can split it apart and, like for human input and so on gold roll the dice extra and so on. But it actually doesn't really. It's not necessary at this point. This function once again, we are in the game in a jet this factions of type white, and it doesn't return anything, but we need to make sure it is public, so we can click on the button and call this particular one from the from the roll dice button. So I gonna name it may be a human roll dice. There's going to be the function name we don't need to do any input of a here or any argument because it is doesn't it doesn't matter. Once again, you can make a comment over here. This sits on the roll, dies a button. So we need to call this particular roll dice or human role dies function later on from the but in itself. So what we now need to do so, of course we need to roll the dice. But before we do that, we want to make sure that we deactivate the button, which will have pressed So activate button open close parentheses, falls. So it is important that we do this because otherwise we're probably the possibility to hit it like super fast. What we now can do, it's once again don't forget to save as much as you can. What we now do is of course, first we roll the dice. Once again, we have this role, dies by human or something called rolled human dies. And we want to set this one to be equal to once again random dot range and up close parentheses. We're gonna put a one comer seven, as we have done before already. Once again, ruled human dies. Is an integer which we need. Teoh actually take care of what has been ruled. So we can later on, for example, directly requested on the game miniter if we want to. But I guess we don't have to Will. Not directly, maybe we're gonna see that. So what we also want to create is a that move a Bill stone list, like once again, the same stuff as we have done before with the CPO. What you can do if you have been lazy and sometimes I'm lazy as well. We can copy and paste some of these informations around from one side to the other. So in this case, we go to our move, a stone function. And what we do is we gonna dual the fill this stuff over here already. I got a copy it, including the two lists. You can also only take one of these lists. Basically, doesn't matter. I'm gonna close it so we can actually see stuff better. And what I want to do is I want to get rid of the move kick stones because for human, it doesn't really matter if you want to kick it or not. In this case, it is important that wherever this one particular list where all this possibilities are going to be end, since we want to activate all possible even. And no matter if clickable or not all possible movable stones. So all stones we want to do so What we're gonna do is where all this red stuff is going to be, like dice number here, in here. And, of course, move. Kick stones is not yeah, accessible for us. We want to copy Movable Stone's name. Double click on the one which is going to re read and add the currently found stone by not the dice number brought by the human rule dies or ruled human dice. Numbers are gonna put this over here DoubleClick once again on the red ones and just paste it and was control V. So we're gonna take both at the same time, like for the possible Kika bols as well as the possible movable walls. So in the next port, we want to make sure that we are highlighting all the possible stones based on whatever has been rolled. And yeah, it's doing this in the next port 43. #43 Human Input Roll Dice 2: welcome back to the course in this part. We want to make sure that we attacking what has been rolled as well as if the base node is going to be full or not. So once again, basically, we going to do the same as we have done on the CPU side. So probably we gonna copy and paste some stuff all around. And also, we need to make sure that we are having, like, streets specific our requests over here open up your game and a descript and go into the human role dysfunction after we had done was filling the list, We want to make sure that we're going to check all the possible rules. So after we have rolled the dice, we want to make sure that I gonna make some commands over here pretty quick. The number is probably the number. Wave rolled is basically smaller than six. Then we want Ah, no, If we have completely ruled a sex like end, the start note is basically not fall. So number IHS equal six end start note. Start note is not full. So once again, we're gonna do this, Jack beforehand. So over here, we're gonna do the start. You know, full Jack. So and the last one is going to be if we have not ruled the six. Or in this case, if the start note is going to be false, So basically the same stuff of here. But at the start, Nell's note, it's full. We gonna need to get a several different results on that. That's probably another one we're gonna make Use off later on. But at the moment, we gonna start with all off that. Let's do the start. No check. Once again, we can copy this one from the tech start node function over here. We can basically copy this complete part at first. So we have done over here. We found something off course we're gonna later on. Chek forced Arnold four. Let me give. Let me take the 1st 4 loop of including the bull start note for again. We go into the game engine residue down over here. We're going to do the start. No check first. So whatever is going to be the one where we're currently on and off course what? The active player is going to be returns for true or force According you know to that. So if we break out of that, we know that at least one is going to be on the start note, and we can go forward and check against the start note, as we have done before. So first off, let's check if we have rolled in No. Six, but another one in this case, we just want to make sure that we're checking against it at the very beginning. So it rolled. Human dies. Is that a smaller than six? We want to do something. What we want to do is of course, we want to look through all our possible stones for except in this particular case and see who is out at first. So four. I'm gonna take I as an indicator or index over here. We're gonna loop through all playlist ins. Grab Ricketts Active player. Of course. Don't my stones dot links. So once again, we looked through all the human player stones at the very beginning. And now what we want to check is if if this particular one we are currently going through makes we want to make sure that he's out. So gonna make a command of here, make sure he is out already. So that's what we want to check it for. So if playlist into grab rockets once again Active player, don't. My stones in square brackets I don't return is out. We want to make sure that we know if this particular stone is going to be out already. And if that is the case, only then we want to add up to the movable stones list over here based on that and then later on, once again we go and highlight these particular stones. But we need to make sure that the ones we're looping through are actually able to leave the base. So what we want to do is here. We want to start another. If junk self first we want to tank. If playlist in square brackets Active player, don't my stones. Then once again in square brackets ID So the one we're still currently looping through don't and now we want to check for a possible kick move. So we want to check for possible kick at first, as we already did once again. And where's the CPU before as well. What we want to put in is the stone I d So our current stone ideas in this particular case playlist in square brick kids Active player. Don't. My stones don't in square brackets, I don't. And here should we have the stone I d. And also we want Teoh check against the rolled dice number. In this one case, it's going to be the ruled Human dies over here, so we want to check that at the very beginning. And depending on that, of course, whatever is returning in this case, if that returns a true there is some possible kick in this particular case. We want to add this one what it would have us matching this one to be inside the movable stone list. So we say movable Stone's daughter at open close parentheses. And now we put in whatever the current stoners were. Look things through. In this case, it's once again playlist in square brackets, active player dot my stones in square rickets. I So this is the stone we want to add whenever this particular stone has the possibility to kick somebody out off the playfield once again, we want to make sure that we continue at this point and we don't go over and at the other one, which is just going to check for the possible move without being a kick. Herbal Stone. We're gonna do this. Still this check over here. So once again, we go through that we are checking, not for possible kick, but for we want to check for possible move based on the rolled human dies number over here . So human role dies. We continue over here so we don't go through that part as well. Whenever we have found one of these and we can take away the continue over there. So once again and here we check for possible move, he would check for check possible kick. And here, once again, only the currently roll dice number. Same here. We're gonna check for that as well as the current stone. I d off this particular point or this particular yeah player. So and this is happening whenever we're not ruling the sex, so we make sure he's out already. So return us out, then we check once again for being possible to kick. Or is that it's not the case for possible move. And if none of these is going to match or whatever, then we gonna whatever is matching in this case lands into the movable Stones list for the human input. Now, since we're done was that we also need to check if the number is going to be six as well as not on start note or even on start note. But that's what we're going to dio in the next video. Don't forget to safe and see we see us in the next video. 44. #44 Human Input Roll Dice 3: welcome back to the course in this part. We want to continue with the human input like whenever we have rolled a six. But nobody is on the on the start note. And also once again on the other side. If somebody is going to be on the start note, let's dive into it and open up the game images script. Make sure you're gonna go into the human rule dysfunction, that which probably is going to be at the very bottom over here. Also, I have done the in the last video some of this notes. So probably we're gonna create all the functionality directly over here. Is it? We were gonna do the same stuff as we have done before, like over here once again. Also, we can maybe go and bring all of this possible tanks of their into an extra function since we're gonna go into that repeatedly and check for possible inputs. So once again, what we need to do is we need to do another If check over there, meaning if we have rolled a human or if our ruled dies number the ruled human dies. Number is going to be equal to six which is going to make sure that we are able to move out and the start note is not fall so and not to start note full so that both is going to happen. We need to do once again the same check as, well, a see if somebody has been or is out already or not. So basically, we're gonna do the same functionality like as I explained before, over here. And if somebody is going to be outside, we want to bring them or bring him inside the movable functionality list. But also, we need to have one other function which is going to tank. If one is not returned or is not returning, here's out. Meaning we need to make sure that he's inside the base. So we need an inside based bank are gonna make it here. I like a command inside to bass check. So if a least one is inside the base, so we're gonna look through that pretty quick and here we gonna implement once again the playlist in square brackets, active player. And afterwards we just say, I don't my stones dot length as usual, the ones we are just looping through the wall time. What we now want to tank is basically we can take this. Um, if statement over here and just reverted Meaning if playlist active stone my stones I dont return out. And what would we want to do is I want to say it is not outside off the base. Then we want to get the players a possibility to palay this one. And of course, put this into the movable stone list. So movable stones dot ad And what do we want to add is, of course, the currently looked through player in this case playlist in square brackets act the flare Don't my stones in square brackets I So once again, we do the same stuff all over the place. And don't forget to enter line was a semicolon. Now, once again, we need to do the outside shank. So this is basically the second part over here outside check. And this once again, this outside check is basically nothing else. The this one. This is also Justin outside check because we have rolled another number about the sex. So now we could try to take this complete part and bring this into another or an extra function. I gotta create this over a year and see what's going on for herself. Are gonna need to return a stone or basically a list of stones and bring this back into my movable stones that are yeah, into my movable stones. So this is going to be off timeless. The type should be stone. And we need Teoh. Give it a name, something like possible stones or something like that. And we need to put an argument over here, which is going to be again the dice number. So from that now, we can actually call the outside check from the possible or else just a function and return a list later on. So in this particular case, we need to create a temporary list so we can say its of type list, off type stone. So we create basically a new, completely new list Over here, you give it a name, temp list, something like that. It's equal to new list off type stone, open, close parentheses enclosed. The line was a semicolon, and at the very end, we want to return the temp list because this is going to be the one we want Teoh make use off now, since we once again return or want to create a list outside of that. But we basically dual the looping like the complete fall up of a hand. Flush the data a bit different. We can't actually do this. So I got a copy. This part over here from the rules smaller than six. The complete four loop over there and basically paces over here. What you will notice is, of course, movable stones is at the moment not inside support the functionality. In this case, we're gonna take Temple ist and put this over here and over here. So now we're gonna add all of these inside over here, like the complete list of types. Stones once again create a new list. We looked through everything and check for all the possible kicks and all the other stuff and add bank everything inside the temp list. Now, we just need to make sure that we return the temple is and bring this Tampa list inside all everything we have inside the Tampa list. I need to bring this one back into our movable stones list over here. So what I going to do is that gonna command this one out? Very quick over here and talking of the complete line command. You can do this blank two ways, as you probably already know. Like with slashes. Or you do as I did was right. Click talk, lang Comment. Or you can also use ah slash Asterix and down Asterix slash And everything in between over here will be automatically. Yeah, commanded out as well. So two possibilities for that. So now what we want to do is we want to take movable. We're gonna go and add range. And what do we want to add? The range into, like, this is going to be a collection off. Different yet types off stones is going to be returned by possible stones in square and then in ah, open close parentheses. And now we need to put in the world ice number. So probably we don't even need to put this one here because it is public already. So I gonna take away this argument because we don't need this. And now we should be able to get the movable stones over here inside that don't forget to make sure this is open close parentheses. Close the line once again was a semi colon. And now we can check if we do or if we are able to do the outside check. Also just from that particular yeah list which we created, like outside of this function, based once again on the Hugh ruled human dice in here and just call or add all of them with one line of code. But we can re make reuse off this complete part of here. I'm going to say that and see if the compiler has any problems. Was that And once he has no problems was that we can go and continue. And as you can see, no problem was that the factions should work horrendously and it is returning everything from the Tampa list, which we have actually filled in over here. And this is basically simplifying overcoat and reducing the length off the complete functionality. And since we do the complete list track of a day over here in the top us well, like wherever, we're going to fill the list once again based on moveable stones over here, continue and all that stuff, and also we're going to check if they are at least out. We can get rid of that one over here completely. So once again, we create the list of stones or movable stones over here. We gonna check against the roll dice of whatever the number is. Whatever it is, we gonna request this one from the possible stones list which we have created over here. Then we do the tax, um, outside, over here as well. So whenever we are not inside the base or whatever is in the base is going to be added as well as everything which is outside. And and now we have the final one, which is basically the same functionality once again. And in that case, we just create an else. If statement over here and we say the rolled human dies off the rule, human dies is equal to six as well. So basically, we're gonna do this one over here like, but it is important that it isn't else of statement. So world dies, is equal to six, and start note is full. So the study is falling. We are unable to go like outside off that I like outside of the base. Then we just do the movable add range possible check over here. This one. So this simplifies to complete process. This simplifies like the complete functionality in sight. And then the next part, we can activate all the possible move or all the selectors from the stones which we were, would be able to move. Don't forget to save. And, of course, don't forget to save your project and see if you have any problems inside the game manager . And if you don't have them off course for free to go on. 45. #45 Human Input Roll Dice 4: Welcome back to the course in this part. We want to activate the selectors off all possible stones now. So whenever we have human input, in that case, of course, we're gonna go and open up our game manager. We simply find, like everything was this possible stone list. But at the very end of the complete function, whenever we are like rolling the dice checking of the start notice full and a sea, whatever the number is, we have rolled over here. And of course, we moved down and down and down and down. And at the very end, we want to earn able all off the possible son actors. In this case, we can just go and loops row the complete movable stone nest. So I'm gonna do a command over here, activate all possible selectors. And how do we do this? Once again, we just looked through it. So four int I equals zero And why I a smaller than movable stones don't count. We can increment. I, of course, and meanwhile were looping through all possible movable stones. We need to make sure before we go into this, wanted to make sure that the movable stone list is bigger than zero. So we say if movable stones dot count is bigger than zero Onley, then we need to go into the four loop. Otherwise it doesn't make sense. And in that case, we're gonna take that and bring this into this if statement. And now we can just talk to every each and every stone inside the movable stones, less a movable stones, inscribe rickets. I don't set selector. And now we can set the selector to be true because we are activating this particular yeah, one which is going to be inside this particular movable stones list. Of course, if that is not the case, like if we have no movable style or stones over there, we want to go and switch the player. This is important. Otherwise we're going to be stuck on the human input. So we said else state is equal to states gold switch player. Don't forget the and the line was a semicolon and yeah, check it out. So once again, we are going to be the red player at the moment later on. It doesn't really matter for all of these because yeah, you know, no problems at all We need to go to our canvas now, wherever our button is going to be located on, and what we need to do is we need to make sure that the UN collect event off the rule dies . Button is talking to the game manager role, human rule dice. In that case, we go once again to the Roll dice button open or go to the on click event and press on the plus. Now we drank our game manager into this opened of no functionality and go to the game and the descript and see where you locate human roll dice. So whenever we're pressing on that, we gonna make sure that we're rolling the dice. Also, whenever we're going to switch the state like whenever we have done over here, we probably want to go and deactivate all the selectors because we have done already. Also, whenever we probably have done an input, we want to talk to deactivate all selectors, like whenever we have clicked on that. So, once again, this is something we need to figure out together. Like once again, whenever we're switching the player, we probably don't have any active, you know, stones, but whenever we had one. We need to make sure that with DX, the vein, all of these. So once again, if everything is connected, like the bull rule button die or roll dice but to the game in it. Don't forget to save the scene as well. By Control. Asked for a quick for quick, safe and let's see was going on over here. I got a press play. I know I have the first turn and I should be able to press this button. It should deactivate itself. And in the next turn, the greed players should be. And then whenever the grim player of course is done, then we gonna have the, um, the yellow one than the blue one. And after that, we have the next turn, and now you can see I rolled a six and I can now select any of these stones and I should be able to do any input. And meanwhile, that is the case we gonna wait for once again the human input, and then we gonna go forward, or we should go forward according to the input we had before, and then make sure the next player is going to happen or we gonna do reroll according to that. What? We're gonna take care of that in the next video? 46. #46 Human Input Move Stones: welcome back to the course in this part. We want to make sure that whenever we rule the six that we are able to select one of these stones, click on them and they're gonna perform the act sensation. They should dio. First off, we go to our stone script since we need to activate some in this case, wherever our human input port is going to be under the sect selector, I gonna create a new function. This function needs to be written 100% this important. Take care. Now this function is called on mows down and open close parentheses. This function is always cold whenever whatever the object is in this case, the three D object is we're clicking on ended reacts can react to it. But we want to make sure that we are making use off heads turn. And of course, if it is out or not, and depending on whatever the input is, we gonna do, call the correct functions we have created in here already. Like whenever we roll a six that were actually able to leave the base off course only when it has a turn. Since we are setting that has turn based on the selector. So what we want to do is at first if has turn, it's true. So if estern so once again it is an active selector. It Owen active selected player Stone from the game and it just elected and said it active in here. We know that this particular one should have a turnover here. So if that is the case, only then we are able to perform on most down function over here. First off, what we want to do is we want toe check if we are out or not. So if not is out, then we want to leave the base so can say over here, leave the base open close parentheses close The line was a semi colon. Once again, leaving the base is basically nothing else than yeah, of course going out because we had a six in this case, if that is not the case, So if our stone or the one we are currently clicking on is already out, we want to start the move. So we say, start the move, open close parentheses And now we don't know what the actual number we have ruled over here and what we can do is, since we have no dice number available here there, we need to talk to the game image and get this information. In that case, we go to the game image and the very top wherever our human ruled or rolled human dies in Tages. In that case, we're gonna make this from public, but who also at the same time, I want to make sure that we're hiding this one in the inspector. So we put in square brackets, hide an inspector so we don't see this. And we are actually not doing any mistakes by that particular one. We can go. Don't forget to save the game in a Dan, go back to Stone. And now we can talk to game in a job door. Instance Don't rolled, Human dies. This is the number we have rolled the last turn. And now we can do the movement based on the rolled human dies number whenever we click on it when we are done with that stuff over here. Like with all the performance, I believe the best way is to set all selectors inside the gay manager to be equal to know or in this case, deactivate them completely whenever they're done. Was that in that case, we once again go to the game manager, roll down until we go into the human input part and probably deactivate all selectors is going to be a public one, so we can call this from outside as well. So again, going back to the Stone and whenever once again we had done was determined. So if it has to turn, it performs all of that and or actually starts with that. And now we want to talk to the game manager and say Game in a diddled instance. Don't deactivate all selectors. Open close parentheses and close the line was a semi colon. So in that case, we make sure we do not or are not able to select two or more stones at the same time as well as there shouldn't be any possibility to do stuff like this. Don't forget to say that script chance. Let's check it out to cheat. We can basically go into the game, and it's a pretty quick where we're rolling the dice and maybe we don't rule something between one and six or 17 We probably want to set this one Toby equal to six. This makes sure that we are actually getting stuff at the first turn out and we can test what was going to happen over here. So whenever we are basically rolling the dice, we should roll a six, and we should be able to select one of these stones, no matter what. But if I do so, nothing is going to happen. And this is because our stones don't have a collide on them. So what we can do now is we can basically pick all of the stones, like like this. Don't forget any. Make sure all of them do have the same components. We're gonna add a new component off type collider. Probably. You might want to take a box collider over here. So all of these guys are going to have. All of these stones are going to have box collider. So whenever we're touching them and they're big enough, basically, then we should be able to touch them and do the movable stone stuff. Don't forget to save and play again. No, I go and roll the dice and select one of these and as you have seen it hopped to the position where it was able to. When I now re roll the dice, the only one I can pick out or take out, it's the one over here because the start note is going to before and the other one's cannot leave. So I need to make sure I use this guy pretty decent now. I had ruled my land my next six, and now I can do two steps. Once again, I can't take this one out reroll. But I cannot move this or even those because to start notice full. I can also like this one. He's going to go away and I go and roll. Another one can bring out this one and so on in the force. The only thing we have not checked is, of course, all the uneven numbers. But I believe these should go and work 100% right now. A swell and no, no matter which one is going to be a human or CPU player, all of that stuff should work horrendously. We also know need to do or need to change back the rule. Human dies to be equal to six and make sure the rule human dies is going to be random between one and seven again. So we have some gameplay involved for all human possible inputs. That's once more back, which is actually not a good one, meaning whenever we have a player out and we are not selecting the one which has to select the active. But it's going to be another one with is not going to be and it would act. Deactivate also lectures and would make that one useless. In that case, we want to make sure that this particular sentence over here needs to go inside if it has a turn. If it doesn't have the turn, it doesn't make sense for us as well is for the game energy as well to deactivate the selectors. So we need to make sure that the current one do have a turn. If it doesn't, we shouldn't just react to the click like on the on miles down click, and do not deactivate this selectors at all 47. #47 Dice Model Setup: welcome back to the course since we're kind of done was our game. I want to implement some more visuals. Those visuals, in that case we're going to start with is going to be a dice. So we have two possibilities and total. We can make a two D dice animation and, you know, let it roll rule rule until we're done with picking our number. And then we just maybe showed the die somewhere on the screen wherever we like. Whichever number has been ruled like the random that range between one and seven and then we just picked from a list whichever image we want to show or we have to show based on this particular number, the other way around would be we're going to create a three D Dies, which we just throw onto the table from wherever we like Teoh, and then let it rule until it's done both ways. A do work, but well, you decide on your own light on what you want to do. I just show you this three d one because we're creating a three D way or is really game at first. What you want to do is of course you want to import. The three d dies more live created. If you don't like this one, of course we free to make use of your own. I gonna direct this in my three D Models folder and see how it looks. As you can see, it's just a cube, but no materials on it. Once again, that depends on the unity version you're using. I going to go, Teoh Ah, use legacy materials over here and apply the changes. So I gotta get the dice with just those numbers on. So whenever you create your own dies or whenever I don't know you purchase dies. Make sure that three and four opposite numbers make sure to, and five are going to be opposite numbers and same for six and won. So all these opposite numbers need to be a seven in total. So and this is going to be the dice were using Over here. We can tweak around the material if you like to on the dice directly. There's also the map involved over there. So about the materials once again, there we will be this dice UV one. As you can see, it's just all these dots on that. If you want to tend to your ah, dicier, absolutely able to do so you can make it orange or green whatever you like. And please, or you just keep it plain white all once again up to you. I'm gonna keep it plain white so we can see stuff better. What you also want to do is of course, you want to drag it into your scene because we want to make use of it. As you can see, it's also sized one by one by one. So you can now go and a shrink this down by reducing the scale to whatever amount you probably like. Teoh. So, ah, once again, this is the design decision on your own. You can even make it bigger. Once again, it's up to you. What you want to do now is you want to create some extra objects which are sitting on to that dies as a Children. To prepare this one. First off, we're gonna make sure that we're using some three d object on this cold sphere. As you can see, whenever we create the sphere, it's sitting directly inside the cube and since it is one by one by one in case of scale, we know how we can position this fear on each of these sites. These are going to be in my feelers, which a feeling which side is laying on the bottom? I gonna pop this toe the riper holding down control as usual because I'm popping that by 0.5 also want to reduce its scale to maybe 0.3 or something similar in all three axes. What's going to happen is, of course, the feeling on the side. Like the year, the collider, the C collider will reduce its size as well. Now, since we have one of these sites, we also want to make sure all the other side's going to have such a feeler. Don't make it to back. It also does not need to be is so much. And looking outside, you can't even make it like this doesn't actually really matter. Probably want to make it a bit more inverse, something like that. But for now, let's a do it as you 0.5. So we have actually some numbers to play around with. Also, you want to rename this one too. At the moment. Just aside. Now again, duplicate the scene or the sphere and pulpit to the next position over there, and you can't completely. Yeah, repeat this step for each single side. Do this until all of your sites do have a sphere on it. Once again, you can duplicate by control D and snap it by holding down control key. Make sure your snap settings are active and in the coric shape of the so. If all of these do have now a sphere on the side, we're able to create a prefab out of it or we just keep it in the scene as it is at the moment. If you like to, you can push it or put it in any corner or in the center off the play field for the moment , it doesn't really matter. Just make sure you select dies completely and take it wherever you think you're gonna make use of it later on. Also want you want to do us you want Teoh, select all of these sites and deactivate the mass surrender component on them because they don't want to see them. You only want to have the collider which are sitting on that, and for easier access we can later on er enable disable match surrender components to our needs 48. #48 Dice Make it Physical: Welcome back to the course in this part. We want to continue working on our dies, for example, giving all sites some values as well a setting up the rest for this particular dies. We gonna need Teoh. First off, we need to make sure that this is going to be a physical dice, so this can drop down from wherever it's coming from. We can, for example, declare some other three d object like a cube and put this maybe somewhere on the ground, for example, we can bring it to minus 0.5 at first over here, before we do anything else, then we can a shrink it and scale it to our needs. And of course, you can see when while we're doing that, basically, it doesn't really matter if it is visible or not. We need to make sure that we are, like, over the top off thes fields over here was that you're gonna make use of that as a ground where the dice can basically pope away from once again. We cannot escape bliss to whatever size we're gonna think where our dies is going toe work into. We can position there somewhere in the playfield once again. So this is probably the area where we want toe throw over dyes into once again it can intersect. Anything else you laid on gonna go and to take care off the rest of it. If you don't like it over here, you can always go and place it wherever you like. And you can take a camera to make a look on to this. For the moment, I gonna pick the center off the playfield. Justin, just for the testing purposes. Also, what I want to rename this one is going to be my ground. So that's my dice ground. You know the name of Dice Ground, if you like to. So this dies grown too, and needs have a box collider. This is important, and the dice itself does not have any collision object at the moment. So we can basically go with the box collider here as well. So this collide basically can do collisions. What we also need is to have any kind of physical approval of physical movement. You're gonna need to add a ridge body component to the dies as well. Well, we now would hit play the draw the dice should drop down because off gravity also, you can see it is sticking onto Those are year off those little collision objects, like onto all these sites over here. We need to avoid that. And how do we do this? We gonna need to take all these sites and make them trigger like this. When we now drop that, you're gonna see that it is falling straight on one of the sites and there's no distance and at all, this is what we want. Also, when the dice itself, we can increase or decrease the mess. So we're gonna probably make this one full faster When we decrease the mess to maybe 0.2, we can check this out, and that's OK. Once again, we later on give it a beef or a punch. So it is going toe pop around a bit wherever we like him police for the ground itself. We probably want toe also create some walls around it. We can duplicate the ground, rotated by whatever degrees, make sure this 90 degrees at all and then lifted up so that it is still your intersecting kind off the ground field. Now you're gonna go and duplicate this and other several times over here. Just make it so that the dice is not able to fall through or full outside off this dicing area. Once again, bring this to R wherever you like. In please. Just to make sure you're gonna have no problems later on and losing it Now, you can basically take the last hour, the walls off the ground and name them. Maybe war doesn't really matter and make them child off the grounds. Whenever you're late on popping or dragging around the ground, you're gonna have all the walls connected to it. What do you know want to do is you select them all and disabled the mess surrender component When we know press play, our dice is falling down and we're good to go with that. So no problem at all. If you need to work on this once again, just go and return Able all the mess render components in the next part. We're gonna go and take a look into the sites 49. #49 Dice Dice Sides: Welcome back to the course. This part We're going to take care off the sites off the dice. Meaning we gonna create a small script which is taking care off. What is the currently upwards looking size or site and so on? What we need to know is always the opposite offer. Whatever the ciders we're currently at, go to your scriptural and created new see shop script and call it dice Side and opened this one. I've been more no develop all visual studio, whatever you please. And like we don't need starting update or we want to have as a bull which is going to be called on ground. This just returns if the dice we have when we have thrown it as going to be on the ground. Also, we need the public access er for for being on the ground, which is returning on ground. So what we can do is we can name it on ground open, close parentheses, and inside the curly braces, we just return on ground. This is a function we gonna take care off in a second. We now want to do is we want to do some yes side values on to our dies. In this case, we're gonna create a public type into Joe, and now we're gonna set it to be side value. The site value contains the value off the opposite side wherever it is going to land. Also, we need Teoh have some on trigger events which is going to take care of what is the current side value and also what we want to do is is it already on the ground or not? In that case, we create to trigger functions. The 1st 1 is called on trigger State. Make sure you type this 1%. It needs to be off type collider. So I gonna name this C o l. This is important. We need to implement this. What we want to check now is we want to check for a tag called Ground. We don't have the tank right now, but we're going to create this in just a second. So what we do request is if Cole don't compare tag and then an open close Prentice's we can put in any string I'm gonna take this round string. Keep that in mind how you type it later on. You're gonna make use it off that that is the case. We want to make sure that on ground is equal to true. So whenever our trigger off this particular die side is going to be on that, we're gonna know. Okay, we are on the ground. This side is sitting on the ground, or at least is being or staying on this particular site. We also need another trigger function over here, which is going going to be called on trigger Exit. Whenever we are exiting the trigger, we want to make sure that we reset on ground or actually set it to be false. In this case, we need to have another excess toe, Kaleida. See? Well, it doesn't really matter what type of collider were requesting here, so if and now we do the same stuff over here, cole dot compare tag is going to be ground. Whenever we're leaving the ground. Whenever we're lifting the dice, we're gonna leave the actual ground basically. And in that case, we want to set on ground to be equal toe false. This is basically everything we need to do on the sites off each dice. Now what we want to do is Of course. We want to set up all the die sites, go back to Unity, select all side off the dice and direct the die side script onto them. Like so Now we can actually set up all the values for each side selecting this one knows. Okay, I'm on side six, but the opposite is going to be this. Ah, On this case, it's sitting on the one. But the opposite is going to be the six. Meaning this die side value is going to be six, not one. Keep that in mind are gonna set this one to be six, this one over here, sitting on the two side. So I know the opposite is going to be five. So the value is going to be five. Next one is this one which is sitting on the sex. I know the opposite is going to be one. So the side value is going to be one. Next one is this is sitting on the four. I gonna know the opposite is going to be three. So I'm gonna put in straight next one, and the list is This one is sitting on the three, but I know the opposite is going to be number four, and the last one is going to be sitting on the five, so the opposite is going to be number two. So we type in the side, value the number two. That's everything we need to do for the dye sites at all. Don't forget to save your scene and yet script if you haven't already, and we're going to continue in the next part. 50. #50 Dice Script 1: welcome back to the course in this part. We want to continue with our physical dice. The first thing we want to do is we want to set the ground equal to whatever the tag ground ISS. And since we don't have a grown tack, we just go over here and add a new tack. We select the plus and then we type in ground. Make sure that you type it 1% the same way as you have done in the script off the dice sites. Now what we need to do is, since we know this tag, we also need to once again click the ground directly over here and change the tank to be ground. So now we know that whenever our dies is going to fall down onto the ground, we have on trigger, enter, check or, in this case, on trigger stay as well as on trigger exit. Whenever we're lifting that ice up again, with that set up, we cannot go into the dice itself and create a script for the dice. For stuff, go to your scripts folder and creating new see ships grips called dice. Now go and the direct this one already onto the dice. If you like to keep or waiting until the compiler has done otherwise, you're unable to drag it onto it and opened this one up and mono develop off the just studio whatever your police and like wait until the system and the solution has been loaded and all the red stuff is going to be gone. And now we can put in all our year stuff into the dice itself. For now, I get rid of update because we gonna probably trigger this one. They don't a bit different. What we want to do is we at first need to connect into the internal or through the dies with the body because we need to know if the dice is still rolling or instill moving. Or is it, you know, is it static already? So we create a rigid body common connection are gonna call it just RB. So once again, this is just for testing. If hours dice is still moving or whatever it has to do or not, in start, we gonna grab the R B as a component. So the rigid body in this case we set our B is equal to get component Open close trying a brackets type rigid body open. Close Prentice's behind that and close the line was a semi colon. In that case, we cannot talk every time we want toe rid the rigid body component and take all this information out of it. When we also can do is we can set our be don't gravity's of the gravity or in this case, use gravity to be equal to force. So the the actual dice is not automatically falling down and is not making use off gravity in this particular case. Also, what you want to do is we want to a store, some bowling variables. The 1st 1 is going to be boo has lended we need to track if our dies has been lended or not and we're gonna take that as some indications later on. Also, we need to have another one which is called thrown. Is that or do we have thrown the dice already? Then we need to have something else which is called type of actus rea, and we store the initial position for that so I'm gonna name it may be in it position once again, you can type it all, It's You can name it different. Whatever. What I want to have is this position is going to be the initial Stroh position from where we have started with the die. So we can always go back to this position. And, of course, keep on going with throwing another dicey as long as well, whenever we need to. So we lifted up and throw it. And later on, whenever the next player or the same players re rolling the dice, we're gonna go back to the industry position and throw it again. So what we want to do it is with that initial position is we want to make sure that we set this one before we actually setting the R B like the rigid body we want to set. Initial position is equal to transform the position. So the starting position off the dice is equal toe transform dot position. So we store the three D space position inside this vector. The next one is What we need is, of course, we need to know all our dice sides on this particular dice. Like if you have 20 sided dies, of course you need to put in all the die side somewhere This gays are gonna say and create a public array, off type dice side you can ago And of course, loops rule the Children off that die side or you can set them by hand. Basically, doesn't really matter. I gonna name it a dice side or sites because it's the multiple end. Of course I need to have a connection to a public anted. Uh, I mean, it doesn't really need to be public, but we need to have an inter job, which is going to give us the side of value or the dice. Will you? Basically, because we want to store this information inside the dice and we want to access it whenever we night need. Teoh public, in this case probably is not needed because we going to get the information directly from all the dice sites. What we now can do is we can drag all the die sites into the dice itself. You're gonna wait until the compiler has done running over here, and we're gonna see the public array off die sites as well as the site or the dice value. Once again, you can Now it take all these die sites, we gonna take this or make use off the little lock symbol again, Select all those six sides and drag them over here to the name inside the die site Over there. This way, we are able to talk to them and requests who's going to sit on the ground if there is any. And we only request that whenever we have thrown the dice and the dice has been lended. But once again, this is port off the next video. 51. #51 Dice Script 2: Welcome back to the course in this part. We want to continue on rolling the dice. In this case, we want to start to work on our die script a bit more. Currently, we're storing the industry position and set the rigid body to be not using any gravity. Also, well know what other? All the respective die sites so we can store that inside the dice value and make use of it we know want to do is we want to create several factions which are taking care of that The dies is getting ruled in this case a name. It dove white roll dice once again, off type White does not return anything since we just perform whatever it's inside the function an open, close, curly braces. We want to make sure that we do two things. First off, I want to check in an if statement if we not have thrown so thrown is actually before end. So we used the end operator. We not have landed, so not has landed. What we do is whenever we call ruled ice, we want to say OK, thrown is equal to true. Since we have thrown it already, then What we want to do is we want to set the gravity back like off the off our reporting to be used. Gravity is equal to true. That's important because otherwise the dies cannot fall down. Well, we know want to do is we go want to give it a push into any random direction by using pork ? In this case, we talked to the rigid body RB don't and now we want to add torque this one and it's representing by or represented by a practice three. What we can now do is we can give it a random torque like a random push into ease off all three world directions. So what we're gonna do is we say, random dot range. You already won't know what's going on, and we give it some number between zero and maybe 500 I don't know. So we give it now a random turyk between zero and 500 into the X direction. We're gonna copy that and paces over year for the wine for those at the direction as well. So, once again, we give it the torque. Was a random rotation basically into any direction that means it now falls down, rotates and then it lends. Sooner or later, we're gonna check this out in a bit. What we want to do is we want to create an else's statement in this else a else. If statement, I gonna make sure that we're checking if it has been thrown and it has been landed, meaning both is going to happen at the moment, we want to make sure that we kind of resent the dice. In that case, whenever we re setted, we don't have dysfunction yet. I just type it out if it is possible. Well, let me make a command. We want to reset the dice toe. It's yeah, first position, so basically resented to its in this position. So and two rosette, this we're gonna have to create another faction over here, meaning it's off type void. We call it reset or with a big are Well, he said, open close friend to seize. And, of course, that puts him curly braces around it or inside it. So at first off, we want to reset the dice position. So we set transform. The position is equal initial position and that it doesn't matter in what kind of direction . It currently is also what we do is we want to set RB don't is Kinnah Matic. This is going to be for something aesthetic. It's going to be false. They are gonna talk about Kingdom at exhibit late on also, what we want to reset its throne is equal to false. Since we don't want to have it to being thrown at this point, also we want to send has landed is equal to false as well as we gonna reset RB don't use gravity is equal to false and that should be it for the moment. So whenever we reset the dies because we have landed already, we want to make sure that we're gonna reset it over here if it has been thrown and has landed and we want to make sure we're going to roll the dice we also can do is we can resent it. Wait for a second or two. Probably re economic use of a nine number. Reiter. Wait a second or maybe 10 seconds. So it is has the possibility to reset itself, and then we're gonna do the actual roll the dice. Once again, there are hundreds of possibility whatever we can do over there. But that's basically ever seen we need to do now when it comes to throwing the dice alike or Ashley, how to read all this information is going to be a bit, let's say code heavy. But there's no problem was that we gonna check this out in the next video. 52. #52 Dice Script 3: Welcome back to the course in this part. We want to go on with our die script in that or in that place, we gonna mix, use off the update loop. So we create a void update. Probably We're gonna change it later on to make use off a nine am aerator instead of update . But for the moment, it is possible for us to make use of it so we can actually check for everything we're gonna need to go on over here. What we want to know is, whenever we have thrown the dies, of course, we want to make sure or went to want to know if the dies is lying on the ground and is not moving anymore. Unity has a function for that. Directly inside our rigid body component called is sleeping. As you can see, it returns the true or force so we can basically talk to it like a function. So if our dice is sleeping, we need to make sure that we also have thrown the dice and it has not been lended. So we need to take another end operator. So we say and not has landed because has landed is only true if we are sleeping and we have thrown the dice So we need to make sure that we have thrown the dice. It has not been landed at this point, but it is not moving at the moment. Then we can react to it. So first off we can set has landed is equal to be true because it is not moving anymore. Based on once again the r b a sleeping over here. In that case, we set this one to be true. So this turns true began do everything whatever's inside and then we leave it. We also want to do is of course, we were onto a cent RB don't use gravity to be equal to force because we don't need to use gravity anymore. Also, what we want to make use off is RB Dog is Kinnah. Manic is going to be equal to true as well So whatever is running into it cannot move push it away or move it. That's what we make use off cinematics in this case now what we want to do is we want to say we want to ah do aside the our side value check over here because we know it has landed . We don't move it anymore. We want to get any value and bring this into the game. If that is not the case, so else. If RB don't is sleeping and has landed already and has been thrown already so that all of that is going to be the case, it means we need to roll the dice again because probably it has not returning anything. So we say we want to roll the dice again. I'm gonna explain this. Meanwhile, we're testing on off that out. But also what we need to do is of course, it's not just having thrown but the dice of value in this case. So dice value is equal to zero. So whenever we don't get any value Oh, and we need to make it so that is to equal science of here. So in that case, if we are on the ground or basically we're not moving anymore, we have landed already just because of that, but will return a dice value of zero. Then we want to make sure that we rolled the dice because we have no your argument because sometimes it can happen that the dice is lending on a on a corner or on a side and is a strangely moving. So we need to make sure that we are re rolling the dice again just to make sure we're going to get any result later to roll the dice again. Of course, we need to create another function over here, which is called, Yeah, I was off type point and we're gonna make it so that we're gonna call it roll again like that, Open toes, parentheses and what we need to do is at first we need to make use of our reset function over here. So it's we call at first reset, often close parentheses. Close the line was a semi colon. We need to make sure that throne is going to be said to be true. So thrown is equal to true. And what we also need to earn able is RB don't use gravity is equal to true. And what we also need to do is we need to give it a push because this push is only being done over here. Inside of the rule dies over there. Probably there is a possibility to make use off the rule dies again. But actually we can just keep on on getting this one and bring this into our rule again function, because all the other stuff might not need to be your important for that. And that's everything for re rolling again. So in here I can call rule again once again, open close parentheses, since it's a function, and don't forget to enter line with a semicolon. 53. #53 Dice Script 4: Welcome back to the course in this part. We want to finalize the dice completely. So we need to go and create one more function as well as later on. We need to connect our button to the functionality as well as sending all the necessary data later on back to the game manager. First off, open up your dice script and we need to create a second or the next function over here, which is doing the side value. Check this one. We already commented out over here, whenever we're done was rolling the dice. In that case, the first and the very first thing off girls is we need to create the function name. I gonna name it aside. Value check. Okay. Close Branta sees. And, of course, open toes. Curly braces. First off, we want to make sure that the side value or the dice value is equal to zero. We're gonna need to do this because we want toe. Have the check over here to not return anything strange or we're going to reset it whenever we're starting, you know, to rule the dice and check for it when I want to do is we don't go through all these die sites we loops room by one or the other four Lupo for each loop doesn't really matter and return Whatever the dies, value is if whatever the sod, any side is returning in case of true falls by requesting the bull on ground. So when we're gonna need to do is we're gonna take a four or for each loop once again, up to your I gotta make use of before each now. So for each open, close parentheses and now what? We are talking to it, Of course, Dice side. This is the script name. I'm gonna give it a name side so I can talk to it in an hour ago and take the dice sides array over here, and then often goes, curly braces are gonna make use off the if statement. So once again, if the side which we are currently looking through So if side don't on ground so it is returning to or falls in this case, if it is returning true, then we want to give ourselves the dice value to whatever the Dai side returns. In this case, we set dice. Value is equal to side. So the current we will look through site don't side value. So I returned this over here and what we can now do is we can send to the result toe the game images sent. Result two. Game manager. So with the game, manager basically can take care off that the game is going on. I'm gonna say that what we know want to do is of course, we need to call side value check over here like whenever we're done with throwing over dice , don't forget to safe and probably in start where we are using our B gravity already You may have seen that the dice is still moving When don't forget to safe by the way that the dice is still moving One of only we're now pressing play also I have a type of somewhere I forgot to semi colon In the end, I guess anywhere over here Don't forget to save whenever the complete the consul's complete And there are no errors, of course in this consul and we press play this dies is going to fly or float around as you can see, does not use gravity. It's just ping ponging around. Since this is flying around over here. We probably at start want to make sure that we are setting Is Kinnah Matic to be fools or in this case, through. So whenever this is can a Matic is on. We can do this directly over here. Whenever is Kingdom Atticus on this dies is not going anywhere. Gonna check this out. As you can see, whenever it's Kinnah Matic, it's not rolling around or actually floating around somewhere by whatever for would have a reason. So what you want to do is you want to unable is can a Matic. Now we need to trigger the dice to work, meaning we anyhow need to connect the dice to our rule dice button over here. Also, we need to connect it so that whenever we have rolled a number that that the game manager basically knows that we have done anything over there 54. #54 Dice Roll Dice 1: welcome back to the course in this part. I want to make sure that the CPU is able to trigger rolling one of this dice and returns a number and activate. Of course, the complete rest off the current year workflow. To do that, we're gonna open up our game manager and see how that CPU is basically working once again just to keep in mind whenever we're calling Rule dies. Whenever we're CPU, we're gonna start a co routine to roll the dice DeLay. We can basically get rid of that rule delay at the moment because what we do is we wait for two seconds. Well, we can also keep it in. We're gonna wait for two seconds and then were asked Lee, roll the dice. And meanwhile, we are rolling the dice. We're gonna create the number we want in that case, what we want to do. So we need to return the number diced by the dice itself. Whenever it's not ruling any more into the game manager and set it up so that this rule dice in this case has this particular number already whenever it's done. So there are several things we need to set up for that because at first we need to anyhow talkto the dice. So what we're gonna dio in over here probably, or wherever we need to create a connection to the dice. So we create a public called dice and name it dice was a small D, for example. Now we can in dies itself. We can trigger any function we want as long as it is public. Currently, there's nothing public over there, but what we can do us. We can basically talk to the rule dysfunction inside the dice. In that case, we gonna get public. Boyd ruled Ice Well, we know can do is we can say dice a daughter. Roll dice and it will do or trigger the complete rolling dice functionality. And whenever it's basically done over here, dust aside, Village act because it's sitting up late at the moment. And then whenever that is the case, we're gonna get any dice value as long as it's not zero. And then we can send this information back to the game manager. In this case, we probably create an extra function over here. Boyd CPU dice them open close friend to seize, and we want to do in here and open close curly braces we say dies, Don't roll dice the function we just made open, open, close parentheses and close the line was the semi colon. Now we gonna trigger from the CPU whenever we wanted to rule the dice. In that case, we can basically do all of that over here, which is sitting in the rule dies DeLay instead of rolling the dice after two seconds, we can call CPU dice the one we just created. So after two seconds, we gonna say, OK, go here, rule the diets over there, and it's going to perform it. There's one thing we need to take care off, of course, in a bit, because we probably need to reset the dice whenever it's lying on the ground already. So we don't have to tap twice to lift up the dice. But that's what we're gonna check in a second or a minute, since the CPU currently does the role. But also the human later on is going Teoh tank. This number and consideration would probably want to make sure that we sent over something like is human or is bull or is a CPU, whatever the type is, and according to whatever we send over there, we probably want to know and send back in this case, the next step is we probably want to make this rule dysfunction over here public. So our dies from the other side, can access it whenever it's done or whenever it has been ruled. In that case, we probably won t o make you reuse off this particular one and decide if it was a human input or if it was a CPU input over here. First off, we need to put an integer off the dice number as going. Or as when we're calling this one from the dice. Gonna name it dice number. Maybe it was an underscore. Otherwise, we're gonna override this dies number over here and instead of ruling was Random Gold Ranger going to commend this out? We're gonna put in the rule to dice number over there. In that case, we can basically go in and call this from the dice directly. So now we know whenever the dies is done, we can call this function over here we can directly from the dice and now what we need to do is we need to change the use case for that. In that case, we're gonna take our year input para Meter. So whatever the current guy iso, if it is a CPU, we need to act the friend than if it is a human. In that case, we gonna make another if statement in this case, if player list inst grab records active player dot And now we need to request the player type is equal to CPO. It's going to be this one is that it's the case. Then we want Teoh do everything automatic. So basically, we're gonna take all of that and bring this into here. If our current player type is a human like if that is going to be human over here, we want to act different. Of course we need to. In this case, where we need to do is whenever we're done with that and to the player actually has thrown the dice, we're gonna go down through the Jew human input we want to call rule, human dies. We already deactivate the button whenever we call this human door old ice. But what we don't need, we don't need to roll over here because we have that already. I gonna copy that. She rolled human dice part over there. I go up again into the role Die, sanction. And now what we need to update is rule human dies is equal to whatever the incoming dice number is like this. And then we can call human or rule human dies or human ruled eyes over there. This one. We need to make sure that the human gets the correct amount later on and we can do or everything else we had to do over there. This is important. Also, wherever we are laid on, going to do the rule dice input by the button. We also need to basically we can use the same one over here. We can call CPU, roll dice or CPU dies as a rule, dice function or once again, whenever weird putting that we're pushing that particular button. This is whenever we're rolling this Ashleigh. Yeah, When we are activating that, we need to make sure that whatever we're calling whenever this button is pressed, that we're rolling the dice from the button press itself. But I guess we need to create a new one. Since once again the sits the human rule dies, usually sits directly on the button, so we need to create an extra access er which we can make use off on directly on the button . So in this case, we can also we can also use the CPU one. As I explained before, we can make it so that we say human role or whatever Open close parentheses. But it doesn't return any. So we need to make it sure that is going to be of type white Open, close, curly braces and what we want to set is actually what we want to do is we want toe throw the dice so dice don't rolled ice. This is what we want to call now from the roll dice button whenever we are a human. So we need to take care of that. Actually, it doesn't. It cannot be the same one over here, so I just name it real human role call. Don't forget to save and let's go back to unity and find our button for the you roll dice or you rule Human dies. So we go to the canvas, select our rule dice button. We can also Whenever you have locked us still have locked us, you can actually go and reduce it or make unlock it basically. Then it can go here to the game manager. We gonna make use off human rule instead of human rule dice. Don't forget to save your scene And now it's time to test. So whenever I want to roll the dice a click on here on what I get is another reference exception because we don't have any excess to the dice at the moment. So we goto gay manager, go down over here and drag in our dies. Don't forget to save your scene. Once again, Control s for short cut and try again. So I tried to roll the dice. The dice falls down and it now return to six. But anyhow, it does not report that we are able to do something. We're gonna take care of that in the next video 55. #55 Dice Final Steps: Welcome back to the course in this part. We want to do the final step to get the dice actually working, which I already explained before but just forgot to implement we need to open is the Di script itself. And wherever we want to send the result of the game ended, er we need to call one particular function and the function is going to be resume over here in the top, I guess where we are actually rolling the dice and decide if it wasa CPU entity or human entity we no need to do is we need to call this from the dice Already explained this over here and we need to put in the dice number. So go to your dice script Now We talked to the game in the jet first, So we se game manager. I thought instance Don't roll dice This one on when we need to put n is the actual dice value like this because this is the one which we currently found here on the ground. Don't forget to do a safe the script and let's test it out again. So I try to roll the dice. I rolled a four. And now the CPU is going to take its turn and tries to make use off the dice. The downside is, at the moment, whenever we want to re roll the dice, we need to update. Or in this case, we need to reset whenever we're rolling the dice. So first off we reset the dice and then we're gonna throw it like, over here whenever we call rolled eyes, we need to reset first. I'm gonna copy Reset over here. Then I paste it over here in front and whenever we re set off course than we are able to throw and roll the dice. So once again, don't forget to save. Let the compiler run and see if that is working right now. So me as a player, I'm the 1st 1 going to roll dice. I had a five. So my button DX debates because I cannot re rule at the moment. Now the CPU was trying to roll the dice. You get a five and now the next one is going to take the dice after two seconds. And all of these guys are now trying to rule six until they any I'll get out you can see he had a sex. You can now re rule. And now we get to one pretty cool. And now we have a three D times. Basically, we can also take our own function or our own creature Over here on. We can basically do the same stuff as we had done before once again. Now we just keep on waiting for two seconds before the next guy or the next enemy is going to take place over there. And they are all playing with our three d dice over there. As you can see, sometimes it's a bit picky and sometimes it does not really match 1% as we probably want to have it. Also, the torque, like the rotation on the dice, works quite good, and we are also able to make use off the dice. Anyhow, I cannot collect this at the moment, so we need to take care off click ability. I believe it is because off the colliders which are sitting around the walls, so maybe these colliders are at the moment too big. So we probably need to make sure that we put this somewhere else on the screen, but also we can probably if we're not having it to, let's say, ah, sloppy dice in this case and we not for let it fall too much down, we probably gonna get rid off the walls as well. So once again, what was the problem? The dice or where A like the walls around it do have collisions as well. And if I tried to click on my ah, yeah, on my little stone over here these or basically these dudes years should actually not react to my clicks, but they do because they're collision objects on it. So probably the best way of here's getting rid off the walls, take the ground and scale it up quite high. So it basically does not really matter. Maybe I'm not going to do this way, but single last loss. So, like, per site, something like this. You can make this ground, however, how big you want. Once again, you can pit, picked the stone, go to the top you and brings us maybe more to the center. So it's not so strangely looking over. You can always go into isometric view and bring this may be here in the center and maybe you want to lift it up, slide a bit. So you're gonna have more like a poppy. Your animation for this particular dice. I gotta try again. That rules crying too good. I made it to. And now the enemies or actually the sea pews are going to do the same over here. We don't have any sloppy things because we'd only use one dies later on. If you're using, like, several more dice, you probably want to make a least ground or some walls around the ground of the year. So whenever they get pushed back away from something, you might want to get rid of that and not lose your Yeah, your dice, in this case, by falling down onto the ground or whatever or quite far away from that. And that's everything we need to dio for all our dies functionality. There might be some things we need to take care of light on meaning whenever, for example, the figure is inside a dies. We probably are also not ableto collect on this. So maybe we're gonna disable the collider or something whenever the that is going to happen . But as you can see, it barely happens at least at the moment. And, um, if that is going to happen one day or the other, you might want to make sure that you deactivate the collider whenever the dices lended and when it has not landed off course that you're going. Teoh, activate the collider again. Otherwise it probably does not work as it it's supposed to. It's one thing to mention over here to not abuse at the roll dice button. Once again, we need to make sure that activate but and falls is going to be over here or above. It basically doesn't matter. So otherwise, a human player could keep on tapping on the button until he finds the dice in a Cory position. Don't forget to save the script and you're done over here. 56. #56 Info Window: welcome back to the course in this part. I want to go and create some small info window where we gonna see and also can off course flush in data to, ah, see or actually give some feedback to the player. So who has the turn? Who has ruled whatever number as a dies and so on and so forth, just in case. And so we're gonna give the player in case off whatever case, we're gonna give him some feedback so we can do this directly inside over cameras we've created already for roll dice over there. We can basically put a box around that if we like to, we can give it any graphic and stuff like that. We contended and so noticed just simple things as well as we're going to give it some text . And inside there's tax. We gonna give some like we do with the debug a lion's over here like who has ruled which number and so on and so forth so we can give all this information inside. And this particular info box I'm gonna go to two D view and a scroll out quite far. So until I see the complete canvas. It is totally up to you where you want to put this. You can put this on top and the bottom left, right? Whatever the once again, all of that it's a design decision you have to do on your own. What I want to do is they're gonna create ID and you you I image. And I can place basically this image wherever I like to. And I can't make it big and small and stuff like that. And I can do my designs inside of this image also. And I can also define where I want to position this one. Maybe I'm not going to put it in the top because it might not fit the camera with you. I'm currently at blood. You can also always go and change the camera view. So probably I gonna put my info box down below over here. Maybe I make it a bit transparent in case of color. Maybe also give it a sprite of this year background, sprite or something, and once again tinted a bid to make it a bit semi transparent. Whatever, once again, you can always get your own, um, stuff inside. You can make it also like highlights this one with some color tint, whatever. So so people see what's going on over. You can even make it bone black. Also once again. All of that depends on how your playfield later on looks. So probably you make it a bit grayish. I don't know. You can also anchor this a bit to the bottom so it always stays there and just livid about it lifted a bit up, so it's always going to stay in the position, no matter where it is once again. Also, that depends on if you're going to work or play later on in landscape mode, as we do at the moment or later on, probably gonna make use off the portray mode like upside down or actually, like 90 degrees changed. This is once again all of the design decision you gonna have to make once again on your own . So inside this image, you can name this one. I don't know. Info box doesn't really really matter how you name it, but as long as you give the name and you know what's going to be about next one is you want to put in a text field. Something like that. You can make it once again. Big, small. You can shrink it, Abdel. Next. Right. All of that stuff. Make sure this child off the info box so it can put in all the data on later on. Just drag around the info box at the text, and stuff like that will follow. So I'm gonna name it, may be in for taxed. And now you can decide what's again what kind of style you want to do or want to use. How big the text you want to have it. Where do you want to have it? Do you want to have a best fit? Do you want it to have want to have it in whatever way and so on and so forth? Whatever the phone sizes, whatever the formed itself is, if it is bold or not, if it is left side of right sided in the center and so on and so forth, you can, um, basically design all of that on your own. Okay, So once again, if you decide to make use of best fit, then make sure you maybe make it a bit small, so it's not being too much information. You can once again also do this in the center of the playing field. Doesn't really matter. We just change the tax later on. We're small script Teoh put in order necessary data. We can also tend thanks. And all the other stuff by code, if we like to all you keep it as is. Okay, so and now, if you wanted to do is we basically just want to talk to the text or the info text over here by excess ing. This attacks perimeter. But to do this, we're gonna need to have, of course, a small screw it, which is talking to us. So I gonna name of maybe info or info here, maybe info at the siege of script and opened this one up in mono develop or visual studio? And are we gonna need just a small stuff over here? First off, we need to have the component or the connection to the text field. But the text field is part off the name space unity engine dot You I for user interface. Make sure you at this name space by once again calling using unity and in, don't you I now we're gonna be able to talk the tax and I'm gonna name it Info, text, and we don't need start. We don't need update. We just need to have a function which we can basically talk to and flush in data. And the simplest one is going. Teoh, give this one s static para meter, as we already did was to gay manager. So we can say we create a public static info and we're going to give it a name, maybe instance. Once again, the only thing we need to do is otherwise we don't have access to the aesthetic pyramidal. We need to create a avoid awake, open those fantasies. And in Curly Berry says, we need to make sure that instance is equal to this. This is important. Otherwise this does not work through this excess. Er doesn't work. Now. We need to have a public faction which is called public. In this case, we're gonna update the text elements, so we make it off type void since we don't return anything and now inside of that, we say so. Message, whatever the message is is going to become, for example, here inside the string and we give it just whatever the messages we want to give it. So let's say text And in open, close curly braces, we no need to say and for taxed dot text. So we talk directly to the text component sitting on the text component directly and said this one equal to whatever the string is. We want to talk or sent into this also probably in awake or start. We want to empty the strength in this case, we can say and full text and dot text is equal toe. And now we just put in some empty quotes over here. So we no matter what is currently going to be inside this infra text we can override. It seems I have a type of somewhere in this case, we don't talk to string. Of course we want to talk to text. So we take this text and if you are unsure, you can also name it Underscore taxed like this. So whatever puts in over here lands directly inside this info text over here, which we need to just drag in to where wherever we need to. In this case, we can a directly talked with the info box authors and for tax basically doesn't matter. Probably the best way is doing a directly onto the info box. Now we drag just our info on to this and go to the child, object in for text and drag this into the info textured over there. Now we can't say the scene. And actually, whenever we are pressing play, this should be an empty box. There we go. Nothing is inside. That's good. Now we just need to fill in data into the infra script from wherever we do. Any info is or wherever we, for example, do at the moment D buck lines. So, for example, we can say who is going to be the next player or who has ruled. What number? How do we do this? We can actually go, for example, into our game manager. And whenever we're reporting any d Brookline's once again we can go and are dated. For example, in this case here, whenever we're rolling a dice, somebody has rolled a dice number. Instead of putting this one in a D back line, we can also say who has rolled the dice. In that case, it's going to be we talk at first to the info. Then we say daughter instance. And then we say so message and so message. Open cost fantasies we can put in any string at this particular point. The message we want to show is, at first we want to send over whatever the current players so playlist dot active player, and then we say daughter, play a name. So whatever the player name is, and then we can say plus, then in quotes, keep a free space before that when we say has rolled. And then we can leave a space after that and then we say plants. And then, in this case, we're gonna put in whatever the dice number is. So underscore dice number. So this is the easiest way to talkto this particular info box, and we can do the same whenever we're switching the player. So whenever we are switching the player, we can already say who's going to be the next player because we know that, or whenever we're rolling a dice or whenever we are triggering raw the dies, we can also say we want to yeah, actually talked to who is going to be the next player we can even do this directly in turn possible. So how do we do this once again? We gonna not probably not do this directly by the human over here, but probably we do this directly wherever we are switching the player. So whenever we're switching the player, we can actually say, OK, who is going to be once again? The next player in this case after we had done was setting the next player. We're gonna put in any info over here. We can also do this whenever we had done with setting the complete player over there like before we start to rule the dice. In that case, we can set it over here. So once again, we can talkto info dot instance dot So message open, close parentheses. And now we can say something like playlist in square brackets, active player dot layer name Plus And then once again, in quotes, something like has turned. Or we can just say we make a semi colon and do something like that. So we're gonna take the player named then. Is this? Ah, yeah. This over here, this upper case, whatever it is called and then a s behind it. So we can say this is going to be whoever's turn in this case if it is green than it's going to be Greens turn or blues turn or player once turn whatever you name to your players and eso this way we gonna give out info is directly into this box and update the player if he's like, unable to see something or whatever into this particular info books over here. Now you can test this one out by just press play whenever the compiler has done and has no problem, you're gonna see in the end for box, we gonna see something at all. We don't see the first player at the moment, but I like who has the first turn. But that is going to be one of the next ports, meaning whenever we say, Where do we want to start with? So who do we choose to be the first player? Because currently just read player has the turn, but I can roll the dice and I get red has ruled to know it's Greenstone. As you can see, it's automatically updating whoever is, you know, getting any and now yellows turn and so on, and so force So now we always know what's going on, and you can do this by tanks. You can do this by colors. You can do this by whatever you please. And like So now it's rats turn. We can roll the dice. Of course, we're gonna get updated. We rolled it to another. Next player is going to be green, and he's rolling before and so on. And so force. So this is actually quite some idea how you can update or actually tell your players who has the actual turn. 57. #57 Random Player Starts: Welcome back to the course in this part. I want toe let the system automatically decide who has the first turn. In that case, we're going to open our game manager. And before or after we deactivate the actual button for whoever is that we're gonna go small. Yeah, put a small, random number over here. So we just say end. And now what? We just take a Yeah, a local very able in this particular case just for that sake. So we're gonna say and name this one like random player. And we want to set this one to be random. Don't range between. And now we're gonna go and request zero comma, and then we take the player list. Don't count. So whoever and however this number is going to be We know there are four inside, but negate by one. So we have a number between zero and three, basically. And now we just say our active player is equal to whatever this random player number is going to be. And now we can also show a in four bucks once again info dot instance don't. And now we talk to show message, open close parentheses and inside, we say player list in square brackets. Know again. It's updated, active player, and now we say, plus starts first or something like that. So now we can just update the player by whenever we're starting that, you can put this also into some kind of co ro teen. Wait a second or two, so you probably don't get overwhelmed too much with this information. And after that, it's happening off course. We need to make sure everything else is updating accordingly. Don't forget to say the script on and let's go back to unity and check this one out. So whenever we start, game manager plus entity is going to start first. So we forgot to put in the name of a here. So playlist square brackets, active player don't play. A name is the one we actually want to show over here. Of course. Don't forget to save again, letting compile a run and to his job. And whenever he's done, stop play and see who has the first turn in this case. Green starts first. So Green has ruled one, and now everything else is going to go forward over here 58. #58 Main Scene 1: Welcome back to the course in this part. We're going to start to create a menu, a scene, a menu scene where we can actually pick which one of these players are going to be human or even CPU. And also, you can go and design it for your needs and purposes. Go to file and creating your scene. Don't forget you'd only do this whenever you're done. Was the sample scene if you want to rename it every time, you can make use of it. So I'm how do we create actually a user interface where we can pick or choose which off these players are going to be, you know, human or yeah, CPU. What we're gonna do is probably we create at first a Penhall or an image which is going to represent how our Yeah, what panel is going to look like? I gotta go to to demote because we are most of the time are going to work here in two D it first I want to make this one resonates more because the only stuff is going to happen inside off. One of thes panels is basically ah, they're going to be a let a yet name and probably a color off the panel represents. Whatever the color off, you know, the player is going to be. And then some other things we're gonna take care off. Also before we're gonna do further more than just creating a panel. We want to go to the canvas and changes. Want to scrape a scale with screen size? Otherwise, you later on have yeah stuff you don't want to see over here. I guess so. Scale with skin sites ascent. And we can literally put this panel wherever we like to inside this panel. I want to create some text. This is going to be just a play. A text, for example. Um, let's start with the red one. Red player. We can also tend this one to be ran so we can easier See that also begin. Go into use a pest for best fit over here and line it to the center. And probably put this in the center on the top off this particular field over here. So once again, this is just representing the name off the player you Or in this case of the color, off the player, what do you know want to do is you want to create something else which is going to be called a toggle. A toggle is nothing else. And something was an option. When we can put things or do things on and off, we want to go first we go to label, and the first thing you want to set over here is probably CPU in this label as a text. Once again, you can design it. However, you like to make it bold to make a think make it, then make it whatever you please in like, however, it fits your needs and also how big and hold small You want to have all of that stuff Once again, it can keep on reciting things off course again. Take a look into the background like how big do you want this total button to be and so on until force it probably is the best way to do it right now, because on the other hand, it might not fit later on into Yeah, whatever you're currently at, I'm gonna maybe do it something like that. Once again, you can make it big and small. Have you, like, make sure that it is easier selectable for the players later on. So maybe the total button and needs some hand wants some help for you over here. Also, you can change the background to whatever background you like, even with the check mark, which is going to be just that symbol even that can retain. So if you like to have other ones off course, feel free to make use, um, so I'm gonna leave some space, and so this is going to be my CPU, which will be the 1st 1 which is able to be on which is going to be the selected one. What I know do is I duplicate this CPU one and gonna bring this of our down below on the second. Talking in this particular case is going to be for human. So whoever is going to be receive you or human? This is up to you. But the players should have as a possibility to select one or the other to whoever is going to play this character. So whenever human wants to be a red player, of course, he needs to select human what? You want to do it for the second art. Do you want to say is on is off. So this able to function over here once, you know, press play, It should updated automatically. Or probably it updates or what? However, you like it. So when you know, talk with this on and off, you can do so by just sees. But what we want to have is that only human. Ansip, you are only one of these skill going to be able to be enabled what we want to do. You want to change them accordingly. So when I select CPU, I want to be ah want to sent the human to be inactive? How do we do That is pretty quick or pretty simple. On our panel, we create a taco group type and toggle, and you're gonna find a toga group. Do not activate. Allow switch off. Make sure you select both struggles and drag in the panel inside the group over here a second. See in the very bottom. This is the total group. When I know so like this one over here, I'm gonna be able to toggle between CPO and human. So no matter which one I select, I can only be only one can be active at the point of clicking when we are done was that we can basically go on and copy and paste art for creating the blue, green, yellow and whatever color you're gonna have over here. So once again, you can positions this wherever you like, because you have a Panelist like apparent object. I got a duplicate this right now and bring this maybe to the other side of the playfield. Once again, you can make this one big, small, whatever, Like make any design you after. Basically. And then I bring this to whatever positions you like. I'm gonna make it so that I have this 1 may be here and here I'm gonna change the tax toe. Maybe the green player or whoever is going to be the next Basically doesn't matter. You can even make the one Ah, this one going to be for the Blue Player Once again, I change this one to green also, I didn't rename it on door. Maybe I want Teoh choose this one instead. Like so And maybe I want to make it bold. And maybe I make a bit a bit bigger. Since the name is a bit bigger here as well. So once again, if you want to have, like all of them looking the same, you probably want to make sure that they're all fitting the same sizes and stuff like that . Same here. I want to make sure that I'm, like, on the side, probably over here. So nothing is changing with looking too weird. So next one is basically the blue one, so I can duplicate the last panel I created. Bring this probably over here. Doesn't really matter. Once again. Go to the tanks field over there. Change the color, Toby. Whatever the blue color issue after, which is probably the one most appealing one for you. And of course, I changed the taxed over here to be blue player. And now we're gonna go to the last one, are going to duplicate this again and make sure that I corner this accordingly on make sure you have unable to demote. Otherwise, it might be the tricky I go to the text again. Make this one a yellow player. Like the same way as we written that before skin see, the tanks is a bit smaller over here, so probably want to bring it a bit outside as well as change the color to be this slight orange yellowish color we have chosen before. It's well, whatever you have chosen. If you have a purple playoff goals, papermaker, look, make a pope of play over here and so on and so force. So we just we decide that this is going to be a four play a game, So we're gonna choose between human and CPO. We can do this now between all of these. So whenever I select a human in the yellow one, it's going to change only this one. Same here. Same here. Same here. So now was our target groups are basically done. You can also create in the cameras some kind of a title. Like you. I text bring this somewhere in the top, maybe type in Ludo three D, or we're gonna use anything you like and police make sure you may be making bald or balding metallic bring in your own funds. If you'd like to make this one black, green, yellow or whatever, once again, you please and like also might want to earn able best fit. Just Teoh, you know, have the Paul because you have the possibility over there and you can also go was the background to like a setting the main camera not to skybox, but probably solid color and choose whatever color you may be like over here. So on that, once again, the design is going to be up to your You can once again replace these boxes, make them all at the border, make some other options in the top. What every police in like the only and last thing is we just need to have a start Buttons. So probably are gonna take all these panels again and maybe bring them up slide bid. So I have some more space for my start button at the very bottom over there. So this is fine of the final step for this particular scene. Basically, and we're gonna put the button over here. We can rename it once again, put in something like Start and then off course. We might want to go and maybe change the taxed, the fund, the size, if you like to. To best fit, of course. Yes. Well, maybe you're gonna give the button some other color tuned or any other design. Whatever you please in, like again highlighted a bit or whatever it needs you have over there and then you're good to go. You can also anger that start button to the bottom and no one's. That should be selectable as well as this. Options should be able to be selected. 59. #59 Main Setup Toggles: welcome back to the course in the last port. We were creating the main menu for this particular game. Once again, design decisions are up to you. What we didn't do is we haven't saved. I was seen, so you might want to go in pretty quickly, safe your scene, So go to your scene's folder and maybe name it menu or whatever you please. And like it can also be a sub selection menu. Whatever it is, just save it. Okay? What we know want to do is we want to increase or create a toggle a year functionality. So we know whenever we're starting the game, who was going to be or what has been selected by whoever is playing the game. To do that, we need to create several no new scripts or, in particular, at least two. So what we're gonna do is we created in your C ship script, and maybe we're gonna call it game setting four game settings. So maybe you want to bring game settings into another fold over here just to make sure we gonna you haven't easier access later on. So we create a new folder, maybe call it menu so everything about menu will. And inside of that, you can also create a game for the for all the games will. For the dies, you can do a Dice Wilder and so on. It's a force, however you're pleasing, like open up game settings window and a scroll in If you need Teoh and let's Do the drop Inside of that game setting is make users that we can use all the functionality off these toggles and read the information and store it somewhere to store it somewhere. We're gonna create a second class into game settings, which is going to be a static class, which is just accessible from over here. But we want to have something like Wherever we store information, we want to make sure that we put that in. So in this case, we create in your public static class, and we can call this may be safe settings. What? You also also will notice we're not deriving one of behavior because we don't need excess directly for that as well as we don't want to do anything but keep this static savings over here or the safe settings we're gonna set in the game. settings over there. Well, we know want to do is we get rid off starting update in game settings. Once again, we have, like, two classes now in one script, which is absolutely fine. Now, what we want to do is we want to save the settings. Anyhow, Insane settings are gonna make a small command over here because you might if forget the or have for gotten your own orientation off the playfield. So as you probably remember, the first player on my list and the game ended, it was red. The next one was which was coming was green. Then the next one was yellow. Then the next one was blue. This is important that you keep the order in mind because otherwise this is maybe a wrong setting or we'll give you wrong settings. How do we save the information now? Inside of something? Actually, what we can create is just a public static Ah, string array. And inside of here, we can actually street are safe. The players input. In this case, we just name it. Maybe players. And we set this one equal to and your string off type, you know, array and give it a four. The four means the size of the string arrays always going to become four, which is always starting at element zero. So we're gonna start at 012 and stray. So we have four in total because zero is the first element in the list or even in an array . Now what we need to do is depending on the input we gonna do over this. Total groups we gonna need to set the player. Whatever is the player we need to save its settings inside of the safe settings list. First off, how do we read the data? I'm gonna make one of thes fancy commands as well have done already over here. So everything about red is following. We need to create two bulls or athlete to avoid functions which we can actually take care off from these total buttons in this case, their off time void. Since they don't return anything and I'm going to name it set Rhett human type, open, close parentheses and inside were given the need to have a bull I gonna name the bull on. Well, we know want to do is we want to request if on is true that we want to talk, talk to safe settings. Then we want to talk to of the place list. And in square brackets, we want to excess number zero, which is once again representing the red player in this list. And then we want to set this string to be equal to human. Make sure you make everything uppercase over