Submind YouTube summaries
Thumbnail for Building stuff in Neos: Flax Bed Minigame from ATITD, part 2 (LogiX)

Building stuff in Neos: Flax Bed Minigame from ATITD, part 2 (LogiX)

Watch on YouTube

Video summary

This video tutorial guides viewers through the development of a Flax Bed minigame within Neos using the LogiX system, focusing on plant growth mechanics, harvesting logic, and interaction systems. The core gameplay loop involves planting flax seeds, waiting for them to mature while managing weeds that naturally appear over time, and deciding whether to weed the bed to maintain productivity or allow it to become overgrown until only a single seed remains before the bed disappears. Advanced features such as cross-breeding seeds for better yields and water requirements are also introduced, setting the stage for a dynamic farming experience where players must balance resource management with strategic decision-making. From a technical perspective, the developer emphasizes performance optimization and clean state management by implementing gradual visual transitions using separate material objects for stocks and flowers rather than modifying global world assets. A "dynamic impulse" system combined with a constant lerp function is utilized to smoothly transition material alpha values, while an "on duplicate" event ensures that all plant alphas reset to zero when the game is cloned. To make weeds and seeds interactable, a "grabbable" component with a mesh collider is attached to specific parts of the plants, supported by a timer system built from boolean latches and delays. This system creates a window for harvesting where grabbing an item within the time limit advances the growth stage, whereas missing the window triggers a timeout message and alters the game's progression path. The tutorial further refines the logic through a structured state machine ranging from 0 to 16, which tracks progress from initialization to final harvest using an impulse multiplexer. A critical optimization involves defining variables like `grabbable` at the root "weeds" level to prevent unnecessary hierarchy searches, ensuring immediate state changes when objects are grabbed or timed out. The developer also addresses a specific bug where deactivating objects via alpha transparency caused raycasts to fail; this was resolved by using the `active` slot property instead, allowing raycasts to pass through invisible meshes correctly. Additionally, a utility system for floating text announcements is created with a one-update delay to ensure the Constant Lerp node reads inputs properly, preventing immediate impulses from being ignored. The video concludes by detailing the implementation of seed harvesting logic and the end-game sequence, where a timeout mechanism causes the bed to disappear after five seconds and spawns a large "final seed" that triggers the game's conclusion upon collection. While the logic for spawning the minigame directly from the public folder currently fails to start automatically, leaving this as an exercise for the viewer, the project is successfully saved as "Flax Minigame v1" in both the inventory and public gadgets folders. This comprehensive guide provides a robust foundation for creating interactive farming simulations, blending creative game design with efficient coding practices to handle complex interactions and state transitions effectively.
Read the full video transcript
hello welcome back and this is our flax bed flax planter mini game uh that we're working on so we're going to now uh start to put together the logics to create the actual game now i've drawn out um a sort of flowchart as to what the game actually does so the idea is that you start here where you plant your flaxseed 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 uh 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 that you can harvest so this gives you a flax seed that you can then go off and you know plant again and in this way uh you can basically uh create more and more flax as you need it so when you harvest the seed it goes back to just being you know weedy but if you don't harvest 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 uh until in the final uh 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 uh 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 um 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 um you know farming techniques uh to sort of cross species um 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 um this is sort of like just the basic mini game that you can build off of and that's all that we're going to do right now so um so let's start uh by thinking about this section of the flow chart here when you plant the flax bed basically nothing is in the bed except for the steaks and the dirt so after a period of time you get growth so these uh weeds and weeds these uh flax plants right over here should sort of gradually appear so in other words the alpha for the material is going to go from 0 to 1 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 uh where is it okay so i've lost it but that's easy i can just uh 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 around 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 deactiv whoops 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 uh this is not exactly what we want to do um 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 uh in order to make the flax plants uh gradually appear we need to modify their materials so there are two materials there is the tune material on the stock and uh 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 stock 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 okay z right 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 um actually instead of calling this materials let's call this stock 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 um 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'm going to cancel out of this let me delete that and then the stock 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 cac the into the the flower itself and drop it in and now 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 um 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 which means that everything that uses that can get modified which is not what we want because if you you know 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 so i'm just going to copy it in so [Music] 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 um 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 to one all right so uh 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 um these are set to zero so the way we're going to do that is under under flax 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 it's more like uh it's not even a call it's a 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 logix tooltip 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 you know 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 um sometimes it's hard to remember where these things are is it math yeah it's math constant lerp so what constant lerp 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 uh basically at uh 0.1 per second at least that's what it looks like to me right 1.2 1.3 1.4 one point 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 you know counting down so essentially the constant lerp sort of keeps in mind uh uh current target um or it's it's actually its current value um and then when its target changes it immediately starts moving towards that target um at the at the particular speed so this is what we're gonna use to modify the alpha right because we can just change the alpha from zero to one 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 uh the speed uh the reason that we want to give it a speed is that if we do something like 9 e 9 so that's basically 9 billion if we then change the target to zero it pretty much immediately goes to zero with pretty much no delay because it's going at you know nine billion numbers per second uh you know which which equates to basically nanoseconds in other words no time at all so what we can do is we can take this constant lerp 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 right so here is right so right 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 two so we see so we've saved it and that way we can do you know something else with the next impulse and this value again uh remains now to split the float two up we have to go to not math uh operators we have to go to operators and there's unpack x y on pack x y simply unpacks the float two into two floats top and bottom okay 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 uh the 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 so 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 1 1 1 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 x y z w is for quaternions in other words rotations um so you don't do that instead there's um pac rgba that is a color and you can see that the colors of color actually match so for the uh for the stocks we want one one one right because the the texture actually gives you the color so 1 1 1 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 1 1 1 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 [Music] the the current value of this register is 0 0. what i could do is i can just create another write node and write 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 point 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 9 e 9 and the alpha value with zero and go and there it is so with this we can actually start to fine tune what we want to see so instead of point one let's suppose we want it to fade in over a period of three seconds so it would be 0.33 say okay maybe we want it a little slower and make it .25 so let's pulse zero and then it'll fade out over a period of four seconds that that is probably i think point three is just fine so we do this oops pulse and i think that's fine okay so um 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 one 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 .25.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 route 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 it packs now it only packs up to um 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 um 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 0 and 9 e 9 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 processed that message now if we want the flowers to appear again let's just do 0.5 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 stock and the flour material and the same thing with the seeds so it's basically more of the same so um let me go ahead and just get rid of this so i'm going to try to grab all of these 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 seat 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 um you can also do onstart but it's so if i look at onstart 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 mini game restarts for you which isn't any good so i think we want on duplicate there's also on loaded and again i'm not sure whether it should be unloaded 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 logics and this is going to hold all the game logic or the main game logic obviously there's some like utility functions in here and under logics i'm going to call it you know 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 but so you can imagine that on duplicate we want to set 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 uh 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 too so there it is and the message is of course alpha and we want to send it to the flax logics 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 one e 10 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 it's actually just one continuous loop one continuous thread so um 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 lerp the lerp 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 route and then pack this up and then what we can do is um let's let's do it this way um 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 now 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 um 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 um 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 um 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 decrypt this let me equip this let me open up the root so this second surround here is that 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 grabables so let me just do that okay so uh 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 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 is it it's this one right yeah i mean it's it's definitely this one so you can see that the duplicate um the the flax plants are gone and that's because it was duplicated which caused on duplicate 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 you know 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 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 logics next okay so uh what i did um during the break is i added a weed material and logics to the weeds a seed material and logics 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 we're going to go so because this is going to be for the weeds we will start we will start that code in the logics for the weeds so we're gonna do something like um grabbed so let's see what we let's see what we can do so what i can think is that we send a message uh saying you know i guess detect grabbed maybe i should change this to detect grabbed okay and what that will do is it will start a timer right because according to the flowchart which i don't have with me according to the flow chart 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 time out 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 um so one of the issues is um with timers so if we go to where is 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 um 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 um there's a delay so this is something closer to what we want so if i give this two seconds and 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 so that 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 cue 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 uh any delays that are queued up um so that's one way of doing it um the other way of doing it is if you know that you're not going to be triggering the delay uh 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's basically 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 know 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 the time period so let's change this to say 5 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 pulse 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 uh 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 um 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 um and that will cancel any delays um you can see there's also updates delays and that is basically instead of seconds this is a number of updates um i think that is tied to frames i think um there's also delay with value which is the same thing as delay except you can give it a value to output um so so you can have sort of like a queue of uh of values that go along with the delay um okay well i mean this is 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 um 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 ungrabbable grabbed so here is an impulse that will pulse when a grabbable is grabbed now a grabable is um so if we look at the help text we can see grabable eye grabbable 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 uh does except for grabbable there's a component called grabable so let's go to the weeds okay so here is the weed let's attach a grabable component to it um which wheat is that it's that far one um 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 okay so i'm going to work with this weed i'm going to attach it's for some reason it's still it's in transform interaction grabable okay so that makes this weed grabbable now i don't really want to grab it [Music] well okay so if i grab it and move it around i can always undo grab object object and it will go back to where it was so 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 uh and detect um so you know if you've got you know thousands of these maybe go with a box collider instead um or something so under mesh collider there's a type so there's there are things like no collision uh static trigger um and that that's sort of like beyond the scope of of what we want to deal with character collider means that if you walk into it um you you well uh you can't walk into it you would collide with it and ignore raycasts 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 i can't actually hit it with my ray i would actually have to go right up to it and grab 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 grabable and then hit secondary i get this um interface card and then if i take grabable and i wire it to ungrabbable it's accepted without any any casting so that means that this actually does implement eye 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 yep there we go uh the 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 um this is pretty good so we've got the one weed um we can do that for the other weeds as well so let's go into this weed attach a transform interaction grabbable um let's go ahead and just pull out the interface card for that and then this top lead let's go and add a transform interaction grabbable and pull out the interface card for that now um we're going to have a second on grabbable and a third on grabbable so here are the three grabables 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 grabable so um i i think you 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 get slot so whatever this is so it gives you which slot it is now of course it doesn't tell you which weed it is um 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 um based on whether a weed is is grabbed now let's go into flow and um 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 okay so that went off let's pick this other weed here okay that one went off let me undo the grabs okay great okay um so this is our grabbing uh 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 okay so when you uh when you send a message detect grab to weeds it will start the five second timer and let you grab the weed now uh what happens what would be bad is if you uh is if you grab the weed and then grab it again so what would happen is uh if you send detect grab the the five second delay starts you grab the weed great so this impulse goes off and effectively the delay is canceled 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 like reset it using detect grab you can't send another impulse again so in other words when this is reset we only want to accept this um 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 um we're going to have to wire this up to here let me see if i can make this a little nicer okay 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 into the ether um so that you don't get this impulse a second time okay um 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 okay well let's uh send those as a message okay so let us call the message um weed grabbed so that we know that it was the weed that was grabbed okay 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 uh 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 timeout and we want to send it to the same object um i guess that's it so that is our grab detection so let me go ahead and [Music] set the packing root node set the packing route 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 logix so for this now i'm going to set the packing route 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 one two three four five six seven eight eight of them but right now i've only got one seed obviously i need to fix that so this groups 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 okay we need to attach a grabable to this transform interaction grabbable okay so now the seed is grabbable i can take the grabbable and direct it to the node okay 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 um i just need to do that for all you know for for the other seeds so let's see okay so now what we need to do is talk about the fact that the seed and the weeds are now grabbable in other words i can still grab them [Music] which is a problem because i can grab them even when i'm not waiting for them to be grabbed so um under each weed we can see that here is the grabable interface now if i disable grabbable on all the weeds okay now i cannot grab the weed and in fact ungrabbable is on grab is not gonna it's not gonna do anything and i can show you that by opening up detect grabbed starting it up um let's see yeah okay so let me output a display here and a display here okay so the top one is we grabbed message was sent and the this one is we'd grab timeout message was sent okay 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 grabbable how do i do that programmatically well right now there's 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's 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 decrypt 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 grabbable let me now decrypt this and re-equip my logix 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 val variable changes the value of that grabbable well now all we have to do is add more drivers on the same variable for all of the weed things so there's that one and there is that one so now when i change the value of grabbable all of the weeds either become grabbable or stop becoming grabbable right right so that's nice um how do we how do we put that into practice i mean what are we going to use this for well we'll start off with it not grabbable 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 enable grabbed so what i'm going to do is insert into here um 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 grabbable and i did make a mistake under weeds this isn't supposed to be grabbable this is supposed to be flax slash grabbable so that it specifies that it is in the flax space uh because otherwise what um if you're sort of searching through the world um for well maybe not searching through the world but um um 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 uh 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 grabbable in the flack space then we will just end up in uh the flat space here and we will not go any higher um i'm probably not explaining that very well again look at probable primes um 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 uh 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 logix node probably in the detect grab node so again it will start searching up through the parent hierarchy for uh the flax space and then it will look for the grabbable variable in the flat 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 grabbable 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 ungrabbable 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 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 um the moment it's grabbed we want to make it ungrabbable so why don't we just do that also okay so that's that's not true um if it's grabbed and we're about to send the message then we want to make it ungrabbable if it times out we're still grabbable we want to make it ungrabbable so let's just do that okay so here i'm going to insert set flex grabbable 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 grabbable 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 um you know you would have ribbons that sort of go actually maybe for the 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 uh 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 grabbable okay 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 um so i guess what i would do is i would just delete this detect grab and then replace it again or copy it over again because i've i've added some some useful logic the other thing is that when we start the game we want to initialize that grabbable to not grabbable so let me go into the game set the packing route 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 ungrabbable so i'm going to write a dynamic variable bool so after this is done i want to flax grabbable false in weeds okay and yes again i can take it from this slot um well actually no i can't because this slot is logics this slot is weeds itself so that goes there and just to 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 okay and now this time it's also going to be flax grabbable now you may ask yourself um well these are the same variable 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 grabbable in weeds it will go to it will it will stop its search at this space which is on weeds if i do the same thing for seeds so attach data dynamic space flax and i search for the grabbable variable name in seeds again it's going to stop at this space it's not going to go any higher so uh that is uh 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 grabbable and the weeds are not grabbable of course again i have to put a seed on every flower um i have to go into detect uh i have to go into detect grabbed i have to you know do the on grabbed uh for all the seeds which i can do offline um okay so that is uh that is the grabable so let me do that and we'll take a little break now okay so the next thing uh 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 and this is outline text um let me go ahead and open an inspector so that i can look at it and drop it into a nouns okay so this is the outline this is the text right over here so you know you can imagine that it would be something like you know plus one uh flax seed right 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 -180 so the unfortunate thing is that it's only really [Music] 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 uh around a box so that there are four pieces of text you could maybe make it so that you can detect the person who did the grabbing and then make this face that person but you know right now i'm just going to make the uh make the announcement okay so here is this outline um and apparently it's going to start at y equals one i guess that's good um and then we're going to make it float upwards um in addition we're going to 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 um so let's go ahead and create some logics for this we'll just call this logics all right and we will create a child and we'll call it a nouns oops announce okay so we can start by doing what um well we can certainly start by copying actually uh [Music] the alpha for the logics so let me just make a copy of that um so instead of this object we'll start with this object unknowns 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 um what's in here one okay okay so that's the current speed that's the current alpha so uh 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 um let's just [Music] 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 um 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 an ounce okay so the idea here is that the first thing we're going to want to do is um 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 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 zero uh one actually um you know what actually um because this is going to be lurked lerped that is now a verb we'll use a float too let's get rid of this re-point it to this okay so we want it to go to one immediately there okay so what we can do with that is um let me copy the x y unpack put it here uh let's um let's 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 to it to float up to let's see where four that's a little too high two that's kind of nice sure to two okay so we want this to float up to two and we want it to take say one second okay so now when we pulse this here that will reset the position to one and then when we pulse here uh ah we need to drive we need to drive the position so let me pull out an interface card there's the position right there uh we need to drive it with x y z so we'll go to operators pack x y z like this we know that the y is going to be the thing we want to drive and the other values are zero so i can just leave those alone because they're zero by default and then drive the position okay so now when we pulse this we reset this to one and when we pulse this it floats up [Music] 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 write here oh 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 drag where you can sort of 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 we are going to initialize it to well first of all the speed has to be 1e10 because we want it to be pretty much immediate and the alpha value we want to be one okay and then we want to unpack it do a constant lerp and you know etc etc 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 all right let's see how that works so we're going to reset and now we're going to pulse reset and pulse good enough uh 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 um oh and then of course if i pulse it we we get nothing here so um the way i can fix that is to do that oops um do that okay why isn't it going oh right because um ah yes right okay so the thing is that once we do this uh immediate set we need to then proceed to make it float upwards so that would look like this see okay so um why doesn't it set properly now when i pulse this that sends an impulse to this right 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 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 uh the constant lerps 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 one immediately yeah if i tell it to go to one 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 lerp looks at its inputs and it sees two and then it realizes it's already at two so it doesn't do anything so what i need to do is i need to put in a one update delay in here that one update delay will allow the constant lerps to read its their inputs because they read their inputs on every update so that will cause the constant lerp 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 one that will give the constant lerps the opportunity to read their inputs and then do this thing so let's see that happen now there we go okay so it was important to understand exactly how constant lerp works again it's got an output which is kind of like a register and it reads its inputs but it only reads its inputs on on uh the update clock so in other words the tick of of i guess the graphics frames or something like that if because we didn't give it an opportunity to tick constant lerp didn't read any of these inputs and instead read these inputs so it appeared as though it didn't do anything okay so now what i can do is i can get rid of this temporary right i can get rid of this pulse and now i can set the packing route and update uh and pack now there's one thing that i just want to uh point out there's one thing that i want to point out is that um is that the end the end is that when you send this message what happens is the the flow of execution goes through here goes through here up here up here and then it basically um 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 so um 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 lerps are done and because we're not sending a message when those lerps are done there really isn't any way of telling when those lerps are done so you would have to monitor the lerp for the out for you know for their final positions um 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 um all right 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 um the only thing we haven't reset is the outline um 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 so far it'll it'll be fine um 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 five seconds just to speed things up but in the real game it 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 um so we could do that simply by we could do that simply by uh 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 uh start off by giving a let's see it's under flow 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 lot of outputs this one tells you how many outputs there are so this would be so this one 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 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 zero so what i'm going to do is oops whoa what i'm going to do is i'm going to go to actions go to write and i'm going to set this up to write a zero into the integer okay because the default of the input is zero so we've done all this initialization we've set up the state to zero and now we are here in the impulse multiplexer now of course we're going to need from 0 to 16. so i mean there's going to 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 uh when you expand these nodes it looks like the ribbon breaks and of course you can't like 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 um during state zero we want to uh do something in this case we don't do anything and then we want to wait on some 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 going to do is we're going to grab a delay node it's under flow delay and we're going to make it five seconds and when we're done with that delay we have to decide where to go next what state to go to next then of course we're going to go to state 1 next so rather than write a 1 into the state integer what i'm going to do is i'm going to go to actions and use the plus plus node right because we're on zero and oops 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 um you call them staples technically they're relays um so they just relay their input to their output um 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 um so here's another staple for example okay 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 going to do that and i'm going to 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 zero we delay five seconds increment and then go back into the impulse multiplexer which now goes into here which is number one so what do we do in number one what is the action that we take well the action that we take is to fade in the uh fade in the flax so let's do that and we know we can do that with the alpha message so i'm going to need a dynamic impulse trigger let me put it over here because i know that strings are big and rather than run alpha all the way out from there i'm just going to stick it in over here see how big these end up being okay so um the slot that we're going to uh apply the slot that we're going to do for alpha is the uh 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 problem is that it's not really out of the way i guess that's okay all right and what do we want well we want alpha to go from zero to one in a period of say two seconds sure okay 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 uh 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 um not having so many uh 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 uh let's just say alpha up the weeds so we're going to take one of these things uh it's going to be alpha so i can do that 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 too 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 um dynamic impulse trigger i need to leave space for the string and what was it called it was called like detect grab so then we want to set up the grab detection on the weeds right so it's in here uh i did call the object detect grabbed but i think that i called the message detect grab so we're gonna do that so that starts off the detect grab okay now we're gonna 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 we grab timed out and if we get that message we should go to state seven okay so in order to do that we're going to have a dynamic impulse receiver i'm going to put it right over here so the first one could be weed grabbed and i'm 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 the weeds detect grabbed detect grabbed what's going on set packing route okay ah we grabbed and we'd grab timeout and the message was detect grab okay so i will pack that any more fragments no let's unpack the game we grabbed we grabbed timeout 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 gonna get one of these two messages we grabbed or we grabbed timeout if we get we 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 okay so that's weeds so i'm gonna simply grab this and stick it over here and sort of put the staple in the back okay 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 bring it out here and we want to announce [Music] 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 7 to 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 go back okay let me go ahead and pack all of this um it's interesting that that this uh 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 okay all right um you can sort of see that this thing is quite large um and i'm kind of running out of space almost um so i may you know extend it a little bit downwards or i may just extend it um i'll probably just extend it even further out here in this space um okay so what have we done we've gone through and 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 and then we delayed five seconds and then we um 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 i'm just going to put a 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 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 um so i 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 surround to our mini game yet so we need to do that [Music] 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 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 so i can fix that easily by just setting the dynamic variable to oops to um actually no i can't can i um i have to set its uh transparency right so okay so what i'm going to do is i am going to break this line right here and you can see that in the initialization i've also set the alpha of the flax bundle to zero and i've also set its grab ability to false 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 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 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 so in the actual game what happens is that the planter just sits there and then you get an option that says harvest so instead what i'm going to do is i'm just going to make the planted 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 steak rose and we have 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 the announce object the flax bundle and 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 grabable active does have a logix 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 okay so that will deactivate the bed slot and now for the flax bundle i want to alpha it up so uh let's see so again this is alpha i'm gonna 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 detect grab on the flax bundle so again 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 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 timeout because we're just going to sit here and wait for the flax to be grabbed so it's flax grabbed flax grabbed and when the flax is grabbed 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 mini game because you've collected the flax that's it the mini-game is over you would have to plant a new flaxseed but right now we're just going to leave it doing nothing after this and that's it 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 seven and what i'm going to do also ah 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 a display for this state so that we know what state we ended up in okay let me reactivate the flax and and let's see what happens so again when i uh 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 there should be some thyme and then the weed will appear i'll pull the weeds and then there will be some time and then the 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 five seconds it should go to one and there we go we've got our flax then we should go to two and we should see some weeds i'm gonna pull the weeds it says weeded that's great after a little bit of time the weeds are gonna 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 one 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 [Music] let me deactivate the flax for now we're on state six so we know that this impulse happened we know of course that we set the bed to false we know that we set the alpha to one however the the grabbing doesn't seem to work so um why is that let's find out there's the logics and there is detect grabbed so um let me just make sure that it is actually going to the right place yeah i think it is okay i just want to make sure that this slot is correct it's uh logics on the flax bundle so that definitely is correct so apparently we sent the um 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 okay 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 in the flex bundle it did not okay so this is a problem that we need to fix let's just see if there's a problem with the grabbable 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 either we did not detect the grab or um we well we certainly yeah either we did not send detect grab or we did but we were not able to set the grabbable to true okay so what i want to do is let's see what should i do okay here's what i'm going to do i'm going to connect this to a display and unfortunately you can't like you know 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 um yeah that is a question how do we reset the game well all that logics is over there um 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 let's see 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 let me go ahead and pack this into game right and now what i can do is 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 okay all right 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 uh impulse comes out so we're going to pulse this i will have to manually activate the bed and okay there's the weed and [Music] okay all right so presumably it worked it's just that well look at that it it's now grabbable okay that's really weird so what happens if i grab it okay well it's it's working now [Music] 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 going to have to fix so there's this this this flax shaped thing over here um so the real question is and what i can do and 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 it actually stops on you know any object that it hits and it's stopping on this flax thing so i think that what i should probably do is deactivate the flax thing altogether 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 flex bundle it's just going straight through and that's what should happen um 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 grab the flax bundle and set it to false okay there we go okay let me go unpack it pack it okay let's uh let's initialize the game again pulse and see if it works all right here are our flax plants here is our weed i pick it and it says weeded i'm raycasting 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 um that was interesting the 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 let me just pull flax bundle to here and set it to come on come on set it to false and then we can go ahead and do plus one flags okay this is perfect when we pack it packet 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 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 like 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'm sort of you know chest height in the floor i don't like using noclip 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 stage seven okay so 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 well 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 2 0 1 2 so that's this one right here so i'm simply gonna copy that um yeah i did i did say that i was gonna 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 the seeds are in bed so here is the logics for that um 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 and we're doing that on the same logics okay if we do detect a grab i'll simply 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 going to just put that up here and it's alpha again so sure let me just use a ribbon down here oops this is alpha so i can just put that there on the logics for it and 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 uh there may be let's see 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 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 flaxseed and now we're just sitting waiting around for another seed and that's just a delay with a plus so that means that here we can simply go one two three and four okay final state let's save that uh and let's go to the final state so the final state is what happens when ah oh wait a minute no oh yeah um when we're here and we time out we don't want to go plus plus because that'll just get us when we're here and we time out we don't want to do plus plus because that'll just get us to the next state um oh yeah right no we that is correct uh on states 9 11 13 and 15 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 timeout 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 timeout okay now for seed grad grab timeout all we have to do is um all we have to do is go to 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 and i'm going to pipe it in and then we want a 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 but we time out 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 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 the logics now in this case 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 we are going to have to detect grabbed because when we grab it we want it to disappear and display plus one flaxseed 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 and 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 its 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 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 i want to do that is because it has no timeout 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 let me just go to final seed aha yes 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 grab ball no it's called flax slash grabbable and i need to attach a driver to it flax grabbable okay and now i need a second window here um go up one go to the final seed the seed pod itself and copy gra um copy enabled into there okay so now um now it's grabbable now it's not okay i also need to position it to where it's going to appear so right now it's invisible i don't really care um but i can use my dovetool tip to move it around i hope that moved it around i'm just gonna put it like here okay i could even make it bigger because it it 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 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 logix appears all the way over there um flak scrabble blah blah blah we have disconnected this timeout so now it's going to be seed grabbed so we're just going to send another seed grabbed actually we're going to 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 trigger any of the other logic and we need to set up the grabable correctly so let's see where is it um here it is here is the grabable okay now it is pointing to the right grabbable 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 the final thing thing thingaling 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 [Music] 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 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 a nouns let's get rid of this uh we can announce one flaxseed 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 flaxseed 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 all right 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 flaxseed 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 flaxseed and it disappears and that is the end of the game so let me go ahead and fix that one final issue 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 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 um and we are 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 so it's going to be under bed seeds and i'm pretty sure i'm pretty sure this will work even though the seed materials parents parents parent is uh parents parent is inactive i think i hope if not i could just make another copy of the seed material so you know what i'm just gonna do that because i mean there's there's complications and then there's there's really no reason for that so i'm just gonna make a copy of of this seed material put it in final seed open up the mesh for that seed and go to seed material and uh 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 all right 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 flaxseed and that is the end of the game so um 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 surround 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 um yeah so the only problem is that when you spawn this you won't actually be able to start the game um so this is a 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 i will fix that after this video but for now i think that's good enough so uh yeah yeah i think that's fine um 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 pre-made assets in neos and basically you know make your own little games um make a tale in the desert in neos maybe it'll work so until then bye bye