 Hello, welcome back. And this is our Flax Bed, Flax Planter minigame that we're working on. So we're going to now start to put together the logics to create the actual game. Now I've drawn out a sort of flowchart as to what the game actually does. So the idea is that you start here where you plant your flax seed. And then after a certain time, the flax plants grow. And then after another certain time, some weeds grow. Now at this point, you have a choice. You can either let the weeds remain for however much time, or you can weed the bed. So let's follow this branch. When you weed the bed, the weeds basically disappear and your flax plants remain. And then after a certain time, more weeds grow. So again, you have a choice whether to pick the weeds or to just let them grow. So in this case, if we pick the weeds, again the weeds go away and we're left with flax plants. And then after a period of time, the flax bed is ready to harvest. And then when you harvest it, you get your flax. So that would be this thing right over here. Now, if you decided not to weed in any of these points, what you get is basically a weedy bed, which will not give you any flax at all. After a certain amount of time, you get a seed that you can harvest. So this gives you a flax seed that you can then go off and plant again. And in this way, you can basically create more and more flax as you need it. So when you harvest the seed, it goes back to just being weedy. But if you don't harvest the seed, nothing really happens. It's just that you don't get the seed. So after a period of time, another seed appears and you can harvest that. Another seed appears and so on four times until in the final section where you just leave the weeds as is and it times out, then basically the flax bed disappears and you're just left with a seed. If, on the other hand, you left that final seed alone for a certain amount of time, basically again, the same thing happens. The flax bed disappears and you're left with a single seed. So the idea sort of is that if you had planted a seed and then just walked away, you would go through this path and eventually the flax bed would basically die off and you would be left with your original seed. So you can harvest seeds along the way and you can get as many as five seeds. Now in the actual Tale in the Desert game, this can get more complicated depending on the type of seed that you plant. So you originally start with an old Egypt flax plant, which I think gives you one flax if you harvest it or it can give you as many as five seeds and you have to weed the bed. And I'm not sure how this works, but there are other types of seeds that you can get using basically farming techniques to sort of cross species. And you can get better seeds that give you maybe two flax or two flax and one seed and so on. Some of these other seeds also require you to water the bed at certain points. Sometimes they give you more seeds. So this is sort of like just the basic minigame that you can build off of and that's all that we're going to do right now. So let's start by thinking about this section of the flowchart here. When you plant the flax bed, basically nothing is in the bed except for the stakes and the dirt. So after a period of time, you get growth. So these weeds, these flax plants right over here should sort of gradually appear. So in other words, the alpha for the material is going to go from zero to one for a period of time. And it's the same thing with the weeds. When weeds appear, they sort of fade into existence. And when the seeds appear, we want the seed to fade into existence. So I thought we would work on that part of it first. So let's get started. Let's put that all the way over there. And what we're going to do is we're going to start by looking at our flax, not flax bed. Flax planter. Where is it? Okay, so I've lost it, but that's easy. I can just grab a dev tip. It's probably right in front of me and I'm just not seeing it for whatever reason. So I can just do this and I can open up an inspector and I can see what happened to it. Surround V1. There we go. And we can see that its parent is a root. So of course it should show up here. There it is. Surround V1. I just didn't see it. So, okay. So here is our flax bed. So we can see that the flax is visible and the weeds are visible. Now we can make the flax immediately invisible by deactivating just the flax group. So you can see that all the flax is gone. Same thing with the seeds. That's the seed right over there. We can deactivate that and it disappears and the same thing with the weeds. Okay, so now we're left with an empty bed. So this is not exactly what we want to do. We do want these to be active all the time, but invisible. So let's start with the flax and look at it. So this is active, inactive, active. Now, in order to make the flax plants gradually appear, we need to modify their materials. So there are two materials. There is the tune material on the stalk and the tune material on the flower. So I think that what I'm going to do is I'm going to take that material and put it into a separate object under flax. And the reason that I'm going to do that is that then I can take that object, apply it to all the flax plants and the corresponding one for the flower, and then I can just refer to it. I'll show you what I mean. So I'm going to create a material, create a new material. It's going to be the tune material. And basically I'm going to copy, first of all, let's see what we have. So for the stalk, I'm going to pull out the main texture and the normal map. Did we have anything else? Yeah, we needed to change this to alpha. Z-Rite was off, which I honestly don't think we care about. And that's it. And what I'm going to do is I'm going to create a child of flax. And I'm just going to call this materials. And I'm going, okay, that's, well, that was dumb. Okay, I didn't want to do that. What I wanted to do was attach component assets, materials, tune material. There we go. And now the main texture, the normal map, and change this to alpha. Okay, I didn't actually need that. Okay. So that is the material for, actually, instead of calling this materials, let's call this stalk material. And I will create another object. And I'm going to call this flower material. I think I could probably just have another component in the same object. The problem is that then, you know, I would sort of want to rename this material. And really putting it in its own object lets me do that. So here's the flower material going to attach. Actually, you know what? Instead of doing that, I'll cancel out of this. Let me delete that. And then the stalk material I will just duplicate. So now I have the same thing except I can replace everything. So this is the flower, flower material. And I remember that there was no texture, there was no normal map. It was just the color. So let's take a look at what the color was. So I can set that to the side, go back to the flower material, copy the color in, color, color. Okay. So now what I can do is I can take this material, see now I have it, and I can go into the flower itself and drop it in. So you can see it says tune material on flower material. So I can do that for all the flowers. And again, the only reason that I'm doing this is for convenience. So that I have a particular material to modify instead of just modifying arbitrarily one of these. And the other thing, though, is I think that if this material, I'm not sure, but I think if this material is not stored in an object itself, it basically goes to the world assets object. And that means that if I modify it, I'm modifying the world's copy of this, it means that everything that uses that can get modified, which is not what we want, because if you plant 10 of these, obviously they're all going to be doing different things. So that's why I am doing this, or at least one of the reasons. Okay. Throw that ball away, go to the stock material. Now this is my stock. I'm just going to copy it in. Okay. So I think those are all the stocks. And I can test that by just going into, say, the stock material and then modifying the alpha here. So if I go into here and I change the alpha, they should all disappear, right? Leaving just the flowers, of course. Okay. Let me set that back to one. So we need to write some logics that will fade this in from zero to one. And in fact, what we want to do is make sure that in the beginning, these are set to zero. So the way we're going to do that is under flags. What I'm going to do is I'm going to create an object and I'm going to call it logics. So the idea here is that I want to create a utility, kind of like a utility function, even though there aren't any functions in logics. But it's more like, it's not even a call. It's called a dynamic impulse. And you basically give it a name, and then you can direct an impulse of that name to a particular object. So in essence, it's kind of like a call, except not really. So I'll show you what I mean. So under logics, I'm going to create another child and I'm going to call this one alpha. So now let me release my dev tool tip, go to my inventory, and pull out the logics tool tip. And here's what we're going to do. I'm going to open a node browser. So now this is where I can add nodes. So under flow, we're going to use a dynamic impulse receiver with value, and we're going to have it take two floats. Float two. Okay, so let's stick it here. And the name of this is alpha. Can I just pull it from here? Yes. Okay, so this is the name of the sort of function call, just alpha. Now a lot of people use blueprints or red prints, which sort of slap these nodes onto a nice plane or a nice grid. I personally use red prints, but I thought I wouldn't use that, just to show that you can do this without red prints. Certainly red prints makes organizing things a little bit easier because it looks nicer, but this is good enough. So the idea is that you would call alpha with two floats. And here's what I'm going to do with the floats. Let's go to, sometimes it's hard to remember where these things are. Is it math? Yeah, it's math. Constant lurp. So what constant lurp allows you to do is it takes a target and a speed, and it outputs some number. So let's demonstrate this. I'll just display this. Here is the target, and here is the speed. So I'm going to show you what a speed of 0.1 looks like. Now I'm going to change the target and watch the output value. So I'm going to change the target to 5. So you see how it increases? So it's increasing basically at 0.1 per second. At least that's what it looks like to me, right? 1.2, 1.3, 1.4, 1. That's about a second. So it's going up at 0.1 numbers per second, and it's going to go all the way up to 5. Now I can change it right in the middle back down to 0, and it'll start counting down. So essentially the constant lurp sort of keeps in mind its current target, or it's actually its current value. And then when its target changes, it immediately starts moving towards that target at the particular speed. So this is what we're going to use to modify the alpha, right? Because we can just change the alpha from 0 to 1, and it'll start fading in, and we can adjust the speed accordingly. The two floats that we're going to give it are the target and the speed. The reason that we want to give it a speed is that if we do something like 9E9, so that's basically 9 billion, if we then change the target to 0, it pretty much immediately goes to 0 with pretty much no delay, because it's going at 9 billion numbers per second, which equates to basically nanoseconds. In other words, no time at all. So what we can do is we can take this constant lurp, and what we're going to have to do is store the target and the speed. So the way to do that is we go to variables, and we go to storage, and we pull out a float 2, and then we go to actions, and we go to write. So here is write. So write takes the impulse, and it takes the value and a pointer to the location that we want to write to. So the reason that we have to do this is that the value is actually lost once the impulse is finished. So the impulse is finished. This impulse right over here is finished after write completes, which means that after write completes, it will have written that value into float 2. So we've saved it. And that way we can do something else with the next impulse, and this value again remains. Now to split the float 2 up, we have to go to not math, operators. We have to go to operators, and then there's unpack x, y. Unpack x, y simply unpacks the float 2 into 2 floats, top and bottom. So the final step now is to actually convert this into a color because what we want to do is drive the stock material and the flower material at the same time. And to do that we're going to drive the color here. So if I grab color and then I secondary click, you're going to see this enormous interface card. And that interface card is basically all of the fields in the tune material. The only field that we're really interested in is color. So that's the thing that we're going to drive. And in fact we're going to also drive the flower material, but let's first only work with the stock material. So what we need to do is we need to drive it with a color that is 111 and then whatever alpha is coming out of the constant lerp. So to do that, it's not going to be pack x, y, z, w, because even though those are four values, x, y, z, w is for quaternions, in other words rotations. So you don't do that. Instead there's pack RGBA. That is a color and you can see that the colors of color actually match. So for the stocks we want 111, right? Because the texture actually gives you the color. So 111 and an alpha of whatever this is. So I do this and then I can pull this out and give it a 1. Give it a 1 and then it's just 111. And then I can drive the color. Oops. And then I can drive the color. And there you go. Now the stocks have disappeared because of course the current value of this register is 00. What I could do is I can just create another right node and right to that float and then I can manually pulse the impulse and I can write say an alpha of 1 and a speed of, well let's just see what .1 does. And then if I pulse it, see, they appeared. It's a bit slow. Now if we just want them to completely disappear, we can replace the speed with 9E9 and the alpha value with 0 and go. And there it is. So with this we can actually start to fine tune what we want to see. So instead of .1, let's suppose we want it to fade in over a period of 3 seconds so it would be .33 say. Okay. Maybe we want it a little slower and make it .25. So let's pulse 0 and then it'll fade out over a period of 4 seconds. That is probably, I think .3 is just fine. So we do this. Oops, pulse. And I think that's fine. Okay. So the other thing that we need to do is handle the flowers also. So if we look at the flower material, we can see that the color is this particular color and the alpha is 1. So again, we can use our pack RGBA. We're going to use the same alpha because we want them to fade in and out the same way but use these values. So the R would be this. G is .29 and B is .54. And now I'm going to pull out the color, which gives me again this huge interface card. We're only interested in the color. Okay. So now everything should be wired in. So what I'm going to do is I'm going to make them all disappear. So 0 and 999. Okay. They all disappeared. And now let's suppose we want them to appear now. So we hit pulse and there we go. They appear. Okay. So now to store all of this code into alpha, what we do is we grab alpha and then we secondary. No, we don't secondary click. We grab alpha and then we primary click and we choose set packing root. So now we can see on the tool it says alpha is the pack root, which means that when we pack this, in other words, I point at this and I hit secondary. Okay. Now it only packs up to, it packs everything that's connected except for these pointers. And I think there's a mode that you can set, which will even pack, which will even go through pointers, but you just have to pack those things separately. Okay. That's it. That's alpha. Now in order to actually send sort of, it's kind of like a message to send that message. What we do is we go to dynamic impulse trigger with value and it's going to be a float too. So let me spawn that with manual pulse. So what we're doing is we're going to, we are going to send the alpha message to the flag slot. In fact, we can even send it to the logic slot. So let's do that so that it doesn't have to like search down so far. So that's where the message gets directed to. And then we can give it a number. So let's suppose we give it zero and nine E nine. Then if I pulse this, you can see that everything disappears because what happened is we sent the alpha message to the logic slot. There was nothing in the logic slot. So it went to all of its children. It looked in alpha and it saw, oh, there is actually something that can receive this message with this particular type. And it went ahead and process that message. Now if we want the flowers to appear again, let's just do point five because I'm impatient and we pulse it. There they appeared. So that's how we're going to sort of like trigger this in the game. Now we can do the same thing for the weeds. It's just a matter of doing exactly the same thing, creating the material, dragging the material, bringing, copying the material out of the weed into the weed material and then setting up the logics with pretty much exactly the same code except we're only driving one material and we're driving the weed material instead of the stalk and the flower material and the same thing with the seed. So it's basically more of the same. So let me go ahead and just get rid of this. So I'm going to try to grab all of these and destroy it. Okay. So now the next thing is when we spawn one of these planters, we want to start the game going immediately. So it's like you put a seed on the ground and it immediately turns into a planter with nothing in it. How do we do that? So what you do is I think it's under events. So I think you can probably do something like on duplicate. I think. You can also do on start, but it's so if I look at on start, it takes an only host and it gives you an impulse and the idea is that whatever object contains this is going to create an impulse when the object appears in the world. The problem is it also creates an impulse when another user joins you in the world. That's my understanding of this. So in other words, that's not good because then if a new user joins the world, the minigame restarts for you, which isn't any good. So I think we want on duplicate. There's also on a loaded and again, I'm not sure whether it should be on loaded or on duplicate. I've used on duplicate before, so I'm going to stick with that. So the idea behind on duplicate is that if the object that it's a part of was duplicated, then on duplicate fires. And what that should do is it should start the game off. So on duplicate and what we're going to do is we're going to put that in the surround. In fact, let me rename this now to v2. I'm going to create a child and I'm going to call it Logix and this is going to hold all the game logic or the main game logic. Obviously there's some utility functions in here. And under Logix, I'm going to call it just, I don't know, game. Game is fine. Okay, so this will be a part of game. So what we want to happen on duplicate and we're going to modify this in a moment. So you can imagine that on duplicate we want to send a message to the weeds and the seeds and the flax plants that they should all have their alphas set to zero. And you might think, well, you know, why didn't we just set the values of these flax of these things to zero by default? And the answer is, well, I mean, the state is what it is and it's a good idea to just reset everything. So why don't we just do that? So on duplicate, what we want to do is we want to trigger a message with a float to. So there it is. And the message is, of course, alpha. And we want to send it to the flax, Logix. Now, the thing about this is that you can drag out a display and you can see what exactly it is. So sometimes you just might want to leave it there so that you know what you've done. So I'll just leave it there for fun. And we want to set it to zero and immediate. So pretty much 9E9. Why don't I just do like 1E10 for fun? Okay. So that's that. And of course, you know, when we do it with the weeds and the seeds, we also want to chain this. So what happens is after the message is processed, this impulse goes off. So it's not like a message is sent sort of in a different thread. No, it's actually just one continuous loop, one continuous thread. So we start with on duplicate, then we send the message. That goes into the alpha message, which then goes ahead and sets up the lurp. The lurp goes ahead and does its thing. But in the meantime, the impulse is done over there. So we get another impulse over here. So we can demonstrate this by packing this into game. So we need to set the packing root and then pack this up. And then what we can do is, well, let's do it this way. I'm going to save this in my inventory under planter. Okay. So this is surround V2. I'm going to save it. Okay. So now it's saved. You can see in the image that the flax plants are there. That's because the flax plants are here. Now, let me go over here and spawn this out. Ah, okay. Oops. I have to make those things not grabbable. So the problem is that on duplicate didn't actually do anything. However, however, if I go ahead and... Yeah, okay. So this is going to be really hard to demonstrate. So let me go and do some research and see if on duplicate is really what I want. I suspect it is what I want because nobody is actually going to spawn this out of their inventory. It's going to be part of the game world and it literally will be duplicated. So I probably shouldn't even bother. So let me go back to here. Let me de-quip this. Let me equip this. Let me open up the root. So this second surround here is that one over there, which I don't actually want. So I'll just get rid of it. So what I want to try to demonstrate is that when I duplicate this, so that when I duplicate this, the flowers actually disappear. And the problem is that if I just duplicate it, it's going to duplicate it in the same place with these flowers intact. So what I need to do is get rid of all the grabbables. So let me just do that. Okay, so was the ground grabbable too? No, the ground was not grabbable. I don't think any of these are grabbable either. Okay, so all of these are now non-grabbable. So what I'm going to do is I'm going to duplicate this and then I'm going to drag the duplicate away so that you can see that the flax plants aren't actually visible. So I duplicate. Okay, so presumably it's here, but the problem is that it's on top of the existing planter. So if I move this duplicate, which is not grabbable, of course, but I can move it aside. Okay, so there it is. We can see that the new one, that's the duplicate right over here. Which one is it? It's this one, right? Yeah, I mean it's definitely this one. So you can see that the duplicate, the flax plants are gone and that's because it was duplicated, which caused unduplicated to fire, which caused alpha to fire with 0 and 10 E9. So it made the flax plants disappear. So what I'm going to do is I'm going to go off and do the same thing for the weeds and the seeds and then we will come back. Okay, so I think that the next thing that I'm going to do is make it so that we can pick these weeds using either the raycast thing and grip or to pick it up by hand with the grip. So that would apply for the weeds and for the seeds. So again, you should be able to pick any one of these weeds and then that will weed the bed. And you should be able to pick any one of the seeds that will appear on the flowers. I guess I need to copy these seeds over. And that will harvest one of the seeds. So I think that's what we're going to do with Logix next. Okay, so what I did during the break is I added a weed material and Logix to the weeds, a seed material and Logix to the seeds so that we can change the alphas on those. I also went through and made sure that nothing was grabbable. Okay, so what we want to do is to detect a grab on a weed. So here's a weed, there's a weed, there's a weed, and we want to detect a grab on that. So because this is going to be for the weeds, we will start that code in the Logix for the weeds. So we're going to do something like grabbed. So let's see what we can do. So what I can think is that we send a message saying I guess detect grabbed. Maybe I should change this to detect grabbed. And what that will do is it will start a timer because according to the flowchart, which I don't have with me, according to the flowchart, you have a certain amount of time to grab the weeds. And if you don't, then the bed just becomes overgrown with weeds and you can't weed it anymore. But if you pick the weed within the timeout, then that sort of cancels the timeout and picks the weed. And by picking the weed, that will basically set the alpha back to zero so that you don't see the weeds anymore. And then the game will continue on to the next state. So there are a few issues here. So one of the issues is with timers. So if we go to, where does it flow? So there's timer. And what timer actually does is you give it an interval and it outputs a pulse every one of those intervals. So for example, if I were to set this to one, you can see that we're getting an impulse every one. So that's not exactly what we want. So let's just destroy that. There's delay. So this is something closer to what we want. So if I give this two seconds, let me get this out of the way, and give us a manual pulse. So the top one will be an impulse after the delay. The bottom one is an immediate impulse and you can chain nodes together. So it works like this. Pulse there, and two seconds later, pulse over there. So this is great. Unfortunately, you cannot cancel these delays. So in fact, if I pulse this twice, you'll see that this thing goes off twice. So in effect, this is a queued delay. So there's sort of like an internal queue. There's no way to cancel a delay. Well, okay, there is one way to cancel a delay, and that is to put the delay in an object and then delete the object. And that should actually delete any delays that are queued up. So that's one way of doing it. The other way of doing it is if you know that you're not going to be triggering the delay within the delay period, you can just put like an if statement after here and a boolean latch. So this is a boolean latch. It basically stores a boolean and you have a set and you have a reset. You also have a toggle, but if you set it, it goes true. If you reset it, it goes false. And then what you can do is you can say, so if you pick the weed, you set the boolean latch, and then when the delay goes off, so you set the boolean latch and you go off and send a message saying, okay, the weed was picked, but in the meantime, the delay is still going. So what you would do is you would use an if statement here, and if the latch is not set, that means that you haven't picked the weed within the time period. So let's change this to say five seconds. Let's reset the latch. In fact, what we can do is we can tie the reset to the delay. So that way when you pulse this impulse, it resets the latch and then starts the delay. So that sort of starts everything off. This impulse over here represents picking the weed. And when you pick the weed, you'll get an impulse over there. So if you don't pick the weed within five seconds, then this latch will remain false. And when this impulse goes off, the top one is true and the bottom one is false. And it's the bottom one that we're going to want to look at. So I can reset the latch one, two, three, four, five, and then this impulse goes off saying you didn't pick the weed. However, if I do it again and then I pick the weed, you can see that this latch goes to true. This impulse went off, but now this impulse is not going to happen because this latch is true. Now this will work as long as you don't reset it within that delay period. So for example, if I do this and then this and then this again, we'll eventually see that pulse go through. And actually you see two pulses go through because there was the original delay from when we reset the thing and then the second delay from when we reset it the second time. So just keep that in mind. Again, if you want to get around this fact, pack all this into an object that you can delete and that will cancel any delays. You can see there's also updates delays and that is basically instead of seconds, this is a number of updates. I think that is tied to frames, I think. There's also delay with value, which is the same thing as delay, except you can give it a value to output so you can have sort of like a queue of values that go along with the delay. Okay, well, I mean this is part of the logics that we want. So the next thing that we want to do is detect that something has been grabbed. So there's nothing under events. But I think there's like, let's see, is it interaction? Grabbable. So there's is-grabbable-grabbed. So that's not it because I really want it to output an impulse and that would be on-grabbable-grabbed. So here is an impulse that will pulse when a grabbable is grabbed. Now a grabbable is... so if we look at the help text we can see grabbable-igrabbable. So the I means that it's an interface. So it's basically anything that implements the interface grabbable. Now, I don't know what does, except for grabbable. There's a component called grabbable. So let's go to the weeds. Okay, so here is the weed. Let's attach a grabbable component to it. Which weed is that? It's that far one. I want to work with this near one. So let's see which one that is. It's this one. Let me cancel out of that. So I'm going to work with this weed. I'm going to attach... it's, for some reason, it's in transform interaction. Grabbable. Okay, so that makes this weed grabbable. Now, I don't really want to grab it. Well, okay, so if I grab it and move it around, I can always undo grab objects and it will go back to where it was. So there it is. By the way, one of the keys to grabbables actually working is that you have to have a collider somewhere in there. So there it is. There is the mesh collider. It is a mesh collider, which basically means that if you go through the leaves, you can't grab it. You have to grab it on the leaf or maybe the stem. Mesh colliders are a little more complex to compute and detect. So, you know, if you've got, you know, thousands of these maybe go with a box collider instead or something. So under mesh collider, there's a type. So there are things like no collision, static, trigger, and that's sort of like beyond the scope of what you want to deal with. Character collider means that if you walk into it, well, you can't walk into it. You would collide with it. And ignore ray casts is not great because now you can, I don't know if you can actually see this, but my ray is actually going straight through the leaf. So in other words, I can't actually hit it with my ray. I can't hit it physically with my hand. So if you want to do that, that's great, but, you know, I'm not going to do that. Okay, so back to the weed, we have this grabbable. Now, if I grab this grabbable and then hit secondary, I get this interface card and then if I take grabbable and I wire it to on grabbable, it's accepted without any so that means that this actually does implement I grabbable. So whenever it's grabbed, we're going to get an impulse. And I don't know if this is actually going to work, but let's see. Yup, there we go. The impulse went off. The impulse went off again. Let me undo the grab. And I think there was a second grab in there. Okay, now it's in the correct place. So we've got the one weed. We can do that for the other weeds as well. So let's go into this weed, attach a transform interaction grabbable. Let's go ahead and just pull out the interface card for that. And then this top weed let's go and add a transform interaction grabbable and pull out the interface card for that. Now we're going to have a second on grabbable and a third on grabbable. So here are the three grabbables. Let's go ahead and drop these. Now I think I think I can get rid of these interface cards now because these are simply pointers or references to these interface cards. So if I delete it these references remain. Now what happens if I try to quote print this out? Well it just says grabbable. So I think you actually need something like the slot for this. In fact let me just take a look and see if that's possible. I think it's getslot so whatever this is so it gives you which slot it is. Now of course it doesn't tell you which weed it is. To do that I think you have to use like ref IDs or something but anyway that's neither here nor there. The point is that now we have something that will pulse based on whether a weed is grabbed. Now let's go into flow and what we can do is I'm going to put an intermediate impulse in here and then I'm going to wire all the impulses in. So this is basically if any of these impulses go off this impulse will go off. So to demonstrate that let's pick say this weed so that went off let's pick this other weed here that one went off let me undo the grabs okay great so this is our grabbing impulse so we know that we want to put that through the Boolean latches set. So that tells us that something has been grabbed so I don't need this anymore okay what goes into the reset would be a dynamic impulse receiver I'm not sure whether I want it to receive a value but let's just use the dynamic receiver without a value so there are no parameters to this and we will call it detect grab so when you send a message detect grab to weeds it will start the 5 second timer and let you grab the weed now what happens what would be bad is if you grab the weed and then grab it again so what would happen is if you send the 5 second delay starts you grab the weed great so this impulse goes off and effectively the delay is cancelled now if you grab it again what's going to happen is this impulse goes off again so I don't think you want that what you want is that when you send detect grab you can only grab this once and if you don't send a text grab you can't send another impulse again so in other words when this is reset we only want to accept this we only want to accept this impulse if this latch is false so that means that we are going to have to put an if in here we're going to have to wire this up to here let me see if I can make this a little nicer ok that's a little nicer and then if and only if the latch is false in other words it's reset we let the impulse through so once the impulse goes through that sets the latch to true and then this if node will just sort of send these impulses you know into the ether so that you don't get this impulse a second time ok so that's great so now the the last thing is the last thing is I guess I don't need this anymore so now we have these two impulses this impulse here says the thing was grabbed this impulse here says the thing was not grabbed in time ok well let's send those as a message ok so let us call the message weed grabbed so that we know that it was the weed that was grabbed ok and we want to send it to the main game logics so that is right here so I'm going to grab the slot put it over there this bottom one is exclude disabled so if I actually went into say logics and I change this to inactive or maybe game and change this to inactive then the message would not go to that inactive node but we're not going to be doing that so so this is weed grabbed and then we want another one here so it's the bottom of the if and we want to call it say weed grab time out and we want to send it to the same object I guess that's it so that is our grab detection so let me go ahead and set the packing root node set the packing root to detect grabbed so there it is detect grabbed and now I'm going to pack it and there we go so so that's weed and then of course we need to do the same thing for seeds so for that I'm going to go into the logics and I'm going to duplicate detect grabbed and then I'm going to grab it and drag it into the second logics so for this now I'm going to set the packing root there and unpack it so here we're only going to need well actually it's for the seeds right how many grabables are we going to need 1, 2, 3, 4, 5, 6, 7, 8 8 of them but right now I've only got one seed obviously I need to fix that so so this grabable right now right here is for a weed so I'm going to delete that and then I'm going to go to the seed ok we need to attach a grabable to this transform interaction grabable ok so now the seed is grabable I can take the grabable and direct it to the node ok so now we could send the detect grab message to the seeds and we need to change the names of these messages so instead of weed grabbed it's just going to be seed grabbed and then instead of weed grab timeout it's just going to be seed grab timeout and there we go I will double check and make sure that I've set the packing root properly to the seeds and I'm going to pack this and there we go now this seed is grab detect enabled so I just need to do that for all you know for the other seeds so let's see ok so now what we need to do is talk about the fact that the seed and the weeds are now grabable in other words I can still grab them which is a problem because I can grab them even when I'm not waiting for them to be grabbed so under each weed we can see that here is the grabable interface now if I disable grabable on all the weeds ok now I cannot grab the weed and in fact un-grabable un-grab is not going to is not going to do anything and I can show you that by opening up detect grabbed starting it up let's see yeah ok so let me output a display here and a display here ok so the top one is weed grabbed message was sent and this one is weed grabbed timeout message was sent ok so when I started off now when I try to grab it you can see that nothing happens and in fact it times out so that is the correct behavior but the problem is that I had to manually disable the grabable how do I do that programmatically well right now there is no way to access individual components in slots because we don't have collections and collections would be things like lists and sets and things so you know you could theoretically get the list of components for a slot and then look for the grabable in it we don't have components yet so that is not going to happen but what you can do is use a dynamic variable so let me show you what I mean let me go into weeds attach a component data dynamic and add a dynamic variable space now I don't want to go into all the nuances of what dynamic variables are and what spaces are you can look at probable primes youtube tutorial videos for that I'm going to call the space name flax now I'm going to attach another component dynamic variable and you're going to see a little hitch because it has to load all of these things in and it's going to be a boolean and we're going to call it grabable finally we are going to add a dynamic value variable driver that is boolean and what this means is it's going to take a variable and it's going to drive a target what target do we want to drive clearly the enable of the grabable so I need to open up a second inspector so let me dequip this equip this let's just go ahead and open up another inspector and go up a few okay we're on weeds and we want to go to this weed here so here's grabable now dequip this and re-equip my logics tool so now I'm going to take the enabled field and I'm going to put it in the target so you can see that the enable field turned pink that means that it is driven by something unfortunately right now you can't find out what it is driven by that's an enhancement request so if I now change the value see you can see that changing the value of this dynamic variable changes the value of that grabable well now all we have to do is add more drivers on the same variable for all of the weed things so there is that one and there is that one so now when I change the value of grabable all of the weeds either become grabable or stop becoming grabable right right so that's nice how do we how do we put that into practice what are we going to use this for well we'll start off with it not grabable so I can't grab these weeds this is a good thing I don't want to be able to grab these weeds so what I can do is I can go now back into detect grabbed set the packing root now what I want to do is obviously when I want to detect grab the first thing I want to do is grabable grabbed so what I'm going to do is insert into here where is it variables right dynamic variable and I'm going to write a Boolean so I'm going to insert that into the initialization flow the name is going to be flax slash grabable and I did make a mistake under weeds this isn't supposed to be grabable this is supposed to be flax slash grabable so that it specifies that it is in the flax space because otherwise what if you're sort of searching through the world for well maybe not searching but you are let me see how does this work I think I think what happens if you try to set a variable at a basically at the bottom level it will start going up in in the parent chain in the parent hierarchy looking for a variable that is stored in that space so here we have a space called flax that's stored in weeds so if we're anywhere below that hierarchy and we look for or read or write grabable in the flax space then we will just end up in the flax space here and we will not go any higher I'm probably not explaining that very well again look at probable primes tutorials for that so there we go okay so now we have a slot so if you leave it alone then by default it is the slot is wherever it is so in this particular case it would be because this is logics it would be you know somewhere under the logics node probably in the detect grab nodes so again it will start searching up through the parent hierarchy for the flax space and then it will look for the grabable variable in the flax space I don't have to do that because I know that it's in weeds right so I can just say weeds put that in there then it doesn't have to do any search so you know it's a kind of a tiny optimization and what we want to do is we want to write true so basically when we send the detect grabbed message the first thing that we're going to do is make it grabable and so that sort of implies that when we grab the weed or when we time out grabbing the weed we want to make it ungrabable because we're done with the grabber so in order to do that you can't you can't do that off of this dynamic impulse you can't do it off of this output because what will happen is the weed grabbed message will be sent it will be processed wherever it is and then when it's done being processed then this impulse will go off so what we really want to do is the moment it's grabbed we want to make it ungrabable so why don't we just do that also okay so that's not true if it's grabbed and we're about to send the message then we want to make it ungrabable if it times out we're still grabable we want to make it ungrabable so let's just do that okay so here I'm going to insert set flax grabable to false in weeds okay and we want to do the same thing for here so I'm going to insert this why did that happen okay flax grabable stick it back here and weeds slot okay now to save myself having all these arrows I could hook this up to there this up to there I could hook this up to there I could do the same thing with these strings because they're the same string the reality is it doesn't really matter and you know you would have ribbons that sort of go actually maybe for the strings that would make sense so I can just sort of stick the strings in the back something like that maybe so okay so what we've done is we have now made it so that when you detect grab it turns on the grabable and then when we're done with that we turn off the grabable let me pack this and save the session okay so we can save our progress okay and we would do the same thing with the weeds so I guess what I would do is I would just delete this detect grabbed and then replace it again or copy it over again because I've added some useful logic the other thing is that when we start the game we want to initialize that grabable to not grabable so let me go into the game set the packing root and look at it and you can see that as part of so on duplicate is when the game starts so you can see that what I've done is I've set the alphas immediately to zero for the flax, the weeds, and the seeds and what I also want to do is make them un-grabable so I'm going to write a dynamic variable bool so after this is done I want to write flax grabable false in weeds and yes again I can take it from this slot well actually no I can't because this slot is logics this slot is weeds itself so that goes there and just for like maybe documentation purposes oops I can do this so that I know what I'm pointing to I'm pointing to the slot weeds and I would do the same thing for the seeds so let me do this and now this time it's also going to be flax grabable now you may ask yourself well these are the same names but the thing is that they are on different objects that have a space on them so here is the space for weeds so if I'm looking for a variable in the flax space I never go any higher than the declaration of the space so that means that if I write to flax variable in weeds it will go to it will stop its search at the space which is on weeds if I do the same thing for seeds so attach data dynamic space flax and I search for the grabable variable name in seeds again it's going to stop at this space it's not going to go any higher so that is a good thing so let me go to seeds grab its slot and put it in there and again so now the seeds are not grabable and the weeds are not grabable of course again I have to put a seed on every flower I have to go into detect I have to go into detect grabbed I have to do the on grabbed for all the seeds which I can do offline so that is the grabable so let me do that and we'll take a little break now so the next thing the next utility that I want to write is the thing that makes some announcement appear and float up into the air and disappear so what we're going to need to do is create an object to hold that text so let's just make this the announce and underneath it we're going to put some text so let me create new text um let me go ahead and open an inspector so that I can look at it and drop it into announce this is the outline this is the text right over here so you can imagine that it would be something like plus one flax seed something like this and then the idea is that it would appear and then it would float up into the air and then disappear so I guess we sort of want to start it from here and it's going to be positioned roughly here in the middle we're going to change this to minus 180 so the unfortunate thing is that it's only really legible if you're standing right over here because if you're standing on the other side it's going to be reversed you can maybe fix that by either making another text that floats up along with this one or you know making it around a box so that there are four pieces of text you could maybe make it so that you can detect a person who did the grabbing and then make this face that person but you know right now I'm just going to make the make the announcement okay so here is this outline and apparently it's going to start at y equals one I guess that's good and then we're going to make it float upwards in addition we need to change its alpha now if we look at where is the color right over here here's the color so if I reduce its alpha it disappears okay so that's how we're going to change it so obviously again we're going to have to drive it should I make this bigger yeah that's nice okay so let's go ahead and create some logics for this we'll just call this logics and we will create a child and we'll call it announce announce so we can start by doing what well we can certainly start by copying actually the alpha for the logics so let me just make a copy of that so instead of this object we'll start with this object okay so now we have something I can change the alpha of an object and of course we now want to point to the color of this text so we simply go here we grab the interface card for it we look for the color item and we point to color and there we go so what's in here one okay so that's the current speed alpha so that's going to be able to modify the alpha of the text we also want to modify the y location of the text at the same time so what we are going to do is use another constant lerp and we can decide what to do with the speed let's just let's just use the same speed for now and what we're going to do is we want it to go from okay so we want a few things out of this actually so yeah we're going to want a few things so instead of a dynamic impulse receiver that receives a float 2 which would be the alpha and the speed we kind of know what that's going to be so instead of that we're going to use dynamic impulse receiver a string and the string is going to be the thing that we put in the announcement so let's remove this let's remove the float remove let me just make a copy of the right and go into variables storage and grab a string register and instead of alpha it's going to be announced okay so the idea here is that the first thing we're going to want to do is the first thing we're going to want to do is I think reset yeah we're going to want to reset the Y to 0 to 1 which is right over here so when we send a message saying announce we send it with the announcement that we want to put in and we also want to write to a float 0 1 actually you know what actually because this is going to be lerped that is now a verb we'll use a float 2 let's get rid of this re-point it to this okay so we want it to go to 1 immediately okay so what we can do with that is um let me copy the XY unpack put it here let's um let's delete that I'll deal with the color later right now we're dealing with the Y so this is now going to be a constant lerp we're going to want to put another right here and this is going to be how to how to make this float up so we're going to want it to float up to let's see where 4 that's a little too high 2 that's kind of nice sure to 2 okay so we want this to float up to 2 and we want it to take say 1 second okay so now when we pulse this here uh that will reset the position to 1 and then when we pulse here uh we need to drive we need to drive the position so let me pull out an interface card there's the position right there we need to reset it with xyz so we'll go to operators pack xyz like this we know that the Y is going to be the thing we want to drive and the other values are 0 so I can just leave those alone because they're 0 by default and then drive the position okay so now when we pulse this it floats up um was that too fast reset pulse reset oh yeah we want to go a little slower maybe like this okay that's maybe too slow sure I like that now while we're doing that we also want to change the alpha um so at first so let me put in another right here uh let's put it up here let me move these over and this is where a red print would actually be useful because it has a tool where you can uh drag where you can sort of uh uh box select a whole bunch of nodes and then move them all at once which is kind of nice so I'm going to take another float to register here and um we are going to initialize it to well first of all the speed has to be 1 e10 because we want it to be pretty much immediate and the alpha value we want to be 1 okay uh and then we want to unpack it do a constant lurp and you know etc etc um and that's our color and when we're actually when we're actually going we want it to fade out to zero also in with 0.7 I think alright let's see how that works so we're going to reset and now we're going to pulse reset and pulse good enough now we just have to modify the uh message itself so we can again do that with driving the text so easily done string to text okay so there's nothing here because of course we don't have anything in the register so what I could do is I could just temporarily put a write over here that's manual and I can say you know something like I don't know hello world so then if I pulse this that's going to appear that would be as if we wrote the message that way oh and then of course if I pulse it we get nothing here so um the way I can fix that is to do that oops um do that why isn't it going? oh right because um ah yes right so the thing is that once we do this immediate set we need to then proceed to make it float upwards so that would look like this see so um why doesn't it set properly now um when I pulse this that sends an impulse to this write which should immediately set the y to 1 and the alpha to 1 so why is it not doing that let me pulse this here okay so all that did was null out the text so I'm not really sure now why it's not working um hmm why isn't it working well let's see if I send an impulse here it goes into here and we should at least see the y value go down to here oh I know why okay so this is a consequence of the constant LURPs containing a value so remember that it contains a current value and a target so the problem is that the current value is right up there so if I tell it to go to 1 immediately yeah if I tell it to go to 1 immediately these impulses continue and then all of a sudden I'm going to tell it to go to 2 at speed 0.7 so the um so on the next sort of tick of the clock the constant LURP looks at its inputs and it sees 2 and then it realizes it's already at 2 so it doesn't do anything so what I need to do is I need to put in a 1 update delay in here that 1 update delay will allow the constant LURPs to read their inputs um because they read their inputs on every update so that will cause the constant LURP to accept these values so I hope that made sense so let's go to flow updates delay and what we want to do is we want to put the delay right say here let me move that ribbon so it's in here and then we go to here and the number of updates that we delay is just 1 that will give the constant LURPs the opportunity to read their inputs and then do this thing so let's see that happen now there we go ok so it was important to understand exactly how constant LURP works and then it's got an output which is kind of like a register and it reads its inputs but it only reads its inputs on the update clock so in other words the tick of I guess the graphics frames or something like that because we didn't give it an opportunity to tick constant LURP didn't read any of these inputs and instead read these inputs so it appeared as though it didn't do anything ok so now what I can do is I can get rid of this temporary write I can get rid of this pulse and now I can set the packing root and update and pack now there's one thing that I just want to point out there's one thing that I want to point out is that the end the end is that when you send this message what happens is the flow of execution goes through here goes through here up here, up here and then it basically it would continue down here but there's nothing here so what happens is the message is done and it returns to where you sent it one update later this impulse goes off and it goes through here and then it would continue over here except we've got nothing else to do it's important to realize that when you send this message it returns pretty much immediately in other words it returns when this thing starts to move so if you're expecting to do more stuff after you send this message well you're going to have to wait some amount of time before all of these lurps are done and because we're not sending a message when those lurps are done there really isn't any way of telling when those lurps are done so you would have to monitor the lurp for their final positions but again we're just doing this quick and dirty so let's just pack this pack this pack this and pack this and again we had to pack all of those because there were all those reference pointers okay so we now have we now have a utility to announce something apparently hello world by default that's okay alright next thing I think we're going to do is actually tackle the game logic okay so let's go ahead and start implementing the game logic so what I can do is go ahead and unpack the game logic that we have right now and we can see that what we've done is we've basically reset things the only thing we haven't reset is the outline and I don't actually have a reset for that and I may want to do that but for now the outline is invisible so far it'll be fine okay so we've done our reset so here what we want to do in the initial state is we just want to wait for a certain period of time I'm going to set it to 5 seconds just to speed things up but in the real game it I think is like 30 seconds or something and then we want the flax plants to slowly appear and then we want to wait a certain amount of time again and then we want the weeds to appear so we could do that simply by we could do that simply by chaining all of those things using this impulse but I don't want to do that now you can see that I've numbered all of these states from 0 all the way down to 15 there is actually supposed to be a 16th state over here which is kind of the end state and we're going to make a little state machine so the idea is that when we're in a state well here let me show you let's just start off by giving a let's see it's under below I think it's it's an impulse demultiplexer nope multiplexer okay so what the impulse multiplexer does is it takes an impulse in and based on this input over here outputs the impulse on that output so you can have a whole lot of outputs this one tells you how many outputs there are so this would be 0, 1, 2, 3 and 4 so if you put in 0, 1, 2, 3, or 4 in here you'd get that impulse out over here so the idea is that we can simply hook this into here we can get a variable an integer register and put that say here say here and that input and that integer will tell us where we are in the state diagram so initially we should be at 0 so what I'm gonna do is oops whoa what I'm gonna do is I'm going to go to actions go to write and I'm going to set this up to write a 0 into the integer because the default of the input is 0 so we've done all this initialization we've set up the state to 0 and now we are here in the impulse multiplexer now of course we're gonna need from 0 to 16 so I mean there's gonna be a lot of these how many is that well let's find out 19 that's a bit too many 17 yeah that would be 0 through 16 17 right yes okay great now unfortunately there is a bug that when you expand these nodes it looks like the ribbon breaks and of course you can't rewrite it because it's already there so what I typically do is I just delete the ribbon and add the ribbon again the ribbon is actually there it's just that graphically it appears it appears in its original location so okay so during state 0 we want to do something in this case we don't do anything and then we want to wait on the sum condition now the sum condition for state 0 here is a period of time has elapsed so that's easy enough to do what we're gonna do is we're gonna grab a delay node it's under flow delay and we're gonna make it 5 seconds and when we're done with that delay we have to decide where to go next what state to go to next I'm gonna go to state 1 next so rather than write a 1 into the state integer what I'm gonna do is I'm gonna go to actions and use the plus plus node right because we're on 0 and whoops and all we want to do is increment the state so I need to put this over here and now to make things neat I'm just going to apply some of these you can call them staples technically they're relays so they just relay their input to their output but I kind of like calling them staples because it's like you've got this wire here and you're stapling it you know along the wall almost so here's another staple for example so what this will do is it will increment the state and then whatever this does well whatever this does is we need to go back to the beginning right so I'm gonna do that and I'm gonna put some more staples in here maybe I'll put a staple up here and another one say here does that look okay sure so the effect here is that when we're in state 0 we delay 5 seconds increment and then go back into the impulse multiplexer which now goes into here which is number 1 so what do we do in number 1 what is the action that we take well the action that we take is to fade in the flax so let's do that and we know we can do that with the alpha message so I'm gonna need a dynamic impulse trigger I'm gonna put it over here cause I know that strings are big and rather than run alpha all the way out from there I'm just gonna stick it in over here see how big these end up being okay so the slot that we're going to apply the slot that we're gonna do for alpha is the flax slot and in fact we want to go to logics we could go to flax but then it would have to search through all of its children in order to find the thing that accepts the message so we're just going to go straight to the logics node okay and again what I could do is you know just sort of put this here somewhere the problem is that it's not really out of the way I guess that's okay alright and what do we want well we want alpha to go from zero to one in a period of say two seconds sure and so that's the action that we took and now we need to wait for some event to happen now in this case we're going to wait for a timeout to happen so in other words it's the same thing as the delay and then of course we can see that after the delay we increment we increment the state again so interestingly that's the same as this so I could just take this impulse and plug it directly into the delay over here should I do that no let's not do that just for the sake of not having so many ribbons going to the same place let's just do this and then of course we're going to need a plus plus over here so after the delay we're going to want to plus plus the state and then we're going to want to go back to our multiplexer okay so that's state number one state number two we do the same thing with the weeds so the action that we take is to let's just say alpha up the weeds so we're going to take one of these things it's going to be alpha so I can do that um it's weeds so I'll go to the weeds logic and grab the slot so now we're sending the alpha message to the weeds and we want it to go to alpha one sure with the same speed two okay now after that we are waiting for some conditions to happen okay one of the conditions is for a timeout to happen another condition is for us to grab the weed so what we want to do here is also after we send after we get the alpha going um we also want to dynamic impulse trigger I need to leave space for the string and what was it called it was called like um detect grab so then we want to set up the grab detection on the weeds right so it's in here I did call the object detect grabbed but I think that I called the message detect grab so we're going to do that so that starts off the detect grab okay now we're going to receive a message back from here so we're either going to get a weed grabbed message which means that we're going to go along this path to state 3 or we're going to get a weed grab timed out I'm going to double check these messages uh weed grab timed out and if we get that message we should go to state 7 okay so to do that we're going to have a dynamic impulse receiver um I'm going to put it right over here so the first one could be weed grabbed and I'm certain about that message or we could receive a message that is um weed I think it's weed grab timed out something like that so what I'm going to do is I'm going to pack all this lots of fragments any other fragments no um and then I'm going to go to uh the weeds detect grabbed detect grabbed I don't know what's going on set packing root okay ah weed grabbed and weed grab time out and the message was detect grab okay so I will pack that any more fragments no let's unpack the game weed grabbed weed grabbed time out okay so um so we send a message detect so we send the detect grab message and then we don't do anything after that we're just sitting there doing nothing we're going to get one of these two messages weed grabbed or weed grab time out if we get weed grabbed what we want to do is set the alpha to zero immediately so we're going to want to set the alpha to zero immediately uh sure let's just go ahead and grab the alpha string from here um and it's going to be the same as this which is the weed right because this is weeds let me just stick that here so that's weeds so I'm going to simply grab this and stick it over here and sort of put the staple in the back and we are going to want to set the alpha to zero immediately so in other words make it disappear okay so there's that and maybe we even want to send an announcement so maybe we want to send an announcement which is a trigger with value string get out here and we want to announce and there's the logics that handles announce so we'll just send the message to that slot and we're just going to say weeded just to sort of acknowledge that you did something okay and after we set that up we want to go to uh so we're on weeded so we want to go to the next state which is three so because we're already on state two we can just use plus plus to go right to state three um let me put another staple up here and then drag that up here I can probably just put another staple up here and then uh yeah let's go here and put that staple up there okay so that's what happens when we weed when we don't weed what happens is the weeds are going to stay there so we don't have to change the alpha but we do need to go to state seven so in this case we are going to need a right node and we're going to write a seven um two here um let me grab another staple let's bring this all the way out to here staple this down bring this out to here and run run this ribbon up to there okay and let me go ahead and pack all of this um it's interesting that this ribbon is broken I wonder why um yeah that's the one that went into the multiplexer okay and what I'm going to do is I'm going to save the session and now I'm going to unpack again alright you can sort of see that this thing is quite large and I'm kind of running out of space almost um so I may extend it a little bit downwards or I may just extend it I'll probably just extend it even further out here in this space um okay so what have we done we've gone through we've now handled the case where we weed and we've handled the case where we time out so let's go to state three in state three all we're doing is we are doing pretty much exactly the same thing as state one almost um in state one we set the alpha to one of course if we do that again it doesn't matter because we're already at one um and then we delayed five seconds and then we incremented the state which is exactly what we want to do in state three so um where is state two state two broke for some reason this is state two or maybe I never put that ribbon in in the first place okay so that's state two uh so state three does pretty much exactly the same as state one which means that we put the staple here and pipe it directly into there that is state three which then goes into state four state four does exactly the same thing as state two if you weed increment the state if you don't weed go to state seven so that's easy enough to take care of I'll add another staple and there we go okay so now if we're in state five if we basically wait for a period of time and then this says ready to harvest and that um what that actually does is it is it's supposed to make uh the the planter disappear and this flax appear um so so for state five for state five we are basically doing nothing except delaying can actually go from zero one two three four five and just go straight into the delay because all we're doing is we're waiting for five seconds okay and then during state six what we need to do is we need to make the flax planter disappear and the flax appear so we didn't add the flax to our uh to our minigame yet so we need to do that um and I will take a break and do that myself um add the alpha logics to it because obviously we want it to be initially invisible and then just to become a visible um so I'll do that offline okay so um what I've done is I've taken the flax bundle I've extracted the materials of course there were two one for the rope and one for the you know watermelon thing um I hooked up the alpha logics to it I hooked up the tech grabbed to it uh so we should be good to go um I've opened up the game logic but now the big flax bundle is kind of in the way um so I can fix that easily by just uh setting the dynamic variable to oops to actually no I can't can I um I have to set its uh transparency right so okay so what I'm gonna do is I am going to break this line right here and you can see that in the initialization I've also set the uh alpha of the flax bundle to zero and I've also set its uh grab ability to false uh and then I'm just going to pulse here and that basically makes everything disappear okay so now I can put that back and now I can see uh pretty much everything so um um let me put this away grab this deselect all so that I don't get those outlines put this back on my shelf okay here we go um so where we where we left off is uh I was going to put the the flax bundle in here uh and then now we can go ahead and figure out what should happen um in let's see phase five let's see zero one two three four five so in phase five all we did was delay that goes to phase six which is uh ready to harvest um so in the actual game what happens is that the planter just sits there and then you get an option that says harvest so what I'm going to do is I'm just going to make the planter the the flax bed disappear and the flax bundle appear so that is going to happen right here so in order to do that um let's see what do I need to do so we have this surround here we also have the ground we have the stake rows and we have um well I guess the flax and the weeds and the seeds and everything what I'm going to do is I'm going to create an object that is just bed and then I'm going to put all these items in the bed even the flax and the weeds and the seeds so that all I have left is basically the logics uh the announce object the flax bundle in the bed now what I can do is I can activate or deactivate the bed and you can see that it basically disappears so the first thing that I want to do here is deactivate the bed so we can do that so unlike grabbable um active does have a logics node associated with it so it's under slots and it's just set slot active self so right here I can grab the bed slot and I can set it to false so that will deactivate the bed slot um and now for the flax bundle I want to alpha it up so uh let's see so again this is alpha I'm going to put alpha like right over here sort of centrally located okay um there's the logics for the flax bundle so that goes there and I'm going to use the same alpha and timing okay so um and once I do that I want to detect grab on the flax bundle so I guess I'm just going to use reuse that string um detect grab on the flax bundle so again um actually I can just use this logics here because this should be the same thing so I set the alpha I set the uh grab um and then um so okay so the other thing that I did um for the flax bundle is I copied the grab detector but I disconnected the time out because we're just going to sit here and wait for the flax to be grabbed so um it's flax grabbed flax grabbed and when the flax is grabbed uh we want to set its alpha let's push that back a little bit we want to set its alpha um and it's pretty much going to be this again to invisible and we want to let's go all the way say here announce and we of course need to use the same slot that's the announce object and we will just say plus one flax and that's it um probably what we would do for the actual game um you know if this were part of a larger game is we would wait a little while and then we would actually delete the entire minigame because you've collected the flax that's it the minigame is over you would have to plant a new flax seed um but right now we're just going to leave it um doing nothing after this um and that's it uh let's see okay I think it's time for a test let's do a test run so all we've done is we've implemented uh the top of this flowchart so basically what we have to do is pick the weeds if we don't pick the weeds then we'll end up in state 7 and what I'm going to do also ah um well this is interesting the reason that this is happening I think is that the flax bundle is still here except it's uh yeah see that's where the flax bundle is um let me make it inactive for now so that I can actually see what I'm doing here um let me add um a display for this state so that we know what state we ended up in okay let me reactivate the flax and let's see what happens so again when I pulse this in order to start the game we should see the flax grow up and then the weeds grow up I'm going to pull the weeds uh there should be some time and then the weed will appear I'll pull the weeds and then there will be some time and then the bed should disappear and the flax should appear so let's see what happens pulse and we can look at the state so after 5 seconds we should go to 1 and there we go we've got our flax then we should go to 2 and we should see some weeds I'm going to pull the weeds it says weeded that's great after a little bit of time the weeds are going to reappear again we see weeded that's great and then that's it the flax is here when I pick up the flax it should just say plus 1 flax and it doesn't and I'm not sure why okay so grabbing the flax didn't actually work let's see if we can figure out why so first of all let me deactivate the flax for now we're on state 6 so we know this impulse happened we know of course that we set the bed to false we know that we set the alpha to 1 however the grabbing doesn't seem to work so why is that let's find out there's the logics and there's detect grabbed so let me just make sure that it is actually going to the right place yeah I think it is I just want to make sure that this slot is correct it's logics on the flax bundle so that definitely is correct so apparently we sent the we sent the detect grab message to the flax bundle but we never got the flax grabbed message so let's see why I'm going to pack all of this logics and then I'm going to unpack the detect grabbed logics and see what happened so we should have gotten the detect grab and we should have set the grabable to true let's see if it did actually get set to true the flax bundle it did not so this is a problem that we need to fix let's just see if there's a problem with the grabable dynamic variables no it looks okay I did on purpose leave the slot empty so that it would just go up to whatever parent it could find and set the flax grabable to true so either we did not detect the grab or either we did not send detect grab or we did but we were not able to set the grabable to true okay so what I want to do is let's see what should I do here's what I'm going to do I'm going to connect this to a display and unfortunately you can't insert a display here the display is the end of the impulse so I'm just going to put that there and what I'm going to do is I'm going to reset the game so the way to reset the game hmm yeah that is a question how do we reset the game well all that logics is over there so I should be okay with opening up the game again okay because all the logics is over here and what I'm going to do is I'm going to also add I'm going to add a message receiver so flow dynamic impulse receiver and I'm going to say go so this way what I can do is I can just put some logics you know over there off to the side that sends the message go and that actually triggers everything um I will manually have to go to the bed and activate it okay um let me go ahead and pack this into game right and now what I can do is uh let's see I can actually go over here maybe yep let's go over here and just create a dynamic impulse trigger manual go and then send it to the logics of the game okay so now this is sort of like my manual button to start the thing off so when I pulse this we should be ready to go so what we want to do is we want to pick the weed where's the weed there's the weed picked this is another problem that I'll get to in a moment okay alright so we see that we did indeed detect the grab so what must have happened is that this flax grabbable failed now there's an extra impulse over here that's for on not found it seems to me like it should have been found let's just see um yeah so the weird thing is is that it was not found why wasn't it well was it not found let's go ahead and do the game again and see if this failure impulse comes out so we're gonna pulse this I will have to manually activate the bed and okay there's the weed and okay alright so presumably it worked it's just that oh well look at that it's now grabbable that's really weird so what happens if I grab it okay well it's working now um okay I don't understand that but let's no no no no let's go ahead and pack this into detect grabbed I don't understand why why that did that okay now this is another thing that we're gonna have to fix so there's this this this flax shaped thing over here um so the real question is um and what I can do and I don't know if you can see this I don't know if this is actually getting rendered but my the raycast that is coming out of here um it actually stops on you know any object that it hits um and it's stopping on this flax thing so I think that what I should probably do is deactivate the flax thing all together the flax bundle and then when the flax is ready to appear just activate it I think that'll solve that problem because the other problem was that with this active and with this outline over here I was unable to get to the weeds that were behind it so so what I should do um so what I should do is um reactivate the bed bring out the game logic okay um and we should make a copy of set slot active self and insert that here and make this true and give it to the flax bundle there so now um okay so I'm I'm looking at my raycast and I'm seeing that it's still the mesh is still there um because the flax bundle is still there if I deactivate it now that should be the initial state of the game so I'm looking at my raycast and I'm not seeing it stop at the flax bundle it's just going straight through and that's what should happen and in fact I can put that into the logic over here as well to sort of initialize the game um let's just put it inside here the flax bundle and set it to false okay there we go okay let me go and pack it pack it okay let's uh let's initialize the game again pulse and see if it works alright here are our flax plants here is our weed I pick it and it says weeded I'm ray casting through the entire thing so that worked I can pick the far weed that worked weeded okay and now we have this and now I grab it and we get plus one flax excellent that was interesting the uh the flax is actually still here so um yeah so actually we just want to deactivate the flax when you grab it we don't want to set its transparency we just want to completely deactivate it okay so that that's fine um let's go ahead and bring everything back so the bed should be active the flax bundle should be inactive and let's pull the game logic out once more so when the flax is grabbed instead of just setting the alpha to zero we will set its slot oops that's not what I wanted we will set its slot active self um let me just pull flax bundle to here and set it to come on set it to false and then we can go ahead and do plus one flax okay this is perfect let me pack it pack it and save my session now everything is saved and finally go back to the game logics okay we are now going to implement the second part the seed part so this is what happens when we go into state seven so that's right over here this ribbon right over here now the good thing about this is that this is very repetitive so I probably should only have to write two bits of code here um and I am probably going to end up not putting it down below here but you know maybe putting it out here um because putting it down below means that I have to crouch um because I I well I could go through the floor I could set my locomotion to no clip look down and then just go down a little more and now I am sort of you know chest height in the floor I don't like using no clip that much it's a little unnatural to me but if that's all you can do well that's all you can do so let's go ahead and see what happens on state seven all we're doing is we're keeping the weeds uh remember they're not grabbable anymore so we're keeping the weeds and we're just waiting for a period of time so let's do that um and we're going to state eight well the nice thing is that we already have a delay that goes to the next state so let's just reuse that I'll do this state seven is done let's go to state eight okay so what do we need to do pretty much the same thing as we did with the weeds except with the seeds so the seeds should fade in and then we should wait for them to be grabbed or wait for them to simply time out so what that means is and which state did I say it was the same as two zero one two so that's this one right here so I'm simply going to copy that um yeah I did say that I was going to go that way but I think there's uh I think there's enough space down here there's a little bit of space down here okay so I so what I want to do is I want to set the alpha and this time I want to set the alpha on seeds so here's my inspector um the seeds are in bed so here is the logics for that let's see it's one and two just like this okay and then there will be a dynamic impulse trigger to see if we detect a grab um and we're doing that on the same logics okay if we do detect a grab we put this over here and instead of weed grabbed it's going to be seed grabbed seed grabbed okay uh then what we want to do is make the seeds disappear I'm going to just put that up here and it's alpha again so sure let me just use a ribbon down here this is alpha so I can just put that there um on the logics for it it should disappear just like this does and then we want to announce announce here's another announce let's move this down to here announce um let's get the scene inspector out of the way announce plus one flax seed okay now once we get the seed we want to increment by one so in all of these um when we have seeds and we pick the seed we increment the state by one so that's pretty easy to do we just uh um we can just go up here right because that does exactly the same thing it just says plus plus and then it goes back into the state machine let me save that okay now this is actually going to be true for state um 8 10 12 and 14 they do exactly the same thing there may be there may be a difference in no there is no difference okay so what we can do is we can simply do this now state 16 is going to be something else state 16 is sort of like the final state where actually the bed disappears and all you're left with is a seed okay so let's deal with um the other states so this is what happens when um uh let's see this is what happens when you're when you're uh when you've picked the seed so the seed has disappeared we've gotten an announcement saying plus one flax seed and now we're just sitting waiting around for another seed um and that's just a delay with uh a plus so that means that here we can simply go one two three and four okay final state let's save that and let's go to the final state so the final state is what happens when ah oh wait a minute no ooh yeah um when we're here and we time out we don't want to go plus plus because that'll just get us to the next state um oh yeah right no we that is correct uh on states nine eleven thirteen and fifteen after we time out we do want to go to the next state uh the thing we haven't taken care of is what happens when when the seed has appeared but we time out so there's this uh seed grab time out which we have to handle so let's go ahead and handle this and I made all this noise about how I wasn't going to crouch but here I am crouching so here is seed grab time out okay now for seed grab time out all we have to do is um all we have to do is go to uh the state plus two so I'm just going to take this plus plus and I'm going to put it out here um and I'm going to pipe it in and then we want to plus plus a second time that makes two so I can just pipe it into there and there we go okay that should do it now we can talk about the final state so again let me save okay the final state so this is what happens when we've got seeds uh but we time out um or we've got weeds and we just you know we go for five seconds and then we stop on the last phase what should happen is everything should disappear except we should get a seed okay so everything should disappear that means that the bed disappears we know how to do that so let's just go ahead and do that set slot active um is this the right thing yep this is the bed um let me just stick that there so I can simply do that there we go false um right and now we need a seed to appear yeah we need a seed to appear and unfortunately it's not going to be the seeds that are on the plants it's going to be one seed on the ground so unfortunately what that means is we need to create another object here that holds only that seed and duplicates um and duplicates uh the logics okay so I'm just going to be lazy and I'm not going to do the alpha fade in I'm just going to have it immediately appear um we are going to have to detect grabbed because when we grab it we want it to disappear and display plus one flax seed so let's go ahead and do that so I'm going to create a child and I'm going to call it final seed okay here's the interesting thing if I copy it from the bed so there are seeds here I can take one I can copy it copy it and put it in final seed okay now the interesting thing is that it's mesh it's uh it's material is seed material which of course remember is um shared by all the seeds and is currently uh let's see and is currently um invisible no actually it will be visible right or will it no it may not be visible but I can make it visible right because it doesn't actually matter if they're visible on the flowers because the entire bed is going to be disabled which means that I won't see it which means that I can simply use the same material um and in fact I can use the alpha logics over here to make it visible so that's good um I also need to copy the detect grabbed logics so I'm going to make a copy of let me make a copy of the the flax bundle one the reason that I want to do that is because it has no time out it just sits there and waits for it to be grabbed okay now um okay let me go ahead and pack what we've got and save what we've got and unpack detect grabbed um let me just go to final seed um aha yeah so the grabable also needs to be driven so I need to get I need to attach a space to this and I need to call it flax I need to attach a boolean to it and it's called grabable no it's called flax slash grabable and I need to attach a driver to it flax grabable okay and now I need a second window here um go up one uh go to the final seed the seed pod itself and copy grab um be enabled into there okay so now um now it's grabable now it's not okay uh I also need to position it um to where it's going to appear so right now it's invisible I don't really care um but I can use my dev tool tip to move it around I hope that moved it around it's gonna put it like here I could even make it bigger you know it doesn't really have to appear uh as the flower so I could actually scale it up um so instead of .009 I can make it like .002 okay so now it's a little bigger um I can't show you it until it actually appears um but I think that should be it so um let's pack this logics away now we need to go into detect grabbed for it and the logics appears all the way over there um flax grabable blah blah blah um we have disconnected this time out so now it's going to be um seed grabbed so we're just gonna send another seed grabbed um actually we're gonna call it final seed grabbed right because we're already handling a message called seed grabbed so you know we don't want to uh to um trigger any of the other logic and we need to set up the grabable correctly so let's see where is it um and here it is here is the grabable okay now it is pointing to the right grabable I can now set that okay let's open up the game logics and do the final thing game okay so uh seed grabbed um okay where am I ah yes okay so this is the final um this is the final thing thing thing thingling oops I don't need that what I want to do is we've set the bed to inactive but now we need to set the final seed to active so I'm going to deactivate it right here um I'm going to grab final seed okay I don't know why that didn't work oh I need to grab it here okay that's final seed set it to true so now it's active um and then I need to detect grab on it so let's see it would basically be like this yeah here I go again crouching so um and this is we want to set this to send it to detect grabbed that's the logics for it that should trigger that message and then when we grab the final seed so this is now final seed grabbed we will deactivate the final seed which is this set it to false and announce let's get rid of this we can announce one flax seed um we could actually we could actually just go to here right because the next thing that's going to happen after this is we're going to increment the state again and go over there but there is no state after that so I think um you know what let's just keep it clean um here we go announce announce plus one flax seed and then it doesn't do anything this is what would happen afterwards but nothing should happen okay let's go ahead and pack all that and now let us see what happens when we go through the seed path so here we go alright so we've got flax flowers we have weeds we're going to let it go to weed okay so I should no longer be able to pick right the seeds appeared great we've got plus one flax seed I can't pick the weed this is good the flax seeds reappeared I can pick the flax seed great now when the flax seeds reappear again I can pick the flax seeds and I should be able to do this four times okay and then the bed should disappear and we get a giant flax seed which didn't appear because I forgot to set the alpha okay I forgot to set the alpha which is fine um I can sort of see it and if I pick it I get plus one flax seed and it disappears and that is the end of the game so let me go ahead and fix that one final issue um so I need to activate the bed there it is I need to pull out the game logic there it is um I need to set the um where is alpha uh sure where should I put that how about right after true so I'll stick it in right here okay and unfortunately this is getting very messy but if I had this on a red print I could actually organize this very nicely very prettily um let's grab alpha here setting it on the weed material right so where is the weed material the seed material I'm just going to pull out another copy uh so it's going to be under bed seeds and I'm pretty sure this will work parents parents parent is parents parent is inactive I think I hope um if not I could just make another copy of the seed material um so you know what I'm just going to do that cause I mean there's complications and then there's really no reason for that so I'm just going to make a copy of this seed material put it in final seed um open up the mesh for that seed and go to seed material and change its alpha to one and move it to there okay so it's another copy oh well um it's fine it'll be fine okay let me go ahead and pack this again pack this again I don't know why that's broken but we should be good to go so let me go ahead and deselect everything and press go alright let's see what happens okay we've got flowers we've got weeds and I'm not going to touch them we've got seeds so I'm going to pull the seeds um for the next go round I'm not going to pull the seeds so zero one two three four five okay now we should be at the next stage where we can still pull the seeds this time I'm not going to be able to get four seeds I can only get three oh or two okay and there is that big seed and when I pick it I get one flax seed and that is the end of the game so that is it I can now save this in my inventory and I can put it in my public folder for you to take a look at and pull apart and modify if you want so I will do that right now I will call this I will now call this instead of surround v3 I will call this the flax minigame v1 and I will go into my inventory go to well first of all planter so that I have my own copy of it and then I will go into my public folder under gadgets okay so the only problem is that when you spawn this you won't actually be able to start the game so I will leave that as an exercise to the reader so yeah it may not be as friendly though because if somebody just goes into my public folder and sees the flax minigame and opens it up apparently nothing will happen so I guess I should fix that and I will fix that after this video but for now I think that's good enough so yeah yeah I think that's fine so thank you for watching I hope that all of this video has been useful to you to think about creating your own things out of primitives and premade assets in neos and basically make your own little games make a tale in the desert in neos maybe it will work so until then bye bye