Unity Game Tutorial: Galaga 3D | Octo Man | Skillshare
Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
71 Lessons (10h 29m)
    • 1. #0 Intro

      2:06
    • 2. #1 The Concept

      9:17
    • 3. #2 Straight Path 1

      9:50
    • 4. #3 Straight Path 2

      5:38
    • 5. #4 Quadratic Bezier

      9:16
    • 6. #5 Bezier Curve 1

      12:05
    • 7. #6 Bezier Curve 2

      6:51
    • 8. #7 Bezier Curve 3

      9:11
    • 9. #8 Moving on Path 1

      12:02
    • 10. #9 Moving on Path 2

      6:00
    • 11. #10 Moving on Path 3

      6:54
    • 12. #11 Formation 1

      12:02
    • 13. #12 Formation 2

      9:57
    • 14. #13 Move Formation

      8:37
    • 15. #14 Formation 4

      8:41
    • 16. #15 Enemy Statemaschine

      9:59
    • 17. #16 Enemy Statemaschine 2

      4:39
    • 18. #17 SpawnManager 1 Intro

      6:01
    • 19. #18 SpawnManager Waves

      7:56
    • 20. #19 Spawn Waves 2

      9:58
    • 21. #20 Spawn Waves 3

      10:07
    • 22. #21 Spawn Waves 4

      9:07
    • 23. #22 More Enemys

      6:32
    • 24. #23 Update Formation

      13:46
    • 25. #24 Spawn Pathes

      11:05
    • 26. #25 Clearing Pathes

      5:11
    • 27. #26 Fixing Path

      10:47
    • 28. #27 New Pathes

      13:50
    • 29. #28 Validate Amounts

      11:52
    • 30. #29 Playerbehavior 1

      9:48
    • 31. #30 Playerbehavior 2

      6:06
    • 32. #31 Shootability

      10:27
    • 33. #32 Player Bullets

      10:51
    • 34. #33 Damage to Enemies

      10:25
    • 35. #34 Tweeking Bullets

      7:04
    • 36. #35 Spread Formation1

      13:37
    • 37. #36 Spread Formation 2

      12:00
    • 38. #37 Spread Formation 3

      7:45
    • 39. #38 Update Enemy on destroy

      5:43
    • 40. #39 Automate Spreading

      12:45
    • 41. #40 Report To SpawnManager

      4:31
    • 42. #41 Diving 1

      8:20
    • 43. #42 Diving 2

      7:25
    • 44. #43 Diving 3

      8:28
    • 45. #44 Diving 4

      5:46
    • 46. #45 Enemy Shoots 1

      7:24
    • 47. #46 Enemy Bullets 2

      10:51
    • 48. #47 Enemy Bullets 3

      11:38
    • 49. #48 GameManager 1

      8:18
    • 50. #49 GameManager 2

      7:24
    • 51. #50 Count Enemies

      4:53
    • 52. #51 Count Score

      7:43
    • 53. #52 UI Elements

      11:09
    • 54. #53 Ui Script 1

      9:08
    • 55. #54 UI Script 2

      7:27
    • 56. #55 Win a Stage

      6:30
    • 57. #56 Starfield Effect

      10:40
    • 58. #57 Mist Effect

      7:43
    • 59. #58 Thruster Trails

      8:50
    • 60. #59 Coding the Trails

      10:06
    • 61. #60 Explosion Effect

      10:20
    • 62. #61 Instantiate Explosions

      4:51
    • 63. #62 Fixing Stage Swap

      12:48
    • 64. #63 Player Collision Update

      6:43
    • 65. #64 Reset Player on Dead

      11:28
    • 66. #65 Path Optimization

      6:19
    • 67. #66 Game Over Scene

      10:03
    • 68. #67 Transfering Score

      8:16
    • 69. #68 Menu Scene

      14:28
    • 70. #69 Fix and Clean Up

      5:33
    • 71. #70 Conclusion

      8:03

About This Class

444ce558

In this Course you'll learn how to create a Space Shooter like the amazing Galaga in Unity Game Engine. The concept is based on different behaviors the Enemy Space Ship can be in.

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

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

So we create several Systems which will give us enough freedom to:

C# (Monodevelop)

  • create our own Pathes the enemies can fly on

  • create our own Formation system where the enemies go into for their typical left/right movement

  • create our own diving system to randomize enemies flying around

  • create our touch/click & and hold movement for the Player and shoot meanwhile holding

Unity (2018.2)

  • managing our systems and make them multifunctional

  • creating Space Particles like for Stars & Mist

  • using Trails to make nice visuals for the Space Ships

  • creating Particle Explosions

  • creating a Start and GameOver Scene and of course 1 Game Scene

Course Material

I provide the following Material with the Course:

  1. 4 different Space Ships (3 Enemys, 1 Player) as *.fbx

  2. 1 Star and 1 Cloud Texture as *.png

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

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

Conclusion

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

Let's make your dream game a reality!!

Level: Intermediate
Video Course Length: ~10.5 hoursĀ 
Unity Version required: 5.3+

Transcripts

1. #0 Intro: Welcome to the introduction video off my new video course about how to create some kind off Gallagher style. Yes, reedy game. In this game, you will learn everything about or most important stuff about particle systems. You will learn about how to create your buttons off cools, text elements, some animations over here as well. You're gonna learn how to interact with a different enemies and stuff. We're gonna blend and taxed. We're gonna get score when we're shooting down. We also create all this year fancy animations as well We gonna get go over into all these effects like the trails on the spaceships. We're learning how to destroy them, how to actually let them fly onto a pass. As you can see over here, we're designing all these passes by hand. By creating our own past creator or past script, we're gonna have the possibility to lose a life as well. We're going to go over and cover it so that the formation is spreading out and off course. The enemy ships are going to able or be able to suit you down whenever they're coming out of that and going out of this, you have diving stage. We're going to create this little game overseeing Where we gonna be able to score or safe score into a show score into as well as what? The highest level you actually have reached were able to touch the screen to continue by hitting the mouse. And we're gonna go back to the basic menu scene. All of that, and probably even more is going to be seen in this complete, not Gallagher year tutorial. Serious. So I hope you gonna be my next students. So come over here and rebel course sinks a lot for tuning in, and I hope to see you in my new North Gallagher course. Totori a serious 2. #1 The Concept: Hello, ladies and gentlemen, boys and girls, my name is Dr Man, and I will teach you about how to create a gale against Reedy or even two D game within unity engine. So in this part, I want to talk about the concept we are actually forming within the game engine and what we need to create, how we need to connect each part with, you know, with all the other parts, as well as how to get everything together into this game concept. So let's start with the player. So the player is going to be the spaceship in the bottom of the screen, which is actually moving to the left and to the right. Well, that's basically how it is going to be done in the older version. So there was no free movement and stuff like that. It was only like going left and right and meanwhile holding down, for example, or just moving. You could also press another button and extra partner. We're just doing the shooting like forwards into the forward direction upwards, whatever you name it. But what we can do is we can, since we are able to do it. 3 60 movement. We can even do that if you like to. So we have the possibility to move the player through the complete game field, I would say, And if you think this border is going to be the complete Bay Playfield, then you should be able to take your Blair and move it around whether you like to, as well as do some shooting in the direction it is looking. We don't do any rotations, will just basically go left and right without any weird things. Maybe we're gonna do some leaning left and right. Well, we'll see that. So the easiest one is going to be the player in this complete concept, since he just shoots forward and tries to hit enemies was the Bullets. And that's basically everything the player needs to do and, of course, does not get hit by any bullets. And whenever it is going to happen, of course, he will explode loser life and restart all over. When we are thinking about the enemies, the enemy's usually come into like these triangles here. They're flying on a specific route to pass into the game whenever the game starts or the round starts, or let's say the wave starts. They're coming from somewhere at first. So why do they come from any spawn point? We can declare at any position, but best way, of course, outside of the game field. Otherwise they will pop up anywhere and we don't want that. Also, we need some. That's a time in between those way, so we can actually put the spawn point a bit above. So there's a loft off time into it. Then we're gonna need to go declare how many off these ships are going to be. Come out per Let's April level and this is going to be represented by this complete formation. In total, we gonna have a far for big ships which are going to be at the very top over here. And Gallagher it waas so that these are going to be like boss ships. They have more Hell's like a medium and even more than a small ship, for example. So, as you remember, the medium ships are going to be the especially in the first ones are going to with wasps. So these words are a maximum off 16 inside this rose, so eight per row over here and this. More ones are going to be those flies in the very beginning, and they're gonna be in a grid off 10 by two. So 10 in the bottom and 10 and the in the upper line over here. So what's going to happen here? Is that the system or we shoes? How we want them to spawn per level, for example, like how many we want to do and how should they actually act? So what we can do is recreated for us the past system where these little year objects or this our spaceships in this particular case are flying on this year created pass until they hit this point of a year long like somewhere in the centre off the game feel wherever the last point is. We also want to do is after what we want to navigate those to this slots here so they are actually automatically arranging themselves and then rotate in the direction that they're looking upwards. So that's how would they are acting in Gallagher, and that's what we're going to deal with great at first our own past system, which is going to go until here off course, you can put it like the end, like whatever you like. So whenever they are inside this formation, even before that, the formacion itself, which is going to represent the complete information field, will move to the left and to the right, until there's maybe the screen is hit, or maybe a specific distance from the center of the game field is going to be hit. And after a given amount of time, probably one or the other spaceship which is still alive and we haven't shopped them is going to take, let's say, a diving pass. So this diving passed again be like can start wherever we want to. We can set this to wherever we want to, and what we say is after this, given amount of time, we take one or the other spaceship and, of course, leave sometime in between and let them go and dive. Maybe on this green, past the diving pass until they're once again hit the center point and then they go back and move into the formation except off course. They're not available because they died already. Then there is no point into your driving them back into the formation. But clear the formation for example, and off course. Then we're gonna have this losing and winning conditions we're going to talk about meaning when no, our spaceships or no enemies are left and all the fourty This is a complete number off. All these or 40 per formacion or per this particular level are destroyed. Then we can move on to the next level. So this is basically the wind condition. And we're losing, of course, when the player has no life left and we also talk about these enemies directly, like giving them some hell's how to interact with the bullets were shooting. How strong are going to be thes bullets? Do we want to have some special items to collect or gold or something else to collect? That we can do that as well as off course, when these enemies are moving like down, once that that they are able to shoot into the direction of the player, for example, or straight down as well? Also asked, It doesn't really matter so but this is most of the time what they do whenever they're on diving. Also, a possible when they are going to be in fly in. We just need to take care that they're looking down. What at least a bit tone was like under the zero line. I would say so. Not looking too much up but down. So it's looking better also for the player itself for how this shooting behavior is going to become handy. So that is going to be what we're going to create in this course. So I believe we're starting was the past system because it's going to be the most. Yeah, the most heavy code wise. And when we have our first passes, we're going to go to the formation. After we have set it up the formation. We gonna combine these two together so we are able toe, let them fly on the pass and bring them into the formation and stick to that. Later on. We gonna go and create those diving passes and giving them the behavior that they're able to dive around and go back into the formation. Until off course, the player is down or the ship itself is down. We also once again go and and take a look at these numbers over here you can lay down, of course, put in any number you like. But in the original Gallagher, there haven't been more than 40 spaceships or war store flies. Whatever they have been inside one level per round or pill level, actually. So what we're gonna do is we cracked this great of some kind of spawned management system which is going Teoh take a given amount off number off small ones, medium ones and big ones. Purse born round, I would say. And then we spawned them one after another inside of that, flying in, doing whatever they have to do. Wait until everything is corrected in here and then we let them dive. Hey, And if we like to So in all of that once again is part of this complete serious. So I hope to see you in the next part, and I hope to you're going to enjoy this one. Keep in mind, this is actually going to be according heavy. So And if you're a beginner, watch closely. Whatever. I'm typing in. Probably Kerr. Yeah, take Screenshots. Whatever. End. Just Yeah. Look what I'm doing at this point or at the point off what I'm doing when I'm doing and eso let's get into it and let's create. I will Gallagher First Gala Gacy No would say so. Stay tuned and thanks a lot for watching already. 3. #2 Straight Path 1: Welcome back to the course in this part. We're starting to create the past system we're talking. I was talking about in the last concert video about the Gallagher game. So what we need to do is of course, we need toe do a lot of coding and we need toe rearrange a lot of things. And of course, we need to understand one is going to happen on these past finding systems. In this particular case, I will pass is going to contain several years. Let's say wait points we're going to create. So we start with the rez, a simple system, and we're gonna increase it over the time. So probably this video can bear be a bit longer or I'm gonna split this into several parts . So let's get into it and trying to understand how the complete system off the passes or pass system, it all is going to become working. So what we want to do is we want to create our first see sharp script, and this is going to contain our past. So just name it pass, and don't forget to hit. Enter, by the way, small tip. When you're coding things make sure, the consul in the game and the senior of your visible the full time at the same time, meaning when the consul gives you an arrow and you only see this like here in the bottom line, whether Zgray is like under that you easily can miss it. So make sure that the consulates next to your game views whenever you're depressing on the play button. Or even if you're just doing added to scripting, then make sure the consul was always fully visible. If it is not visible, goto window general, and then make sure that the console is visible. So this is important. Also, you might want to check a row pause as well was later on. We're going to talk about gizmos, but this is only part off the game view over here. So But once again, for the moment not important later on, we're gonna make use off it and all. OK, so let's get into past yeah, scripting. So when we want to do is we want to open this one up in mono developed or visual studio, whatever you please like, I prefer model developed since, well, unlike it's gonna zoom in a bit and open this one a bit more up. So what we want to do is we want to make use off a specific function which is sitting in one of behaviour directly. And this is off time void since we don't return anything. But what we want to use is 81 draw gizmos function. Make sure that you type this 11% correct. Otherwise it might not work. This one is running in editor space and Editor time. We don't need to press any play, but nor anything else. But we need this to visualize our past. So at first we want to create is a straight past are gonna commence things out and sometimes a student seem to struggle with commanding things out and forget later on what the heck is going on and why doesn't it work as it's supposed to be? So this past is basically later on sitting on a holder object and everything on its child are going to land into a list or an array off a year off the pass itself and so we can select it and rearrange it. Just the game object itself, and we draw the past between those points or this particular game objects. So four straight past once again I gonna give it a color over here. So just any color we late on one to sign Name this one I think, is public. Otherwise I cannot change it in the inspector's Oh, make it public color. And I call this may be just passed color. So And we can actually has set this one to already be maybe color doored green or something , or gray or whatever you prefer. But to make sure that you see this so green is actually rather good to see, so make use of it. So what we want to do is when we are once again creating or pass in the on drugs most function we only want to draw this first. And meanwhile we moved things around. We want to follow or have everything following up correctly. So we want to do is we want to set the color at first in a side this so we can say gizmos don't. And now we want to set the color off gizmo to be the past color we have created. So it's a gizmo dot color is equal to pass color. So whatever we have said in the Inspector is going to be come onto the gizmo. Now when we want to do is want to pit, put all the child object off the current one where this past is going to be on all the child objects want to put them into an rate. So what we're gonna do is we crane, I transform a race or transform and with square brackets behind this say is a array off time. Transform every gun I'm name it maybe O B J array. So for object of rate. So every child off this array we want to put into and this array over here like every tired off the game object where this past scripts sitting on How would we do that? Well, it's rather simple. We just fill the OBE day array we just created and we said, We want to say equal toe, get components in Children with this one, and we want to say want to get to transform component, open close fantasies and close the line was a semicolon. So we did say here we want to fill the array. So once again, the array in this particular case is going to be the one which is holding a lower data based on the Children into that. The next one is we want to make sure that we have a list where we know place everything inside. So this could be in public or actually also a non in public. One can be a non public one, but we want to see if everything works. So I make this from public, so public list and open close those trying of brackets, and this is going to be also a type of transform list. I'm gonna choose list because they are dynamic and changing dynamically the size of itself so we can actually put in things and to take away things. And the lengths off the list is automatically you are going to increase the decrees based on that so we can do this in runtime as well s in inspector time. I would say so, and we give it a name. So this is going to be our Passover J list. So past o B J list. This is the list we're gonna to take light on to read from. So it's a new list so we initialize that already It's a new list of types transform open, close parentheses, end off course once again, close the line was a semicolon. So meanwhile, we have now everything inside the array. We want to make sure that we also put all of that information inside the list. So all the Children objects in the object of really want to pass them into the list, but not the parent object first. Before we can do this, we gonna say we need to clear the list because it is always updating itself. Meanwhile, in Ron tie our inspector time. So it's running the world time all time. So what we need to do is, before we go into the next step, we need to say Passover J list don't clear. So we make sure that this is an empty list when it is done. So far, the next one is we want to put all Children into the list. And so what we're gonna do is we take a four loop or for each basically doesn't really matter, since both are doing the same before, each is a bit simpler since we can say, for each type of transformed. Then we give it a name is going to be our o b J were looping through Then we say in and then we take the object of right so b j array. So every time we are or we now loops rule the transforms inside the orbiter, Ray And we say if our O b J, meanwhile we're living through is not equal to this don't transformed. So this is not going to be the transform where the past is going to sit on. Then we want to say we want to add this particular object we're currently looping Throw to the O B. J of the Passover jailers. So we say Passover jailer's daughter ad. And now we add the current one we're living through, which is going to be over J. Once again, the O. P. J. From here is going to be represented. Or basically this one we are currently looping through in this for each loop. Okay? And that's pretty much everything we need to do to fill the list automatically by the points. And we can feel the list automatically. If you don't know what's going on, we can easily go now and to our Ah yeah, unity And that the compiler run, we can create a new empty game object and that we recall this one past holder. We cannot seem much by that, but we can on this pass, although we can put in pass. And as you can see, there's going to be a passerby J lists now. And when we, for example, created you empty over here into this pass holder, it's automatically getting added where it was in the past or B J la's by this object even if I now renamed this like past point as a name, like so it is also getting written on updated in here. So this is basically the foundation off all this point. So we can also take another one. We can duplicate this one, and so now we're gonna have to off these in. So in our past over J list. So this is working already pretty much fine in the next one we're going to visualize in the past. So the straight past and so on and so forth, so stay tuned 4. #3 Straight Path 2: welcome back to the course In the last part we were starting was our past and how toe automatically feel in all the past points into the past of the jays list. So in this point, we're going to go forward and visualize the past. So what we're gonna do with that visualization as we can show that you were You know, whenever whoever is going to set things up, for example, we want to see where will pass is actually on because we cannot, like, tap the world time onto the game Mounties and see which one is the correct one and so on. We want to give it some nice look. I would say so after this for each, whenever we had done with adding these components, we want to draw the objects. So drawing the object is going to be we want to highlight them with some gizmos. In this case, we're gonna make use off a four loop, which is actually looping or the past LBJ's objects. So we say in here where Max is standing with a past LBJ's list don't count. So the we are looping as long as until we reach the amount off the objects inside the past list. What we want to do is we want to create a new position, Rector. At first. So it's a factors, Ray. We call this pause on position. It's up to you once again. When we're gonna do is with that position we need to store this position off the current object. We're looking Struve. So we're gonna take a pass of a J object list and then we're gonna take I as an indicator when index we're currently looking through. And then we take its position. This is the position we're storing in the position vector over here. So we're gonna store this here now. When we wanna check is before we do anything else you want to see if I is greater than zero If I is not greater than zero, Of course it doesn't make sense. So we do not take the first but the second place. Yeah, the second point, actually. And at this point, when I is bigger than zero So we are in the 1st 1 We want to set the last one the previous one to be the the past of adjacent this zeros element or asked the element which came before. How do we do that? We say we'll create another vector. It's going to be the previous point or the previous game object. We said this want to be equal to Passover. Jail is in square brackets. I am. Mine is one. We can only do the setting miners one until or meanwhile I is bigger than zero when it is already zero. That would be a negative number and we would get ah out of range exception or something like that. So and we're gonna take its position off course. So this is the start position where we're drawing our base on the first line from and then we paying basically to this position. So from the previous position to the current position, I would say so. And what we're gonna do is we do this in here like we draw a line with the gizmos function . So gizmos, daughter, drawer, line and where we want to paint from and where do we want to? Paint, too, is, as I already explained, we want to paint from the previous to the position, and that's Brady basically it to see where our objects are going to coming from and going to also we want to grow a gizmos. Don't draw wire sphere. I want to make it so that I can't see this even better. And so I draw via three on the current position. So not on the first, but on the name on the current one. So we painted onto the current possession and give it the radius off 0.3. Maybe not to back, not really needed to be there back. So it's just as an indicator so we can see where the past is going to go to. So whenever we had done was that we should see our actual passed in the scene as well as in the game view. But in the game, you we might not see this. Why? Because the game you does not usually so gizmos. So as you can see, there's one wire sphere over here, and this is going to be this particular past point when you want to see this in the game, you, of course you can always unable gives mostly on the right. And you see, when I'm dragging around things here also, they're moving over there. Okay, so this is going to be our indicator and our past. We have straight set it up. So what we can do know is we can duplicate this and create a pass to our needs as we just copy and paste that. So we have strength passes. Between that, we can copy that again, and we can set up any pass any straight pass in this particular case, do whatever we like in police, and that's it. So this is the base off the past system we are creating hiding in the next one. We are starting to create a quadratic busy curve. So we gonna take this straight pass and say it so that between three points we interpolated so that we are or the system is automatically creating roundish around curves for us, we can take light on to, you know, navigates row. So this is currently our base pass. We can also already walk on that whenever we're starting to move on this particular pass 5. #4 Quadratic Bezier: welcome back to the course. In the last part, we were asked leaves you have visualizing the past hour. Objects are going to go to when they are like moving from one point to the other. In this point, we want to start and create a busier curve tool, which is actually calculating the difference between two curves or actually between three points we're giving them. And then we're gonna inter polite the amount in between those. So they are actually rounding up between those three. There's one downside to this. It's not going to interplay directly between four points, I would say, but still is actually in the easy approach. I want to talkto you about end. Uh, all is going to be working in between Aled, those here all the points were actually going to create a to. So once again, we are creating a quadratic busy a curve tool for this or actually just a calculation. So to calculate the quadratic busy curve. And we need some points in, let's say, somewhere in world space and we need to request this point and interval eight or ask the love between those three points by three different. Let's say Yeah, slurping functions. Let's start with the vector itself. So we create a function which is not often avoid in this case is of type vectors three because we return of actors three in the end. So we call the sanction get point maybe, or whatever, since we want to understand what's the point? Where or what's the current? Um, your point. We are requesting on a on that curved shape in between three indicators vectors. OK, so and the three indicated vectors are going to be P 4.0. Then we need another vector. Those are will arguments, by the way, P one another vector three p two. And in the end, we need the float we call T, which is standing for time. So this number t will always be somewhere between zero and one, and we will automatically, yeah, calculate t by by the points. We want to interval eight in between two. So this is going to be our indicator later on. What we want to do is that get point function is raza simple. I gotta try to explain as best as I can. So you hopefully understand what we're doing here adverse. What we wanna do is I type this out once one after another and then we combine all of these . So we want to create or want to say, we want us take Victor's readers blurb, which is a linear interpolation function between two points and a time float t So we say vectors, read a little herb and we want to love between two points with this first part. What we want to do is we want to take p zero. So the first vector point we are into relating and then we take p one and we take off course t as the pair of beautiful timing. So this is the first part. Currently I don't store this anywhere. It might draw some eros whenever we're going back into the inspector. What? Hopefully it's not happening, so be careful. So when we now want to do is we want to create another vectors, Riedel Herb, which is basically doing the same. But now we want to inter Pilate between p one comma and p two. So the ones, the second and the search vector. And of course, based on time T let me pretty quickly explain you what we are actually creating. So what we're gonna have as we have, like all these three points already. And where's our line? In between these three points And in this quadratic busy curve, we gonna interplay it again between 30.0 and 0.1 were loping between them based on time tape. When we're doing the same with P one and P two and were then we gonna take the time points which are actually getting created in between. We gonna get the quarterdeck curve. What is going to happen when we're having this last point, for example, and we gonna take this handle point here and treat that as being pointed one of a Yes, or we're gonna bring this year. We gonna automatically get a curved shape over here. It's a bit off answer like that. So we would actually end up with a quadratic busy curve between two points 20.0 and point to, and we gonna use this as our handler? How does it work? We're gonna have our input 0.1 point 2.3, which are going to be from our straight points. Basically, we have already created from a straight pass and we implement a time T Time T in this case is some number between zero and one cycle 0% and 100% is zero and one. Let's assume this one is no end 10.3, for example, and this one should be at points three already. What's going to happen is that we're creating a line between those two points as treat that points or this line as an extra indicator. At the same time, we gonna have this purple point here, which is also making use off time tape so between but because we want to Interpol ain't the outcome off the first and the 2nd 1 And we want to interplay between those toe alert between those two as well. So we get time t point here in the center, or basically we're gonna take the same input. So we're moving this point also. But in this case, between this calculated points and we learned between those two, what's going to happen when these are moving, like when the time is passing by one, for example, we have a good amount of different times, or keys or points, which are we are using to inter polite between P one and P two and so on and so forth. Then this is going to wonder around what's going to happen when this is, for example, wondering here. Because now this is maybe at 0.8, the timer we gonna create automatically a curve, depending on the density off. Our time fell You somewhere we're gonna talk about about the identity and the time laid on . So in the end, we gonna have something like that. So this is the timeline is going to be represented between p zero and P one. Now, we're gonna split this up. Between that. Say these three points on the other side is going to be the same. So they are going to go over here. This is like 50%. This is like 30%. Maybe. Yeah, something like that. There's going to be 80%. The same is going to happen with the purple line in the center over here. So this is now going to be the point for this one. This one in the center is going to be for the center point of in years, like the 50% between those loved curve as well as the last one is going to be like this one is going to be on 80% between those two points we have created or we gonna calculate in in just a second. So what we now need to do is we no need to inter Pilate this one and this one by time t once again. So we gonna have the cord heretic curve in this case. So when this is going to happen, like once again, we're actors Radar loop And we have once against repair Amedure's a comma comma and the last para meter once again is a time T And of course, we close the line was a semi colon. So what in the 1st 1 is going to lend all of that except the semicolon? So I copy that and put this in the first lot a copy of the 2nd 1 over here, Copy and put this in the second slot, and then we have the time t once again. So we live with within the first love factor. We love to times between the other ones. So we're going to get the Kuroda quadratic curve. What we want to do is we want to return that since we are requesting a vector, we get automatically alert Vector based on p one p r p zero p one p two and time t So this is basically how we create actually a request a point on a busy on a quadratic busy girl Between three points in the next video, we gonna make sure that we are automatically creating all this points in the in the busy curve vector and, of course, draw some lines in between and, of course, make use of the function we have created now. 6. #5 Bezier Curve 1: welcome back to the course. In the last part, we were creating the busy curve Get point function. Well, actually, for the quadratic busy curve. Also, I explained you how we're going to go through that. And now we're start coding from the very left point. Then we go and loops through all the past points now and add the needed para meters to own pass, hold, object. So at first we want to create a basic of based on points we were we can actually yet defined how many steps we want to have in between that. So how many steps do we have as a possibility? When we open up, a world has a script over here, we want to add a new interview. Uh, this is going to be a public introduced since I want to have the possibility to actually set this one by hand. Whenever I need a higher or lower the density inside that curls and since speaking off density, I gonna call this line density, and we basically don't need to set this thing up to anything. But maybe we want to set a least one so meaning at least one point is on our busy curve. Also, I want to create a slider for that is going to be in square records. We can say range, and we want to set us somehow between one and a maximum off 20. How does it look? Let's pretty quickly look into it whenever we're going back to it, Teoh Unity. And here we gonna should have a line density slider. So currently said to be one we can put in a number or we can arrange that so that we can slide this one up and down to our needs. Do yourself a favor and don't overdo it. 20 is more than enough for depending on how long the distances are between those curves off course. But in the end, we don't need more than 20 I believe, not even more than 10. What we also want to have is a new list, which is taking care off all the points on the busy curve. So when you want again, remember these purple points over here. These are going to be the points for our busy curve or which are forming our busy curve between p zero and p two. So how do we do that at first. We create a new list off time vector story in this case, and I'm gonna put the line density perimeter on top because I want to make sure that we don't have any weird, um, stuff running in the inspector. Meanwhile, we are adding to the line density because at the moment we started with the public list off that later on, we can just make it private. So this list is in this case off time vectors, Ray. And it is our busy o b J A list. And we're gonna set this one already to be a list of time factors. Three open close parentheses and close the line was a semi colon, as usual. So may meaning. We can instantly put in data into it without initiating this one in start, which is actually we are not needed. Okay, So based on that line, density, we know want to fill in points calculated by our get point function we have created in the last video. And we want to do all of that inside the on drug Esma function. After we're done with this four loop over here where we are point painting the green gizmos and the green lines basically at for us. I gonna make a small command in here. So that means everything after that is going to be about the curved past or the busy past. Once again, how you command things out as out is up to you. Make notes as much as you need it. So you have no problems. Where's some Your photo ops later on. Most important, one is I put another one here. I want to check for an overload. I'm gonna explain this a bit later on. And after that, the first thing as we already have done here with the past of jail, is we want to clear the busy or B J list. So we say, busy opened a list dot Clear because once again, the on drugs malfunctions always running inside the inspector time. So meaning we always have to cleared and refill it automatically. So we don't need to take care of anything else. So this is the most important one over here. Then we want to do we want to set our lines start for the first loop ever. Meaning we want to take this first point over here the first past point, which has, like no gizmo. And we want to take this as the first point as an indicator, Where do we want to start? So we created new vector story, and we catch that into that particular point into it. So and since we know where it is, we can say we name it Line start. It's going to be equal toe. We take this from the past, obeyed a list from the first element in this case element zero and would take the position off it. Don't forget, the interline was a semicolon. So now we store the line start based on the first position in the past, no matter where it is. So what would know want to do is we want to look through the complete Passover Days list, check for later on check for an overflow or under flow, and then we're gonna create all the points of based on the victors. We get point function over here and fill its insight the busy O B J list. So that's greater. Fall up. So we type in four and double tap on last time. I didn't explain this pretty much. You pressed tap twice after you were typing for and it should automatically fill up the data. So I was going to stay at the end. I is going to stay in Same. Since we have this other fall appear and close already, we can still use or once again use I as an indicator to neutral or our index were taking for this. So what we're looping through is in the second perimeter here. Once again, I keep this I This one here is going to be our past o b j list dot count. So the amount of points we have in our list we want to look through them. Now the fun part comes Gonna go back to escape pretty quick. We want to since p one is going to become declared as a handle and not directly as a point . We go now we want to over hope this Oh, every one point like everyone, every second point in this case, you want to hope over this because we're just using this as an handle. What do we do? Is I at this point is going to be zero. I at this point is going to be too Meaning Usually we say I plus plus and we would run from this point to this point. But since we want to know, take this in consideration, be over, harbored by saying I plus equal Duke So meaning we hop over. We add toe I when it is at zero, we attitude to it and we over hope this one and go to this point. Otherwise we don't get a curve. Otherwise, it would just be a still straight line sins once again, we already did this over here, as you probably remember. So basically, it's the same. What we start was but we over hopeless or every second point in the past over days list. Now we create in nested for loops. So we type and four again and press top twice again. And is this indicator here should be a j indicator. So this straight this is J and this is Jay. Or you can also take any other letter except the I letter. So and what you want to do is marks in here is going to be smaller or equal to our line density para meter like this. So if day is smaller, equal the line Danza de Pere Amita. Somehow it doesn't let me do anything. Yes. Oh, So if J is smaller, equal lines entity, we're gonna go and hope forwards and go into the next point. So now line density becomes the number. But on this points that go back, Teoh this the number we want to take here inside this loop. So when we say we only have one, we go from here to here. It's a straight line in between 10.1 point two. If we have a two inside, we're gonna have, like, a center point over here, and we have, like, a little triangle. The more dense this part is going to bay, the more numbers are the poor morel identity we have, let's say 10 points then we have, like, 10 small points on this line curve, and we actually can shape this particular curve. The more points we have, the smoother the curve is going to be. And we're gonna you need need this points to navigate our ships around on based on these points. So that's important that we're going to use those. Okay, So what we know want to do is we want Teoh, calculate the next point after line start. The next point in this case is going to be off time vector sri again. And this is going to be called line and and line end is going to make sure that it is using our get point function. So we say get point And now we pass in all important para meters here. What do we do? Is we say at first the first point, though, so p zero is inside our past. Oh, BJ's list. Then we take the index pyramid off eso in square brackets iDot position. Then we have a next point. This is going to be P one. In this case, it's basically the same a copy that make sure that you always have position with it and in here in the 2nd 1 is going to be I plus one. So the next point from the current point, we're hoping stroke. Then we have another come over here and said this I plus two because this is going to be the second point in the list. And then we have the time. Pyramid A, T and T is now the interesting point because we want to take the line density and consideration so the higher once again it is the further or the more often we gonna look through that, get the point function and get the point function based on the percent age, the current point where looping throw on the curve based on the line entity. So what we say is day and not we divide J by line density. So, Jay, once again, it's a current point we're or the current entity were at. And since we wanted to have a float number between zero and one, we need to type cast a line density and to afloat. Otherwise, there would be just an outcome of zero. So we say, in open close Prentice's before line density, we type and float. Oh, right, so so meaning we know Take J and we divide day by the lined entity to is to get a number between zero and one. So if J is equal to line density, it is one. If it a smaller like if Jay is five and we have aligned Entity Off 10 than we are at a zoo 100.5. That's what this mathematic calculation is going to be for? Don't forget to enter line. Ah, Wizard Semi Colon. And when we're going back to unity right now, we should get a lot of Eros. But that's OK. And what we're gonna do is the next port. We are actually fulfilling the rest of this. As you can see, there are some argument out of range exceptions but police continuity within the next video . Otherwise, this video would just be too long. 7. #6 Bezier Curve 2: welcome back to the course in the last boat. We were actually starting to create the BZ curve part and what we now need to do to need toe check this overlord in here. The point was, Dad, as basically since we currently don't check for an overload and we're going hoping like twice over it, we would actually go over the size off this account over here. And actually that is going to give us this argument out of range exception. So before we continue with this point stuff and here and visualize the sink we actually want to create, we gonna do the overlord check kerf create a nation once again, I just commend things out once again, you can do the same. And when we don't want to do it, see it. We want to check how big is the size off? The Passover jail is and isn't an even on uneven number. So if past O B J list don't count and now we're gonna take a model. This is a percentage sign. Modelo too. So and then we check if that is equal to zero. What this model doing? Uh huh. I'm gonna open a pair off curly braces. And here now I let me explain it. For example, if Paso PJ list size is going to be off five and we take model or two, it say's okay, I gonna oh, only go up to two, and then I reduce the number, whichever is inside. So I say this sets it automatically to straight, but still, model comes in place and it want to negate this 12 B minus two again and we end up with wasn't number one. And this number one is the outcome based on model or and if it isn't one, then it is not going toe work because we're checking for an even number, even number. So since once again, this outcome is going to be like that, it is an uneven number. So we have to create an else statement over here. You don't need to type this line over here. This is just for demonstration purposes. So basically, this year, lens over here and would be automatically an uneven number, so on even. But when this one is going to be a four or a six in at the very beginning already and we say okay, we take Modelo to, then we take model or two again at this one would return is zero. And that's where we can say this is going to be an uneven number based on the model 02 over here. So what do we do when that is going to happen? I gotta commend this out. Since we don't need this any more. What we're going to do is we add an extra point to the orbit days list from the from the a bit tasteless, and we set a specific number to be our overload protection number. Let's create this number pretty quick. We can put this wherever we want to do is going to be just an interview and I call it overload. You can once again name it whatever you like. So I copy this name already, since I created that just to make sure I can go forward. Rez. Acquit. So what I do is I sent this overload here, Toby equal to two. And when it is an uneven number, I sent overload going to be equal to straight. So now we want to overload this function when it is even. We want to make it uneven, meaning we need to add an extra an extra object to our list. So we want. So this is going to become an uneven number because as you can see, this one here, this triangle here is an uneven number as well. And since it's a quadratic busy curve, we gonna interplay between three points and totals on uneven number. So when it is uneven number, our system would just wouldn't work as we created that. So what we do is we add to pass over jailers and the extra object. So it's a paste past O. P. J. Listed and up close parentheses. And in here we want to add what? Well, we want to add the last object from the past of the chase list at the position, wherever it is currently. So we say pass up a J list in square brackets once again Passover J list and then in square brick No. And then we say don't count minus one. So we take the last item or the last past point, and we basically duplicate this in every. Add this to it. Otherwise we don't get this overload. Right. So what do we do is this overload Now, actually, and this follow up over here, we take this count and say, Since we're adding a 1 to 1 more object of here, we reduce the number by this overload number. So we say minors overload. At this point Now, we can also say Okay, we have an uneven number and we want to make it even. Basically, we can do the same. We just take an object and add this to it. But actually one is not enough. We have to add to, since we are overloading here with three numbers. So we added two objects over here the two times the last object we've added and recreation of a load off three. So we actually did tremendous the complete of the load by three. At this particular point, we're no good. Go and suppress safe and go back to our ah, unity over here and let the compiler run pretty quick. We probably already get rid of all the argument out of range acceptance So clear the concept and yeah, tested out. So as you can see in the past, Holder, we already duplicated this object over here two times. But our pass is still looking the same. So we can basically manipulate everything in here and depending on the size or the density off this year later on, our calculation is going to run. But currently we don't visualize that. So what we're gonna do is in the nest. But next part of were going toe visualize that passed, and we gonna add everything to the pay their O B J list so we can move on it. 8. #7 Bezier Curve 3: Welcome back to the course in the last port. We were getting rid off the argument out of range exception just because we have to have to do this overload check. So we're not over doing it depending or independently, no matter how many points we have in our past opened a list. So the 1st 1 the green one we have created in the first place. So and once again, we overload. Check this one over here so we don't get any out of range exceptions when we are adding the overlap load and Grassley, decree menting the count by the overload over here. So what's currently happening is okay. We have a line start. We have a line end. But what we want to take as actually or what we want to create is a visual ization for this . So what we're gonna do is at first we say we create another guest. Most so when we set maybe a color off Rhett, so equal color gives most of color equals color dot Red. You can once again choose any color you like. Now, once again, we draw a line, so he's a gizmos dot draw a line And since we have done that already, you probably know it is taking from enter too. So where do we want to take? This room is going to be from line start and then we want to put this to line ends. But this is not completely fully working. Why is that so? Because at the very end, I want to set line Start are so I want to override line, start. And whenever the loop is completely done to be line and otherwise the system will not work . Let's test it out. We're gonna visualize even more in just a sec. When this compiler has done running, I have to select the window every time eso and check the compiler at the bottom right where the circles you can see. We have now a red line from the line. Start toe the line end because we have a density off one. If we are increasing now, the density to do by the slider you can see we're gonna get a triangle, and we can go with prison Prison first and first until this is going to be a super round Pisa curve. Currently have identity of 13 once again you play around was dead a bit. And what I want to do is even a one step further. I want Teoh. So all these points by using some small drawer wires, fears over here s well, so we put them before the line start line and override. You don't have to, but actually to visualize them even further or better, it might be a good choice for you. So what we do is here. We say again, gizmos don't color in this case, it may be, is going to be color. Don't blue and I want to set once again or want to create a wire spheres of gizmos dot drawing biosphere and in open close parentheses. Once again, we declares the center first of the center is always line start, comma and then we want to set a radius, maybe off 0.1 f or something that doesn't need to be that take. It's just to ah visualize for us that we're on the right track. So let's see. And that's check. If all the points are going to be shown, there should be no a blue one. Well, online start, but not online end. And when we know increase that. As you can see, there are going to be all these points now on this busy cough too. So when we're now copy and pasting the next pass point, just do this. As you can see, there will be another set created. Do this point over here once again, we would now have an uneven number. Oh, In this case, it's an even number and we add two more points into the pass holders. The best over jail is, as you can see. No, In this case, it's one s. So we add one more, which gets duplicated because it was a even number. So we need to make it uneven. And in this particular case, and when we take this point again and duplicate that and bring this to anywhere else, we're gonna have another kerf once again. This is because we are creating a quadratic kerf in here. So now I can also take this point and bring it so that that would be almost a circle. The downside was the quadratic curve is to perform a circle you need, I believe, eight points instead of four points. But that's fine. And I hope for you as well off course. And of course what we can see now. The four number four here gets duplicated two times. So everything is working 1% correct. Now, since we don't have this vector data from the points, we need to actually take them and bring them into the busy or BJ's list. Otherwise, we are unable to walk onto this past because we don't know where these numbers are. We are this. Things are going Toby inside. So how can we do that? Of course, is there is a simple in. Before we gonna draw everything we can just say Busy opened a list dot ad, and now we want to add Well, what do we want to add? Of course, we want to add line. Start Once again, we have line start ears. This is going to be the first object in this less so. Meanwhile, in the first loop, line starts gets added, even if a line and is already created or calculated. Then we override line start and the next turn. Basically the next like line end is going to be written because it's now copied inside of Line start, and that's how the system is basically working. And as you can see now, the busy curve or the busy over J list is going to become filled automatically by all the blue points over here. When you want to, you can actually go and yet see how these factors are, where this victor's actually are represented or where they are located. And every time we don't change anything, the busy curve is automatically getting updated, as you can see, like Element 26 in this case is going to be the one here. So how does the size now can be 27? It's rather simple. We have a line density, which is actually deter mining. As you can see when I go up and down, this one is going to increase and decrease bythe size off. Whatever this. So when we have a size of one, we should only have three points, right. But Element 10 is going to be duplicated or actually setting up two times, and the same is going to happen for the second point of view, which is stare on. The last point, of course, is the final the end point. We already have set it up since they are duplicated numbers over here before we are going to do anything wrong, I want to show you something. Please take this busy. LBJ Last line start. Cut it out and please bring it under the line. Start line. And here. So we're going to do the drawing. The calculation. Then we override line start was line end. So basically the first point overhears still going to be the first point. Then we're gonna add this line stars at the very, very end off this for look, when we're doing so we can actually see that these numbers are going to change to three different numbers based on how many points we're gonna have in this case, we have a line density of to and what does it mean is now we can control these points by using an empty game object. And, for example, corporatist vote takes numbers in here. So when we know adding to them, everything is correctly set it up. So when we have one line density, we only have two points. So the first point and this one is going to be the second point. Once again, you can always manipulate that and check it out where it is currently at all. So you can see since is the correct point on the past point to You can take this values in this will you like this? That and the X value. And you can actually, yeah, check if there's the same anti shirt. So you have no a complete physical of line tour busy curve, which we can actually make it more dense or even less tense at the moment. Once again, 20 is going to be the very last point over here or the most, the maximum point plus one, since we are actually having at least one poor activity two points in here. So too, is going to be always the smallest size. When we have a line identity of one when we're would have zero, that would be, I believe, a lot off argument are arranged stuff. We don't care about that because line then, that he has a minimal number in this case, off one 9. #8 Moving on Path 1: welcome back to the course in the last part, we were actually finishing up our complete busy life line tool. So, actually, now we can form passes where our enemies air going to pass along or are able to go over. And that's what we're gonna do today. We want to start Teoh here, move our enemies around. Meaning we need a new script in of cause one enemy at all. So we can basically take anything we would like to or are gonna provide some off Ah, off my spaceships and give it to you. So you have anything you can work ways. Okay, Is that we created first and you see ship script and I call this one. Let's say enemy behavior The point is enemy behavior have will contain a lot off informations and meaning Also moving on a pass. So meaning it is going to go into Formacion. It is going to dive around as we already talked about that the very first video. It has a lot off different states in which it can be. And I want to go to all of that or go through all of that. So we are designing Ah Yes. Let's a solid and well proven enemy so we can actually make use of them as we like employees. So one do we need for our moving on a pass at first? Of course. We need to pass toe, move on So I can say public off time pass. This is what the script we just created beforehand And we, for example, say passed to follow. We can also name it, whatever we like and police once again. But too, if you're full up correctly, maybe you want to take the naming convention over here. Okay, So this is the past we want to follow with our enemy. What we need is three or four different, very able to be. They are belonging to the past. So let's say passed in foes. I gotta command things out once again. So this is actually what I do when I'm working on it. What I want to have is an integer which is going to be off time. Let's say we make everything public for now so we can see easier in the inspector and later on we get rid of everything we don't need to. So we have a current way point where we are starting Ed and that we can also name its current waypoint I D. Is. It is a bit more or less. It's just a point on our past. What we also need is we need a speed very able. How fast I would make moving from one point to another. So is a flute speed equal to, for example, you cannot name or take anything you like in place. So another of our most important one over here is also type float. This is going to be the reach distance, the reach distance is a distance to the next point we're currently flying to. So if the distance is smaller than, let's say 0.4 f, then we have reached the next point and so we can go further. The clothes that were going through the next point the let's say not so smooth movement we gonna have. So Okay, so the next one is we want to have another public one in this case, a float. This is going to be our rotation speed. The rotation speeches deter mining. How fast we're moving around the corner to look to the next one to the next point we want to reach. So this is the next one we need at first and for the moment, then we gonna have some a regular info, some normal inflows about, For example, what's the current distance? And maybe we gotta start? Was Dad So it's a public float? Well, actually, we don't need this. Want to be a public one? We don't want to see how far we are. Way eso it's afloat distance. And since we're recalculating this one like every step, it doesn't really matter at all. We don't need to feel in any data, but we need this once again, Teoh see, once the current distance so the current distance to next point or next next waypoint, I would say so this is going to be measured. And according to that, a distance, we gonna check against reach distance and then we react to everything and we're gonna do, like increasing the way point. I d, for example, but once again, we go over this in just a second. Then we can also put in a flute Noah Bullen, which you can probably make public so public bull and there's going to be used busy. So this is maybe something What we want to take in consideration later on, if you want, just like his exact movement, like on the green past instead of the red past. You may want to deactivate us or just not activate. So it's using the past point, um, or the past o b j instead of the busy obeyed A So that's what you want to keep in mind Are gonna set this one true fourth at the very beginning. Basically, when you have something to be fools, then you might not want to do anything. If you want to set this one to true, you're absolutely able to do so and everything. Every time you, for example, create or put this onto a new game object. This is going to work with that as well. So I gonna go next. Teoh, how do we actually move to the next point? We're gonna later on create a state machine which is actually deter mining in which a state we are. But at the moment, we just don't since I want to keep it as simple as possible to move on to our past, we know create an help of function for that because later on, we're gonna have, like, a lot of stuff running, and we want to keep it as clean as possible. So we want to say we want to move on the past, so move on the past and what we want to have is an argument is, of course, a type pass. So ah, since we laid on Ken or are able to do use different passes, we only need Teoh. You know, saying only this one is going to be the one we're actually requesting. So what, we need to do it as at first, we need to calculate the distance which we already have created as afloat. And we want to know from the current position to the next way point i d how far is the distance and then once again react to it. So what we do is we measure vectors. Three don't distance within that. Then we feel earned the perimeter a and base. So where do we start at as Ashley, the past a dart, and that we're gonna have the past LBJ list which is going to be this one we have created in the last videos and what we want to request over there is the current way point I d. So whatever the current weight poor I appoint I d in the past, like in here is going to be the number off the length off the pass of the J list. This is the one we are actually looking for. So the next one is going to be the transform don't position. So we are measuring the distance between the current way point i d. In the past over days list. So once again, this is going to be the same number between those two scripts were So we talk back on force and since we have a public one over here, we're gonna drag our current past just into this. So and once again, we measured the distance from this I d pass or pious I d point and measure the distance between those two. Now, what do you want to do is we want to move forward to the next point. So we say transformed. Our position is equal to, and now we say, vector three don't move towards a point. So we say, move towards. And now what? We want to do is we want to move towards from So the current one is going to be our transform, not position. Come on, then We want to send We want to go to the past. Don't pass over J list in square brackets The once again the current weight point i d And then we say we want to set Ah, speed, variable. So we say speed times the time dot Delta time so And of course, don't forget to close the line with the semi colon. It might be a bit too big now, but hopefully can see this. So this is going to be the speed variable. Hold fast. We're moving. This is the point where we're going to This is the point where we are coming from coming from. This is in this case, our actual yeah, position we are at in update. We want to go move on past and on close parentheses and close the line was a semi colon. So this enemy behavior script deter mines Where want to go to Of course. In here we need toe set the pyramid a pass to follow because this is at the moment of the past. We're going to follow up, so we need to drag it into here. And then we said, There's one over there, so this should not be any problem all over the place since we're using here Game object. We need to say dot Position I guess since this is going to be of time transform and not of Victor's Ray So we're gonna put in the current weight point, I d don't position over there and the same is going to happen and the second line so we can only transform to the current Don't position over there. So the past Oh, PJ's list current waypoint I d don't position. So we're gonna need vectors instead of just using transforms. That's what we need to put in a dog position. In the very end. When the compilers done running, everything should be good to go, and we should be able to follow from this point to this point to this point, and then we're gonna get a argument out of range. So let's test this one out. We gotta I gotta implement a spaceship. So I gonna give them for free to you. So you are able to don't know them probably in this lecture, so check it out or it is somewhere in the project. So this is going to be an fbx file. So before you import things, you probably want to go on creating human folder, maybe a three D Models folder. And in this three D models, older. You wanna implement like this your first enemy ship, for example. And just so we're able, we are able to do something with them. So as you can see, they have some colors. Super low police. So, actually, nothing fancy for us and not so important how it is actually looking. You can export the materials if you like to, or just put on your own. This is everything is up to you. I just keep in m m s day are and I just a direct my ship inside of that, as you can see, is located over here, and it's that value is that X is going to looking forward. So when your three D artists make sure you know that access is always looking forward when you're exporting your spaceship. So to keep that in mind or actually to keep it updated, we want to go and create another folder pretty quick with all our script inside, since we haven't done that in the last one and we're gonna drink our both scripts into it. So later on we find them easier because we're going to write. Yes, everyone's so one enemy ship one I want to drag enemy behavior and I want not to send the use busy because it's not implemented at the moment. And what I want to do is I want to drag him in the past holder. So the pass holder contains the past script, and now he's should be able to move along the green pass whenever we're progressing. Polite, let's say if that is working, so he's going to the first point. Oh, but he is actually only going to the first point because we're not incremental ing the number the current way point I d whenever he is in distance, like in the distance off that. But actually it since the time has already raise along and I want to go into in the next video and we are going to continue by moving on to the complete pass 10. #9 Moving on Path 2: welcome back to the course in the last video we have were actually starting to create the enemy behaviors to move on the past as well as were implemented our first ship. Once again, you're always able to Yeah, use your own graphics and your own three D models and stuff like that. I just offer them for you for free so you can actually make use of them and test them out and whatever your police and like and do all your testing back to our enemy behavior script . We created the movement pass where we want to actually measure the distance to between those two points And until that is actually the case, you want to reduce the distance to its position. And what we want to do is whenever this is going to be reached this distance, we want now to update the current waypoint I day. How do we do that? Of course, we just need to incremental it by depending on if we're using a busy curve or not. So let me go bit down here, so I give me some myself some space. Ah, and we can actually you make use off the function off the bowling if use busy. Otherwise we would would need to to have right things. Yeah, more often. So if we are using busy than we do something, if we are not using busy is going to land into this else function. So if we are using or not using busy and they don't want to say if the distance is smaller or equal to read citizens, if that is the case, we want to increment the current way. Point i d. So we say current waypoint i D Plus Plus, what's going to happen is it's going to try or go to the next Patton toe the next past O P J list object, or, in this case index with the number like from 0 to 1, and to take its position. And then it is going to update itself, automatically rechecked the distance and move towards the next point. So it is going onwards the world time. We also want to make sure that we're checking If the current pass I d is not hard to high. And if that is the case, you want to reset it or keep it as wherever it is. So we don't have any over or under flow. So what we can do is if current weight point I d is bigger or equal the Passover days listed count. So pass don't past Obi Day, lest don't count. If that's the case, then we want to stop it. Well, at least for the moment. Or we just reset it so we can say current waypoint I d. Is equal to zero, so it's going to go in circles. Let's test it out. Don't forget to save the script and let's go back to unity. That's a compiler run by clicking somewhere. So once again, you can always check in the bottom right corner if that circles rotating or not. If there are any errors, of course, try to get rid of them before you go in. Continue and when we're now present, play can see this ship is now going from one point to another whenever it is close to the zoo point, for it is going to take the next point. But what you also can see it is like Raza far away keeping from that reach distance so, but that's fine at the moment as well as it is Yeah, always going to do the same stuff all over the place. So the past finding itself already works. Later on, we're gonna change some states and here, But for the moment, we just don't. If we're using the busy, curving tool, that's what you wanna implement right now as well, because that's what we're here for. We need to put in the first stuff over here into a if we're using busy or not. So if use busy is going to be here, we're gonna move different, then else we're not using busy. So I'm gonna put this one here in tow. Kohli braces like so So what does it mean? As this one here is only the movement for you when we're not using busy and once again same here, we can't now a do the movement based on if we're using busy or not as well at the same time . So what we gonna do here is nothing else than this one. If we're using busy, we're gonna copy all of that. And here. But we're using a different way point list. In this case, we're using the busy obi galas and also you can see we are unable to use position in here. Why? Because these are off time vector already so we can ignore them. Gonna copy that and put the same stuff in here as well And get rid off dot Position. Since that is done now, we can also check war. Where are we? Wears the reach distance and update the way point I d to this. So basically the same bought the request for this one is going to change this fall. So I could be all of that. Put that in here and of the distance. Smaller resistance we increments. Still the way point I d but And here we're gonna use the busy or BJ's list. Don't count. Don't forget to save and let's test it out. So we take now Ah, enemy ship and we check Use busy. We want him to go this way instead of this way. So we make use of it and see if that's going to work. There we go. He's now going inside the curve and is going back. Wants to you know, the current way point i d and back and force the wall time. That's cool. That's what we wanted. So this is actually working, which is pretty much fine. So what we know want to do is we want to let the player or the player ship or the enemy ship in this case, look into the direction where he is actually flying at. But that is going to be poured off the next video. 11. #10 Moving on Path 3: welcome back to the course. And then let's put, we were actually making sure that this enemy ship is able to fly in the busy curve as well as in the ankle past curve of we like to. So we have, like, a multi set it up system where we can do both at the same time. But using the quadratic a visit curve we have created beforehand in this part, we want to make sure that we add the possibility to look into the direction where the ship is actually flying since, well, otherwise it wouldn't just look nice, I would say so what? We want to do it first. Us. We want to see where are we going to? And this is what we want to catch at the very beginning. So what we're gonna do is we want at first make sure that we have a target. If we don't have a target, then we don't want to do that. Or in this case, if the target is not equal to affect a straight at zero. So what we're gonna do is we and for us create an if statement so you can always once again command stuff out like, here's the rotation coming, rotation off enemy. And this here is going to be moving the enemy. So, yeah, you always know what you have actually done so far or what's going to happen with these lines of coat. At first we create a little very able which is holding the target direction for us so we can save our We call it the direction. So this is going to be basically just a vector. Nothing else, But we can declared, however we we like to What do you want to do it? I want Teoh calculate the direction by the past dot Then we want to go. And since we are using currently the busy curve to we want to or the busy curve we want to say B zero B J list in Scrabble kids. Then we're gonna put in the current waypoint idea. We're at the moment looking at minus transform dot position. So that's the first thing I want to do. We want to set the time the direction Where do we want to go to weaken? Also name this target, whatever. So the target is the one. We're actually looking ETS so the next port is going to become a bit more fancy. At first we want to tank. If the direction is not equal to factor 3.0, then we want to perform the direction. Look at I would say what we're gonna do is since we're working on Ex's that plane. So we're looking with the camera from the top. I want to reset direction dot Why so mean? I said Direction Why is equal to zero then? I want to normalize direction. So I say direction is equal to direction. Don't normalized once again, we are normalizing that because otherwise it's gonna give us a wrong magnitude on the rotation vector. Now we need a rotation so we take or create another Via could also be a cartoonion. So that's once again up to you. We create a rotation. Vier rotation is equal toe quarter Nian, don't Then we are using the look direction and we pass in a vector and the vector is going to be the direction Victor, now that we're done, was dead. We performed the axle rotation. So we say transformed dot rotation is going to be equal to quote Ernie in don't slope and slope in this case. What? Once again, it's a spherical interrelation between two points by off course, the time to para meter. So as you can see, we're gonna now input the current one, which is cartoonion a is going to be transformed dot rotation. So we're rotating from our current position. Come on, then, to the calculated rotation. So we pass an rotation by its direction, comma, and then we've put in the time how fast this is going to happen. So we take rotation speed times time, don't delta time. Okay, Cool. So what we can do now is we can actually test this one out when we're using busy on to our enemies. So go back to unities elected. Make sure that the compiler runs, and we don't have hope that we don't have any typos or mistakes or whatever and press play . Our ships have now move and rotate into the direction where it is currently looking at. A went has to go to meaning it rotates its value based on the axe and that plane, but ignores the why. Well, you and that's what we want. You can also check with you. Ah, checking this one to be global, and it is going to be based on the pivot. You can see that the paper does that access is always looking forward. So it's always going and navigating on up to the Yeah, the little blue arrow, which is going to be this particular case, the local Zad excess off the game object or off the enemy ship. Pretty cool. Now we just need to copy and past that stuff all over the place for doing the same stuff with the past. Oh, potatoes. So basically, we can take the complete rotation off enemy. Oh, that's a little typo once again, but yeah, that's fine. Can correct that. So we're gonna take this port over here the complete rotation off the enemy and make sure that we are making use of this also down below in a side where we're using the past O B. J. So what we do is we copied this name again. And everywhere where the busy over Jay's list is going to be implemented, we're gonna need toe put back this one to be the Passover jailers transform because that in this case, is going to be the goal we currently want to rage. Don't forget to save. And, of course, go back to unity. Make sure nothing is wrong over here. And, of course, don't forget to implement dot position once again here because this is not a vector. This is the transform, so make sure productive position is inside the calculation as well. So we can actually take the current position vector and negated. Where's the Passover J vector? So when we don't use busy, we want to make sure that the ship is also still moving along the past and is rotating in the coric direction, ignoring the Y axis over here. 12. #11 Formation 1: now that one. Welcome back to the course in this part. I want to talk about the formation where the ships the enemy ships are going to go into. Let me first explain what were going to Dio. So what we need is we need some kind of grid inside our formacion, where all these small ships and lighter on also the medium and the big ships are going to go into currently, or whenever you're starting to form a great, you basically loops through the possible amount off this grid and then give it a kind of offset between those two feels that's what we're going to start for us ways. But the 2nd 1 is going to be. We don't want to fill them from the left and then go over through the complete playfield. We want to do it a bit different, are gonna give you a small screen shot off what we had trying to achieve when ownership is going to be at the position where the passes ended. I want to first shit to go here to number zero. So from the center point off the actual formation, he's home going to the left. The next one I want to do is I want to give him to the rights of the 2nd 1 is going to fill this spot. The certain one is going to go here. So the 4th 1 here and so on. So it will always be left right than top left top. Right? Then again, Left, right, left top. Ron left top right top. And I want to have this like until we're reaching to complete 20 fields. So I want to fill this always from the center to the left, bend to the right and so on. It's a force. So this is going to be a bit of trouble. Some sin, some of dysfunctions probably knew for you and the good amount off pretty much heavy Miss Matic calculations. I will go through everything and try to explain it. Asbestos I can. So that's what I want to do. Left right up, left upright and so on and so forth. So it's always going toe Phil from the center, and that's what we're going to start for us with. So what we need to do is we need to calculate these points from that particular start here . So I opened up in my unity and we're gonna create a new script and I call this script formation, so see ships, group formation. And of course, we're gonna open this one up in mono develop or vicious DiDio, whatever you like more. So what we need to do is whenever this is going to become open, we need at first to create the great itself. So we need to define a great size. We can do this with Norman Inter just on Internet. Ray basically doesn't really matter for me, So I separate them so you can hopefully see and understand that stuff better. So what we gonna have? It's a great size X. So this is the size from the left of the right. In this guy's case, I want to give it a 10. Since we have 10 pieces per roll speeding speaking off a roll, we're gonna say public and grit size. Why, in this particular case And this is going to be, too, since we have two rules from bottom to top. And, of course, close the line was a semicolon Later on, we're gonna make not make use the Y axis in this particular case. But this is that excess. Oh, yeah, actually, doesn't really matter how we name stuff here. As long as we laid on. Know what we're going to dio? Then we have the offsets between the X values from one piece to another end. We have the y offset from the lower row to the upper row. So that's what we want to separate as well, since they're two different values coming in place. So this is going to be great. Offset X is going to be We start was equal to one later on. We're gonna change them in the inspector and probably fit them Number C. And they and we have the grid offset. Why is going to start at one as well? So once again, we fiddle around with these and the last. What we need is we need to put all this information into a list. So we say in public list, and in this case, this list is off time vectors re so we can actually take all the position data as it is and put this into this grid list. So we call this grid list and of course, we said this one already to be a new list off time vectors reopen close parentheses and closed the line was a semicolon. So we initialize the list over here once again, as we already did in the other videos. And what we want to do is we at the moment we just don't need starting update so you can get rid of them. What we need to do is we need to add through us, create the function we already used a lot. Now it's the own drawer gizmos function because we want to do this already in runtime or in inspect. The time whenever we are able to do so or we know want to do is at, as we always do, as we want to clear the grid list. So it's a grid list the daughter clear, because we're going to iterated through that the whole time. If we don't want to have it filling up constantly until it is like you have just to pick what we know want is what I want to do is no. I want to increment a number which is counting for us the number off slots we gonna have or actually the position day down this is important. We started zero because we're iterating through all of them and income and or increase numb every time we're looping through all of that. Okay, so for the expel you, we need now for loop as well as for the y value. So for the grit size X, we create a for loop it first. So we se four double tap and then we're going on tape again. So we can say, Meanwhile, I is smaller than grit size X. Then we're gonna do and increment I What we know want to do is we want to also bring here another four loop which is going to be for grits for the grid size. Why so meaning? At first we change the letter here to J Day and Day, and Marks is going to be grid size. Why? So I'm gonna enter and enter again, so everything is cleaned up. Okay, so it's at first. If you would go and fill up a user array, you would go just from X and then through that through, why value we gonna do that? We build it up a bit. So eso you actually understand what's going on? So What we say is we create afloat. We take it, take this number X and X is usually the grid offsets x times the letter I So this would usually be the one for having an offset incremental from the left to the right, Until the rays full, we gonna debunk that. And so you gonna understand what we're doing different here. So in four, why is going to be the same? So we say, grid offset. Why, in this case, times J so that day would be the one would just give us at the next line, actually, and then we positioned these things is somewhere we can bring a vector, which is going to show us where these things are going to land. And I want to show them also with these numbers, as I already explained in the in the introduction of this video. So we create a new vector three. We call it back or vector whatever you like. It's a new Vector three and in open close Prentice's we put in this don't transform. We don't need to special with this, but actually it makes it more understandable. Hopefully, for years, the dot position dot X plus X. So we take the current position off the game object where this formation is going to be at , and then we're gonna increment whatever the current position is, plus the value we have actually calculated year. You're going to do the same for the Zad axis and the Y X is is going to be no. So once again, if you are now confused, why we're using Why here? But not there is. Actually we're basically using the said value. But it's easier hopefully to understand We can also rename things laid on s you please. So this the transform dot that plus why so if we are not taking why that position that that plus why? If you don't like to have the y over here or actually in this case, you want this to be that off course refused to rename it to that. So it's probably more light on more understandable for you. You can even rename this one, so when you want, when you have in value at least two times in your scene or wherever you want to use re factor by right click refectory name. If you want this one to be the grid off that. So it is actually also renamed over here. And so you're gonna simplify Your work was doing so. Don't forget, the interline was the semicolon. So we now store the new vector based on the creative parts here. Now, that's visualize the grids for the positions you're gonna make use off handles, handles is based on or located in Unity Editor. So when you're impressing hit or writing here handles, it will be red. So you need to write Glink resolved using unity editor. So we're gonna label things now. So we say handled, start, label. And now where do where do we want to? Yeah, label something. We want to date. Do this at the position Vek, which we're currently looking or going through. And then we give it a text and the text is going to be in number. In this case, it's going to be the number we have created in the very beginning over here. Once again, per iteration, we delete this number, but it will be completely increased over here. And what we now do is after the handles, we say numb close plants. So we increase the number over here. We don't add anything to the grid list over here, since we only want to see for us what's going on. So don't forget to save and go back to unity and create an empty game Object. Oh, and we need Teoh convert numb into a string. So we say numb dot to string and open close parentheses. We don't need to do anything else, but since this is an integer, it cannot be used as a usual string. So keep that in mind. We can actually also use these as a float. We should to use them as floats here. So the great offset accents that are going to be floats. Just keep that in mind, because otherwise this calculation later on, when we have, like, Kama numbers are going to be or not going to be working correctly. So that's where this era has come from. Once the error is done or gone, we're gonna create an empty game object we name. It may be already fly formacion, and we dragged the formation script onto it. What you can see instantly is that there are numbers created from zero from the very left to the than it's going up right down, up, right down and so on and so forth. So per Iterating Per why it aeration? It's going to fill the X. Yeah, constantly. And it is going Let me go to isometric view and it is starting at the position wherever this year object is currently located at the numbers slightly offset it to the lower right , so you can see Okay, this is going to be the one where it is supposed to be. As you can see, we have not these numbers and next to the grid because off the X size and that size. But basically that's not what we want to achieve. As already explained, We want to feel this array not from the left or the right or not from down to top. We want to fill them from the center, off the fly, formacion, game, object, and then go left, right up, left, right, up, left upright and so on and so forth. But that is going to be part off the next video 13. #12 Formation 2: Welcome back to the course in this part. We want to make sure that we're going with our spaceships, not always felling this array from the left up and so on and so force to the right. We want to go and make it so that is going to it right from the center and going left and right. This is going to be I'm asthmatic. Heavy. So I hope you can follow this one up. We cannot change the X. Enter that value calculation from time to time so we can see what's going on in the hope I can actually make. Yeah, this one are totally understandable for you. Okay, Since we are taking the position from the center off the screen, we gonna have Teoh calculate this one here a bit different. So also, we are not taking I inside of or into consideration, but numb, since number is going to be the actual represented off the metrics or off the position where we're going stroke. How do we do that? At first, let's type the first part so I can try to explain it to you and you as best as I can. So what we want to do is we want to take is at first we gonna take a grid offset X That's when we starting with and we increment that by gris eso we say Plus the grit offset ANC's times two. So and we're gonna put this until some pair of parentheses. I tried to go and make that ah, step by step, so once again, this is going to be great offset X plants grouped Office said X times to What's going to happen is great. Us offset x The once again is one. It gets calculated times, too, and it's added to the group off, said X. We also need to multiple a something to it. But let's that was that and see what's going on with our numbers so that our foundation the base were were creating is not going to peace to Strange. As you can see, it's just takes the X offset X off one. And then it adds that the grit offset X times two to it. So both of these numbers stacks are going to be here at number three. That's OK and totally understandable. I guess what we no need to do is we need to take numb in consideration. So we say we took a multiply that open close fantasies by numb and see what's going on next . Now we should have, like this offset times, whatever as against see, we have now some kind off abdomen abdomens do as we had before. But also we multiply everything by the number we have created. Number is always incremental every time we iterated through the why loop so, as you can see, we know, however is exact fill up off these positions. So this is actually not too bad. The next point is we want to divide this by four. Because every time we have four completed in this exact we want to do another turn. So I divide no numb by four. And let's see what's going on next that the compiler run as you can see it once against Xom all over the place. But it is like maybe we can anyhow seasons better. Well, actually, not really. We have two numbers always on top in the bottom row is always even. Numbers in the upper one is going always uneven numbers. Well, at least for the moment, and somebody can see at the first place is number zero and number two hardly to see. Probably you see this one better on your computer when you are working on that. So we have no 0246 eight in 10 12 and 14 18 and 20 or basically 16 and 18. I mean, 20 is not involved because we're starting at zero. Not at one. So far, so good. Now what we want to do is we want to bring this onto, like, every second number. We want to bring this onto the other side off, where we're starting at with this great offset. So what we say is, we multiply that and then we take a specific function. This one is the power function. So mess have dot Pau, This power returns f raced to a power p. So what do we raise is going to be? We raise miners one. And now we want to say we want to power this one up to numb Modelo too, plus one. So we every time numb is model or two. Like it is an even number. We want to add one to it and we want to Yeah, let's say reverse the direction with this minus one. Every time this is going to happen, let's safe and see what's going on. I know it's absolutely hard to understand, and I trust me it will work. So what? He can see no power or the power off one is Now you're bringing this one onto the other direction off the playfield. So every time, like yet every time X is or the number is an even number is going to change to be an uneven number. So it's going negative into the negative direction because that's the minus one in the power function over here is doing okay. So as you can see, this is rather long stuff. But now comes the fun part. Actually, we're gonna go to the sad value. Why value depending on are you or if you renamed stuff like that or not, we gonna do actually not so much stuff. We're gonna take the grid sad offset, which currently is also sitting at number one. And then we say we multiply this by, of course, we need to take numb into consideration again. This time we say model four. So every force step, we gonna break it down to be zero again, and then we take this number, this model Luna most. So it's 01234 and then it resents to be 10 again. Then we divide this upcoming number by two on once again. Multiply this by the current offset length safe and try again. What's going on over here? As you can see now, it is starting from the center, almost from center. I guess I have a type of somewhere. I guess it's just apprentices. As you can see, zero and one are sticking here. Two and three are sticking here by the other ones are going correctly to the left, into the right. So I guess the X offset overhears correctly wrong, because I need to put this into another pair of Prentice's and this pair of Prentice's need to be Go away. Don't forget to safe, and then we should have what we wanted to approach. So it's zero should be here, as you can see zeros, you know, oneness here to three. Then he has 456789 10 11 and zone into force, as you can see, pretty decent, and that's what I wanted to achieve. So now we can take our spaceships, sent them to this great array. We can request that by this number, whatever the number is, we gonna send it to whatever the number off the ship is. So we can fill this spots by 20 different ships. Was different ideas a laid on. So and finally, we gonna be able to add the grids, our actually the yet the vector into the grid, which is rather simple, as you probably know already, because we learned this alone. So I say grid list dot Add So we add the vector already to the less because it's calculated already. You can basically do the same as we, as we have done here based on the vector itself. So probably it's the most easiest part is just taking back and bring this to this position because we calculated this vector already completely so And now when we're going to the fly information, we should be able to see all this filled in vectors or vector data inside the grid list. As you can see, these are the positions, so element zero should be at minus 100 element. One should be at one. So at the positive number from the center point over here and at zero. And the next one is number twos at minus one from X over here and minus one on or one in this case into the set access because that is not going to be in this direction pretty cool . So the final thing is we gonna need to see that thes grid spaces are not too much away from each other. So we can probably take the Zad Valley or in this case, at first X value and to put this into a 0.5. So it's coming closer, and everything is now in a one by one shape over here, and our information basically is done and we can go forward with the next stuff. 14. #13 Move Formation: Welcome back to the course. In the last part, we were asking you, finalizing the formation itself. So we have the correct vector data based on a number we can later on request or basically, we filled in this race so we can request a rain number by the I d. Off the ship. We're gonna talk about the ideas later on as well. In this part. I want to go and moves. Information left and right, as it does, is doing in the original Gallagher. So let's open up the formation script. Let's put in some new Vari ables for the moving off the formacion. So I'm gonna commence stuff out again. Move the formation. So what we need is an offset. Where we What's the maximum amount off offset? We gonna have? I gotta have put it in a float Air Public one. So I can later on manipulated public float, Max, move, Offset or something. And we can set this one, Teoh. I don't know, maybe five. We contest around with these numbers in the Inspector later on, so feel free to do so Now. We need to start position and the current position. So the current position is going to be the value on the X X is where we're going to go to or around We were. We will implement this number and later on, measure against if it is the same as the maximum offset. So what we're going to do is we create a new public. Well, actually doesn't need to be a public one. Just about afloat, car paused ex or current Position X. We don't need to set it because it's going to be done by code. So this is once again the moving position. Then we're gonna have another one is going to be off type of vector. So a public well, actually doesn't even need to be public. Just a Vector three where we have storing the start position when we're starting, we're gonna fill this data and justice sake as well. Then we have a speed. So how fast is this one going to move public float? I don't know, Speed. And we said this maybe to one f once again. Even so here. We gonna be able to play around with these numbers later on. And then finally we needed directions so we can increment or d crimen this buy whatever we need is going to be of type into deer or direction. And we can set this one Toby equal to a minus one. For example. This number will always this number will always be between minus one and one, but it will never be zero. So we'll just switch minus one and one. We just multiply it by itself later on again. So now we have the direction to move till the speed where? How fast we want to move. Then we have the position. When we're starting at at the current position, we're going to increment by time and speed and we have something to measure against is going to be the maximum move offset in this case is going to be for the X axis, So probably want to put an X in the end as well. Up to you. Okay, so in start, we're gonna feel now with some data. So is a voyage. Start off close parentheses. I know we deleted this one in the last video to start an update, but now we gonna implement them again. So we gonna have the start and then start. We just initiate or in your filling the data. So stop position is equal to transform the possessions of the position off the fly. Yeah, the fly object. I would say the flying formation object, and then we want to star set as a current position, X is going to be equal. Teoh transformed our position dot acts, but can also use Start paused on X Doesn't really matter. Basically, it's the same at the same time. Then we need to go into update. Maybe later on, we're gonna put this into and I numerator or something. But at the moment, we just put it in here because it's need to run the same way, basically, or the wall time update is always bad, but And for this purpose, we gonna do this. So what we're gonna do is once again, we can later on changes result any problems. So current Position X is equal to or plus equal to. So we add to current position X. We add time to tell the time to it and multiply this by speed and by the direction so their excess always mine is one of one meaning it is always going in the left direction or the white right directions when it is minus and it adds to it, it still gets minus, you know, plus and minus equals minus. That is a positive values. Then it will be added to it. So at ah, like the direction will just change it This positive or negative. Now we're moving into one or the other direction, depending on where directions you can already try that out. I don't go and do that now because I want to limit this already. And so we want to limit this by the current position X. So if current position X is bigger, equal the maximum offset axe don't want to do something. And what we want to do is of course, you want to change the direction in the other direction. Meaning we say dear times equal minus one. So we changed the direction to whatever they're, so it will be a positive or negative number of depending on where we're currently at, then we're gonna have another one is going to be else if and in this case is the current position. X is smaller, equal minus the Mex move offset. In this particular case, we just negate that here, so we don't need to create two variables even if we could for a minimum one. So if the smaller, equal, minus max move offset in this case minus five, then we're gonna change the direction again. So it's a direct sun Times equal minus one. So once again, we're gonna negate it again. And we set current ex or current expertise or current position X equal to be wherever it's currently. As so max or minus makes move offset acts. And on the other side here, we're gonna do the same, but in the positive way. So we said it to be the current one is going to be the Palast one over here. So let's see if that is going to work with the negative sign in here of not I need to put a parent parent to seize. Maybe around it, we'll see in just a second let the compiler run and seems to be good. So as you can see, we now have the maximum move off. Said X is going to be five. Speed is one we know press play. This should move into the into one direction or the other, but it doesn't because we don't actually move it. So women on the Jews, we say transform, don't position. So like, after we were checking everything over here, we're gonna set the new position off the Yeah, The calculated vector is going to be a new vector here. What we now take in consideration is car Prozac's comma. Start position dot Why comma start position that that that it Now we're moving this one based on the current position X, which is calculated, or increase the world time into one or the other direction. And we don't want to change the start position. Why or that? That's when we gonna take this and catch this year in start beforehand. Don't forget to save. Let's go back to unity and that's a compiler run. And if there are no eros Justin one warning we gonna take care of later on. Then we are able to press play, and this numbers now should move until specific point in this case minus five from its center. And then it's going backwards into the other direction, like it's now adding up until sits plus five from the center from wherever it started. So this is now moving from left to right and keep on counting. I guess there's Offset is going to be a bit to pick. So probably we're gonna have, like, a two or four, maybe or three. I don't know. This is up to you. We can a later on play around with these numbers. So once again, even if that is too fast for you. So if you don't think that these ships are too far are running in this low speed or in the size speed, you're always able to fit around once again with these numbers on your own. 15. #14 Formation 4: welcome back to the course in the last video, we were actually making sure that we're able to move the formation to the left and to the right based on its own position. When we're starting at 000 it's going to go like negative to and to buy a speed of one. Well, we know, basically Condo's. We can start to design where everything is going to bay and how yeah, huge things are going to be as well. So since my game, I don't think I gonna go into landscape. But poetry moat, I gonna change the view to 10 by 16 so everything will be like top to bottom. As you can see, my numbers over here are not even matching into the screen. So what we can do is we can just take the camera now and bring that a bit higher so we can see even more. Ellison gets a bit smaller, but that's totally fine. And maybe we'll give it a bit often offset Ian. There also make sure that it is central to the screen, so we have no problems later, almost setting things up as we like Teoh. Also, we can take the formation object in here and moves up and down to once again wherever we like to. So it's basically fitting the needs off our current Yeah, Game field. If you don't like these numbers later on, we're gonna Yeah, disable them onto the handles part inside information. But for now, it's a good indicator to see if when this is moving like a bit left and bid, right, like just half a ability. And there were going to make sure that we have enough space and we can't see things better later on. Also, what you can measure is, for example, you can take one of your enemy ships. Bring this, maybe try to center this one where the numbers are going to be duplicated and see when you're snapping that by one. If the distance between them is too high, I guess it is going to be too high. So we probably want to bring this a bit more together once again. All of that is a design decision you have to do on your own. I'm gonna bring this down to maybe points 0.25 for something we can see and test it out again. without any problems and always out any issues. Bringing this here this day it's a bit too close, so probably suffer things like that. So I can a fiddle around with these numbers right now. So once again, I have tried to bring them more to the center of here. So kind, see stuff better. So I want to fit this small numbers anyhow to the position where they supposed to be. A So maybe a bit more outwards. Something like that. Point points 31 points re two or three. Something like that. And I want to take this number and double it. So I have to correct Why will you as well or should have to correct by well, you So they are more more likely how they should or how they could be laid on. I tried to see once again if how it looks. And now I can also say I don't want to fly maybe two pieces and maybe want to fly oil to Seems to be fine. But the cool thing now is I can go down a bit with the camera. So from the actual game, I can Seymour in the end. So I'm gonna try this out no matter what, anyways Going to go out of scale, so make sure nothing is scaling here and probably bring this a bit more down on when I press play. I want to see where these numbers are going. Teoh. Yeah, go to from the current position they're starting at. There's still a huge offset, as you can see. So probably two is way too much. Maybe one is going to be the unit. And even if one is too much, we can't even bring this one a bit more down. But one seems to be a pretty a pretty decent number over here. And we can also reduce the speed to maybe 0.3 or something, or maybe point point five and tested out again Once again. This is all design stuff, what we're currently doing here. So we just check out How could our game look? How is it fast or it's too fast, too slow. Whatever it is, we want to make sure that everything looks fine as well as that this little spaceships which are currently flying around here already when we are like dragging. I was play o r pass holder around here that we can see them still good enough on the playing fields. As you can see, they're just flying to the beginning, off the past. And we gonna have a good Yeah, playground for them later on. So would you also want to do? Is we? What we can do already is, since this one is not set it up, as I guess I like it are gonna duplicated the fly formation and snap it. Where's holding down the control key by one up, and then what I want to do, They want to reduce size X to be eight. So we're coming closer to the playfield we want to have. And this is going to be my eye corded wasp formation. As you probably remember, from the first video, we have, like two tend in the bottom role eight and our row above and then four for the boss. Israel are gonna bring this a bit down here as well. Probably later on, fiddle around with these again. I duplicate wasp again. Bring this up twice. Well, it's height. Maybe gonna fit around once again with this numbers again. So maybe not having too much offset in the upper part. And I want this to be a one in the grid size. Why and before. As you can see, whenever we are setting this one on the grid size extra four and a grid size white toe one , it's still forms a quart. So we need to change a bit in code. So we have the possibility to set this a divider raising lay taubate different in the upper row, but keeping the other ones consistent at a four. So what we're gonna do is this number four here and this number four here is going to be the one which is actually taking care off. How many we put where. So we're gonna just We go up a bit over here and creating your public, and I call this def for divider, and I gonna set this one already to before, So nothing is actually being damaged whenever we're changing script Now, also, not on the other formations. Instant of four are gonna put in def over here and a diff over here as well, because that is going to be problematic. Otherwise, So we know. Go back and let the compiler run. Everything should be good to go, and the divider should be popping up here. So for the fly formation and the wasp formation, I don't want to do anything I don't want swap the divider. But in the I rename it boss formation, I want the divider not to before, but to. So, as you can see, whenever we're setting this to to the boss row is correctly set it up as it's supposed to. Now we just need to position it wherever we like. And police once again maybe take the boss or the wasp a bit down as well. So everything looks Raisa. Nice lay a year organized and also spread it. Even so, when we know would press play, that's the most funny one is all these formations should now work or move in the same speech in the same direction. And they're gonna keep consistent in its para meters. And that's what we wanted. And also they have their own counter for every enemy and stuff we're gonna have. So the first boss lens on the zero, the second on the one hand to dance race. So in total, we gonna have four. Once again, we need this zero. I don't need this to be zero. Otherwise, we cannot You put this in the correct array part while we could, but would actually not be comfortable for us. So now we have the information we have now Everything for the wasps, like the second row or a certain in the fourth row, where the boss role, we have the fly rose. And now we can go and fill around more with the enemies so they're actually able to fly inside the court. You have the correct formacion where they supposed to be in? 16. #15 Enemy Statemaschine: Welcome back to the course and the passport. We were actually taking care off all the formations and we put it in the divider so we can fill in the bosses into one role instead of two rows. And what we're gonna do now is we want Teoh. Yeah, modify the enemies a bit more. So they're gonna have, like, two different states where they are moving on the past. At first, whatever the past setting for this enemy is going to be. And then whenever they reach the last point, we want to put them into the formation to the chorus total correct slot. So let's do that. Open up your enemy behavior script. Are we gonna commend out some things here because this is going to be something about state machine handling. Just maybe name it state machine If you like Teoh and this state machine will have laid on way more states than we just currently start with. So first we define it, so it doesn't needs to be always public, and it needs to be an in, um so any name is nothing else than named integer array A would say, but we can put in strings to simplify request on it, and we off course know what's going on. So this is going to be in the name enemy states, and this case, I'm gonna take a you a bigger letter. In the beginning, you can name it, whatever you like. Once again, enemy states And in this enemy states, we don't need to Apprentices, we just open a pad, pair of curly braces, and we can now put in like, the 1st 2 states. What does that mean? It's the first state is going to be maybe the fly in state. Make sure you Yeah, name it as you like and put a comma afterwards whenever you're done. Was that so? My first stage should be flying. Maybe I type it so not sure. Later on, I might rename things here and there. Or sometimes the program doesn't work as it's supposed to. And then we go and say Maybe, maybe we name it to formation. So it's moving to the formation, and that's probably for us. Everything we need to do. Also, for the state machine, we gonna need to have an excess er for the inspector. Maybe I don't name them fly in and that maybe I name and fly in this maybe going to be on past. So we're gonna set them on the pass, and this one is maybe fly in. This is going to be where I flying into his information. So I command this out again, fly into formation and on passes. Of course, when it is on past, maybe from spawning or whenever it's somewhere. So it's going to go to that whenever it's on a pass is on a path. Okay, So when we are starting was working with state machines, we gonna need to define how they're working. Of course, once again, we need the excessive first. So it's going to be also a public. And now it's off type enemy states which were created. And then we say, enemy state. There is a small letter in the beginning, so we know this is the excess er we need to request. Now we have several possibilities to move on the past. I'm gonna make use of update for us. Maybe later on, we're gonna put all of the movement and stuff into, and I numerator, so it's going to be running once and not keep on continuing, like requesting all that stuff all over the place. What I want to do is when we are on past, we want to do something. When we are full, I in We want to do something. We can create this inner if else if else if else if else statement or we can also put it into a switch. So it switches doing switches or is requesting switch based on whatever we're giving him. So what do we want to switch at first or what We're what we want to excess is the access er , enemy state an open, close curly braces. We can define every case off this particular switch statement. The first case always type in case can be on past. Make sure that you added colon afterwards. Otherwise it doesn't work. And at the very end, off a switch off a case, we always want to have a break. Anderson, Mykola. Meaning we enclose it. Everything will. We type in between the brake and the case on past is going to be performed in this particular case. And it's going to repeatedly do this because we're doing this an update once again. We can also put this and into a coal routine, so it's going to do this as well and just measures whenever things are changing. However, when we are in that particular case, what we want to do is we want to move on the past and in this case it's going to be the past to follow. Well, at least for the moment later on, we bring in the correct passed over here so it can actually delete this line because we're doing this whenever we are moving on the past, when we are done was moving on the past. We want to change that to another case. It's going to be the fly in case Colon once again, don't forget to break it at the very end and in here we want to go and move to the formation. So we need to connect NATO onto the formation we are able to go into as well as we need an indicator for what's our position in this particular formacion? So for first, we create public int enemy I d. So this I d represents the position in the formation where we want to send this yes ship into. And then we said We want to have a public formation and we just name it small formation. So we're gonna have an access er and we can drag it into in which formations this particular ship is has to land into. There's going to be some work later on in when we are talking about pre fabs. But for the moment, we just don't. So whether we want to go to ISS when we're flying into formation, we want to move to the position based on our enemy. I d end to the formation here. When we are moving on the path, we're moving on a pass. And what we're gonna do is whenever we're reaching here the last past point, we want to switch to the other statements so we can say enemy state is equal toe and then we put in the fly in past state over here so we can actually change, no matter which one we're taking this one or this one, we're gonna switch the state to fly in whenever we had done was moving on the past. This is only working, of course, when this is an available one. So being meanwhile moving off, flying into it once again, we want to move into the formation. So the easiest part is we can't make a use off f move towards a point Information were requesting. So maybe we gonna create a help of function for this. So move to for mation. We don't need to put in anything because everything is stored already in here and here. When we're flying in, we want to, though. Move to information. Open close friend to seize and close The line was like semicolon. So everything is good to go, if you like to. You can always put curly braces in here just so you know it and maybe you can you read this later on Easier. But once again, that's up to you. I usually do that because I like to read stuff easier. Eso I got Just put it into corporate your braces. You don't have to do this. This is just optional. But maybe you're gonna find this more. It's maybe more readable for us. So to simplify how this is going to look over here when we're moving to a pass, we gonna say transform dot Position is equal to vectors, Ray. Don't move towards and Where do we want to? At first, we want to define Wolf. Where are we coming from? Is going to be transformed the position comma. Then we have a target. The target is going to be our formacion dot and information. We should have the list where we want to go to its the grid list and Ingrid list we can access. The indicator in this case is going to be the indicator off enemy I. D. So the idea off this particular ship and since it is already a vector, we don't need to say dot for dot position that we can define a speed as we already do with the other one. So we can say speed times, time dot delta time. Whenever we're there, we also want to rotate into a specific manner. But that's what we're going to do later on. Let's try that out. We're gonna take our first enemy ship over here. It has an idea of zero. And the other one I gonna set this one to I d one and to see it may be a bit better. I want to bring them one over the other so they're like behind each other. So, as you can see, those two are going to fly now, at first on the past because the current status on pass whenever they're hitting the last point over here, we get in a reference because we haven't set the formation and both of these ships. So what we're gonna do is we take anyone until ship and we drag in the fly formation because that's information. We want this boats go to and press play again. Once again, they have separated or different I ds. We're gonna move them onto the path. And whenever there close to the last point, they go to a 0.0.0 point one and they're gonna stay inside the formation. But that is only because there currently updating themselves to this point. This is not not a good idea, because it's eating up the wall time, some space. So what we're gonna do later on is whenever we are at this point, when we have reached it, they don't want to do something. But that's what we're gonna dio in the next video 17. #16 Enemy Statemaschine 2: welcome back to the course. In the last part, we were actually making sure that we had switching states whenever our enemies coming from the past and move them to the formation in this part, we want to set them so that they're looking upwards and probably also making them make them child objects to the fly information so we don't need to keep on moving them. Let's get back to our enemy behavior into arm move to formation script. What we want to do is meanwhile, we're moving into that. We want to check the distance to our goal. What we want to say is, if vector three don't distance so the distance between two points in this case the first point is going to be transformed the position the 2nd 1 is going to be the formacion grid. We're talking to a want to go to information grid list in square brackets. Enemy I d. When these are smaller or equal than zero point. I know there's a Brazil one f They want to switch the state again to be a state where we are inside the fly information like an idol state. So what we can do is we just add another Idol state over here. So I put a comma and say idle. So we're just idling there. Then we go into the switch statement, put in a case off type idol Colon Greg. And then here we just idle. And don't do anything else as long as we get No. Yeah, Another input. Meanwhile, we are idling. We have the problem. That we're not moving anymore was deformation. And also, we now can rotate this at the same time. So what, we're gonna do it first? We say any state is equal to enemy states dot idol semicolon. Then we want to rotate this one to be a 000 rotations. So we say transformed, don't you? Ankles is equal to and you vectors Ray open close for Inter sees. And then we say zero comma zero comma zero. We can also say two vectors 3.0 should also work. So instead of this, we can say is equal to practice 3.0 like so should be the same. So what we're gonna do is that as we rotate, it's your ankles to be 000 So it's going to look a straight upwards. Well, that's what we hope, what is going to happen. But we're gonna need to do that before we are switching the state. Otherwise, we're not in a formation anymore. And what we also want to do is we want to parent this Iron Ship to be the parent on or be the child off the formacion game object. So we say, transform. I don't set parents and then we can say, What is the transform will want to excess? We want to say formation, Don't game object dot transform So we said this one to become the parent or actually the child off the formation. Let's see if that is working. Why do we do this? Because we want to move. Keep on moving the fly information. But we don't want to stay in update and updating the position constantly. Meanwhile, these trips are flying around, so let's test it out there going on to the past. We can always go and give them some more speed if we like to. For the moment, it's just fine for debugging purposes that good to their position, they rotate into the up direction as it is usually in Gallagher as well. And then they're gonna become child off the fly formation. And that's what I wanted to actually keep on track where they are. And they don't need to update themselves any position data. And we're gonna save some CPU timing while doing so when we later fly, let them fly outside information off course. We just say that we put them out off the parent object law. So we can I get rid off the fly information as a parent, and we go on fly round once again, do whatever we want to dio with the ships and then bring them back inside information. But that is all stuff for one of the next videos. 18. #17 SpawnManager 1 Intro: Welcome back to the course. In the last video, we were finishing up the formation and fixing or fitting everything to our needs in this part. I want to start to talk about how we can spawn all these Yeah, enemies, bringing them on to the past and then into the formation before again. Or we can start. I want to talk about the system I'm trying to bring into this. So I opened up my escape. And as you can see, I already have added some some ideas here. We gonna have almost born four point, which is going to sit outside of the playfield so we don't have any pop ups or anything else, like when they are arriving, Then they don't pop into the screen. Like sometimes Yes. Yeah. You can see this in bad games. Or maybe in the background, off games whenever stuff is going to become loaded. So we're gonna spawn them outside and on this bone object, there's going to sit a spawn manager. This is going to be its group. We design a specifically to create our own spoon management system. What does it mean? It's born manager has to act in some kind of waves. We can define these waves how many passes we want to choose where the system can pick from Every time we're just taking one or two Whatever. We can also also automate things. Or we just set them up like, ah, hard coded paths. For example, One. Does that mean we're gonna create our past? We make a pretty for out of it and we put this into our waves Manager. So per wave, we gonna have to set up how many passes we want. In this case, one or two we can lay down. Also, Atmore, since the system will give us the possibility. But this can also be a bit troublesome later on, with some calculations, we're gonna talk about this later on. However, let's assume we're gonna add to two passes in the first wave. Then we're gonna be able to set the enemy amount. We want to spawn per way for it per wave. This number is going to be divided or actually taken for both passes. We're going to talk about this later on as well, and also we need to check if we already have reached a maximum possible enemies per level by per level. I mean, we have a maximum off 20 smalls 16 medium and four big ships pull around per level. We can design those enemies. It doesn't really matter. We can lay down. Also, we can drag in the enemies for the small, medium and big ones into the wave managers so it can pick automatically which one other correct ones. Then, once born, we gonna have to set them up so they know which passes they're currently on, then the formacion where they have to go to and then as the very last the i d. You get from the waist manager as well. So the mayor wastes, or the Spawn mention always needs to know how many small ones he has already created and that would would also need to do is we need to de back every time. We're doing a change inside this set up. For example, when you have one around one level and it contains, like, six different ways, we want to make sure that we don't buy Miss take over, do it. So we somehow calculate them all together and give us a feedback. How many we have already we can do this in several different ways. We're gonna talk about this as well. Probably we can use a handle for this, like a label and to discounting home any we have set it up in total. Or we can also use the consul to do this day back change or d back on train and give out some eros for us to see owed. We overdid it. We have, like, one or two too much. So we need to think about this a bit different. But that's a story we're gonna talk about later on as well. And finally we need to understand or we need to put in an interval between the enemies were sporting like when we're sporting five per way for maybe 10 per wave. Then we're gonna have, like, 1234 and we don't want them to stick over each other. So we need to have a small interval between this born time, depending on the speed, how fast the enemies in the end are going to be. And also we need an inter well between waves, meaning the first wave. Whenever this is done or over, then we want to wait a bit like maybe when the last ship has been spawned. We want to put in an interval off maybe three seconds before we spawned the next wave. Until we actually finally reaching the very end off all the waves. So we can tell that every ship or every enemy has landed or inside the game, not not necessarily in the formacion, but in the game. Also, later on, we're gonna count up all these enemies together. So whenever we are done with deleting them all over, we are like, we're shooting them down. All then we gonna know that we had done was the level we're gonna get all our points on. We're good to go and can perform the transition to the next level, for example, or whatever. But that isn't stuff for what we're going to talk about later on. So we want to start. Or now I want to start in the next couple of videos to design this complete spawn management system. It might look a bit yeah much, but actually, it's not so hard to do that, So So probably you have an idea. Already when I talk about that, how we could perform this. But this is actually the at the end of this video and the next weedy, every actually started perform will create the sport management system for us. And we're going to design like everything we need to do about it and probably give us some more freedom into spawning and also already setting everything up so we can see that the first enemy ship we have already implemented can automatically goto the yeah required to the design of formation in the game. So let's get into it. 19. #18 SpawnManager Waves: Welcome back to the course. In the last video, I talked about the sport management system I want to create here. You can, of course, always design your own stuff. We gonna start rez? A simple What we want to do is we want to create an empty game object, which is going to be our spawn point or spawn manager. You can name it whatever you want, because it will act as the same. I got zero this out first, and then I bring is a bit up outside off the game field. If you don't know if you're outside of the game field, you can always add a small gizmo or a name like this one here So you can see this also inside the play field, so probably want to take it and bring it at least outside off the game. Fear. But maybe a bit more, depending on how big girls ships are later going to be ho, you know, wherever you're going to be, so you don't have any nasty pop up stuff and so on. So this is the point, or the manager is going to be the same. The point where all the enemies are later on going to become spawned, like all the small ships, the medium shirts and the big ships before they go and enter the past. So what we need to do is we need to know the designers system, which is doing all of that for us. So we're gonna create a new C shop script. Let me call it, maybe Spawn manager once the compiler is completely done running and everything is fine and we gotta go to the Spawn manager again and to direct the Spawn manager onto it. Let's open it up and Memorial, develop us visual studio. And now what we need to do is we need to first define what a way for is actually a boat. The waves. I want to put waves in an extra class. It does not have to behave. Oh, are actually does not have to inherit morning behavior. It doesn't really matter for those because we're going to make this one serialize herbal and we're gonna make use of it inside the list. There are hundreds of Paula possibilities we can make use off, but this one is going to be the easiest. So we create a new public class and I call this wave, and that's basically everything. And then we open up open close colleague braces as usual. So we're designing a class inside the class, which we can perform things into, and to make them visible. We later on once again at the tribute to serialize Herbal What we can also no, do it as we can say we create the public list off type. So in trying a break, its wife now we can name it may be wafer list or waves or whatever you please like, and we initialized that is equal to new list off type wave, so I can see we can design and our own class, and we can make a list out off this wave inside or off. This class insight, this sport manager script, when we go back to unity, would see we should see that there's going to be a list which we can basic in, Just see, but we cannot do anything with it. Sometimes we can't even see that because it is not well, it is there. But as long as wave is not serialize, Herbal were unable to see the waves and the classes for this. So what we need to do is we need to say system, don't serialize herbal. If you want to add system into this name space above, you can totally do that as well. Gonna show you pretty quick so I can say using system and then you don't need to put a system in here, so it's basically the same. So because this takes care off this particular name space anyway, so up to you, I don't do it because I like to see this is going to be like that because also, we only do need this one. So it's totally fine weather, no safe again. And I go back to the sport manager script or yeah, object. You should see the list popping up. There we go. That's the waitlist. And we cannot set a number, maybe two. But since you're no elements, or actually there's nothing inside this waste now, so we need to put in some dinner into the wave class. So, for example, we already talked about that and the last Really, what do we need to have inside? One wave is we need several different things. We need to know the interval between that. But there's not actually part of the wave itself, or we need to do is we need to put in the past. We're gonna start was one, and later on we change things, So you understand what's going on. So what we need to have is a public past where we want to go into pass. Then the next thing is we need to add in the formation where our soup is going to land into . We probably redesigned that later on for better readability. But since we have three enemy types like the small ones, the medium ones and the big ones, we need to add in three different formacion types here, so and based on that, we gonna have to put in the formation type into it. So what we could do is we could create another class where we have all this special enemies to be coming setting up. But on the other hand, we have everything we need to do inside the power inside this wave anyways, So for now, we just enter one formacion because we have one enemy type later on, we gonna change that. So it's the type information and I name it fly formation or you can also name it a small formacion. So for all small ships, this is going to be the formation for all small ships which are currently sitting inside the game field already later on, Once again, we're gonna have, like, two other ones, like for the wasps, like in the center for the medium ships. And then we have the boss or the big ones which are going to have another information, of course, because otherwise we are unable. Teoh, fly to this particular formacion And what we also need is an eye day or a number which is taking care of how many we have already or we want to spawn. Let me put this may be here. So we say public and fly amount, for example. So this year is the amount off flies to spawn, and this is going to be per wave. So every time we put a zero was nothing will be spawned. But when it is like five from five flights will be spawned. The next one is outside off the wave. Claire's we need to define the timing or the intervals between those waves. So we can say public In this case, I would choose afloat. It's a enemy spawn Interval. So that's the interval between ships, Bones, I going to do that? I command things out once again so I can laid on. Remember what we have done here, Award they are for Then I need another public float which is going to be a wave interval spawn interval. So wave spawn Interval. So this interval once again is for the waves. So the interval between waves and then what we also need to have as a private one is going to have type interject. It's going to be the current wave. So the current wave were actually on. We're going to store the CIA privately because we will need to count it up any time we're starting was that we can actually set this 1 to 0, but doesn't really need to be. So this is the current wave. We are actually in the we automate that were increased that automatically over time in the next port, we gonna start to spawn our first enemies based on the wave interval and, of course, the enemy's passport interval and increase the wave amount if it is possible 20. #19 Spawn Waves 2: Welcome back to the course in the last week you were started to design a wave class IP it. So for the moment, we have, like a one pass and one fly formacion where we can actually dragon objects into which are containing the formation on the past script. Let's go back to it and go forward to spawn a naxal. Yeah, an actual wave or an actual enemy. But before we can do that, we even have to put in some more informations. At first we need some game objects which are being spawned. So public game object fly Prefect I call the fly Prefect because I currently work everything out with to fly at the moment. Once again, you can also see Name it small or enemy one enemy to in this mystery and so on. It's all is up to you. So this is where we'll fly Proof ever is going to become into then we can actually take this for life prefab based on where we're currently at and put this into some kind off. Yes. Born in mechanic. What we need to do is we need to create a court protein which is taking care off all the time to act and for us. So for the moment I get rid of updates. Since I don't think we're gonna need this in the future and we're gonna have the start function which is actually taking care of that, the coordinator on it's going to become started. So first we create this coral team with an i e numerator and I know it. Name this Spawn enemies or spawn waves. Maybe I make it warm. Banks like sauce born wastes open, close friend to see is because it's a function and open close the curly braces afterwards. So inside the spawn waves, we need to have a while loop, which is checking. How many ways do we have left and where are we currently at? So we need to create a while loop so we say while and then we bring in a condition. This condition is while the current wave is smaller than the wave amount. So wave list don't count. I want to do everything which is inside the wire loop, and we gonna stay inside that while loop inside this I numerator until it is completely finished at the very end off everything we gonna say Want to increment current wave because whenever we have done with everything inside of that, wanna increment it So maybe one day we are done with the wire loop and we can leave it alone. So what we want to do is, at first we want to always take the small ships first. I gotta commend a lot of stuff out now, so flies first. So at first we want toe, you create or spawn all flies light on, we're gonna do all mediums or a wasps. And at the very end, we're gonna take all the bosses in consideration based on the set up. So what we're gonna do here is we say we loops through the amount off the possible fly spawn amount like this on the fly amount inside the wave. So we say int I equals zero I smaller than the wave list in open close square brackets, current wave don't. And in here it's going to be the fly amount. So we gonna loop through that until we reach the fly amount and we gonna do always smaller than because we're starting at zero. Noted one. What we want to do with meanwhile, were looping through. We want to say we want to create a new game object. I name it New Fly and when we want to. Instead, she ate. It's always say instance. She ate open close parentheses. Then comes What do we want to instance? She eight is going to be the fly prefab. Then we need a position is going to be transformed our position because it's sitting directly here onto the game object, and then we need to have a rotation. In this case, we're gonna take quarter nian dot identity. So we take the rotation off the game object in its initial state because it doesn't really matter. And then we say we typecast this one into a game objects So we say, Ask game object. You can also put in open close apprentices in front of it and say, Game object in here because it was a big G. Both works, but do not do both at the same time, just a one. So I gotta say it like instantly eight as game object, because when we instant jiating something, it's going not to be. Usually it's not going to be a game object, but Justin object and objects are not able to act well, not directly as a game object. Now what we want to do is we want to grab a czar enemy behavior and set it up so that it gets the correct i d. Where it has to go toe as well as the core in past we need to set into. So First, let's catch or get the information so we can talk to this new fly so we can once again say we want to catch enemy behavior. It is like new fly of behavior. It doesn't really matter how we name it's and in this fly behavior or what we want to do is that fly behavior is you want to get it from new fly thought, get component open clothes drying a break, its enemy behavior and open goes apprentices at the very end and the semi colon. So we gonna get from the newly created or insanity ated fly. We get the component off type enemy behavior and store it or a story connected to it in fly behavior. Now we can talk to fly behavior and change everything we want to do before we're going to do that, we probably want to help create a help of function inside enemy behavior at the very bottom . Maybe it's going to be a public void spawn set up. So what we can do is now we can put in arguments here to send or we get from the sport manager on Spawn on run time and put this in here. So what we're gonna have now is whoever passed to follow and what we want to feed in is the past we want to follow whenever we're sporting them already. So we want to automate that. What we can do is that as we can set here a pass as an argument we name it just passed. I never want to have an idea. So we say int i d and then we have the formation. So it's a formation form or formation and small letters. What we know want to do is we want to set all of the's up so it's a pass to follow is equal to pass, and I d. Is. Or in this case, it's going to be enemy I d. Is equal to i d. And the last one is going to be the formation. So we say, Let's see, um, how we named it here. It's also named formation. So probably we gonna name this Underscore Formacion. So is a formation is equal to under school formation. So we always said these things to or from wherever the things that are coming from here don't forget to safe and let's go back to the sport manager. And now we can talk to fly behavior dots and here we have a spawn set up. Then we open that and now we can pass in the para meters. We already have created as arguments we need to put them in here. If we don't put them here, we're going to get any arrows. So at first we want to know what's the past. We want to talk or want to send into it. In this case, it's going to be the wave list in square records, current wave dots and in here we have the past. So that's what we want to set at first. So we want to give it the past we currently run on. The next one is we want to give it the I D. And currently we don't have any. I d over here. So what we need to put in is here and private counter off type int fly I d. And we're going to start this fly I d ed zero as always. And it's increments later on as well. Whenever we're doing so. So we never have any doubles and we never have any doubles inside our information. So and we're gonna have that fly i d. And then we want to bring the fly formation. So we say the same as we've done at the very at the very first we say wife list in square brackets, current wave don't formation or flight formation in this case because it's a fly and that's it. So now we talked to that, and we'll be at the final step. Can do we can increment fly ideas. So we say Fly I D plus plus, Then we want to wait So we say, Wait four Spawn Interval. And this inter well is basically going to be the one which is between those a single units borns like the enemy's born into Well, so we copy that. Well, I could be that you can type it out no matter what. So what we say is yield return new, wait for seconds and then open close parentheses. We're gonna put in the enemy's born interval. We want to have in between those sports, and then it's going to go forward into the next loop and takes more and more mawr until we are done with this complete wave. And whenever this full up is done, then it's ghost of the next current wave and starts all over until the wire loop has ended , and then it's going to leave automatically the enumerated over here. 21. #20 Spawn Waves 3: Welcome back to the course. In the last point, we were adding sworn into well, wavin develop and already created the base off our spawning co protein in this port. I want to finalize that and finishing a stuff up so we can actually start us born things. First off, I want to have a small help of function which is taking care of sporting this wave after a given amount of time. Because in side the I numerator we don't have any time which we can make use off. So what we'd say is we start exporting or starts born. This is my new function here. So white start spawn open close parentheses and what I want to do is inside is I want to start the core protein so coat protein and we can name it directly. So spoon ways open, close parentheses and close the line was a semi colon and after that I want to say cancel invoke And in open coast parentheses, we say start spawn. This is important. This is going to be the one. We're going to be here. This is just a small protection for us. So And since we are invoking something off course. We need to do that in start. So we say invoke and what we want to invoke as a mass it by a time. For example, we want to wait when the game before the game actually starts. And the first enemies are coming in. We maybe want to wait a second or two, or maybe three. Whatever. And this is what this invoke pyramid or this invoked message is going to do for us. It waits until it starts to spawn or actually starts the core routine to become spawned. So we say in string or in quotes. Here we say, starts born, make sure everything is written 1% or no typos. If you're unsure, just copy the name and bring it here. Let me say comma. Then we can't set in any time we want. For example, three f What does it mean? It start? It starts to invoking. It waits three seconds and starts Sporn. In starts born, we start the coat protein and cancer. The invoke. So it's not running anymore in the runtime. Once again, this is for debugging and probably to avoid some strange behaviors later on. And when the court routine starts would go into this waves. See what's the current wave and how big is the wave list. Then we looked through all off the flies and only the flies here, and we spawned them in an interval off the enemy's born into what we have set it up that way increment current wave and see if we're done was that. And if it's so spawn waves is going to be ended because it reached its end. I guess we have to put in one more yield statement, that is, before we actually go forward into the next wild loop. So before we are adding up the current wave, where country and we want to make sure that we wait again. So it's a ute return new wait for seconds. But in this time we not to taking the enemy spawn in develop. We're going to take the waves born into well, because that is indicator for waiting for the next waves before he's doing anything else. So waves born intervals going to lend into the prayer pair of Prentice ease. Don't forget to safe and don't forget to save often and let's see if we can already start to build stuff up, but we need a lot of things to set up beforehand. So first, let the compile around, see if there are any arrows. If there are any police fixed them first before you go forward. So in my assets for that I want to create a new folder with prefab. So creating new folder and I call it pre fat. So in those prefab swill that I want to put my enemy ship into so I can actually yes, born that. So I take enemy ship one Onda, direct this over the prefects Full though you can also go directly into the prefects. All that's where you have access to it. Make sure that everything is set it up correctly. As you can see currently, there is no past to follow because it does not hold it as well as there's no Formacion because we had to set this one on by hand. The enemy idea is going to be zero because we haven't changed that we don't care about the other one here. We just get rid of it as well as this one. We can always feel around. No, inside the prefect without any problems, and we can talk to the enemy behavior script whenever it is over here, we don't have any rigid body components and all their stuff, because currently, we just don't need them. We just want to take care off the spawn manager, and it's born in behavior. Okay, so we have this one set it up now. So what I want to do next is I want to create a little past and maybe in the past holder, which we can take where the flies are going to fly round two. So I pretty quickly go into that, take the second point and maybe create some little pass where this flies are able to go to once again. You know how to set it up. Maybe you already have one, so I don't. So it may be I said we're not pretty quick and make it as nice as I like Teoh or even not up to me and also up to you, of course. And I want to bring the very last end, like in the center over here. And maybe I want to put some roundish, some around this behavior. Maybe here and maybe this is not Tibet, or I can't always put another point in between those. So maybe I duplicate this point over here and brings us on between Oh, that's not cool between four and 44 and five. And I maybe can make this one here. But rounders, How spiky that is outside the game field doesn't really matter. And we can once again always a design on what pass to whatever we police and like, Baby, I cannot take this lower one here and bring this up a bit and maybe put another one in between here. So gonna public it the last point and bring this point of it? Yes. So it's looking a bit smoother in the end. And I can also bring this one, Teoh. Maybe this position. Okay, so I have it's born now past nowhere, or flights can fly on toil the enemy ships can fly on to. I want to increase the speed to 10. And in the sport manager, I can now take this pass for the moment. It's just a temporary solution. I gonna break and bring this into the first wave. So you set up a wave size of one and bring in the past. Inside of that. And you take from the fly. Formacion, you take this formation. He in the second. Everyone in the fly information passed. Of course. Now we need to have something where we can see the pli fly. Prefect, we want to instantly. It is going to be from the prefects. Will the enemy ship one? Well, we don't have the other ones, so we don't take care of them. That we want to have enemy interval off. Maybe 0.5. Okay, It may be a waves born interval off three on. Now we can say how many flights we want to spawn. We can say 10. We can also say 20 because we can fill up the complete playfield at the very end. We're gonna have to wait, like three seconds before the invoke starts. And then you can see the flies or the little ships are going to go into their automatically fill up the play fueled by its amount. As you can see now we have, like, 123456789 10 as we already told them to dio or told them to be And that pretty nice I guess the speed off the enemy ships is a bit di sopra Probably put in a number like five or six and maybe we decrease the reach. Distance 2.2. We're gonna have to test all these numbers on runtime. Maybe also increased the rotation speed to 10. So it is not like legging around too much. It maybe want to go to the sport manager and bring down the enemy's born interval to point to appoint one. So there, So maybe a bit closer together. So let's test it out again. Once again, we can always be wrong, right? And we gonna This is what we need to test around. As you can see now they're flying zoo purse mostly on our pasts and going inside the formation. And that's pretty cool, right? So when we now can do is we can now design this stuff for the medium ships and the both ships as well, and bring them also per wave inside the formation. What you basically can do now is you can now create a second wave. So we increment this size off the way, Phyllis to be to everything inside. The 1st 1 is copied all over. And this way, if we maybe only want to add five, that we can increase that again, Ever get another fight? So where we have a total off 20 now and we can check if the sport interval in between the waves is probably too big or too small. So after three seconds, the 1st 10 not coming in after another three seconds, another four coming in or five in this case. And after another three seconds, you can see there are the rest off the five, and the formation will once or whenever they are inside. It's full, and that's cool. That's when we wanted to know. We want to make it so that we also once again spawning medium ships and big ships at the same time in one way. 22. #21 Spawn Waves 4: welcome back to the course in the last video, we were asked Lee, filling up the way flips and make everything work so far and we also set it up. The enemy ships a bitch in there, so we changed some values. So we are, like, faster rotating, increasing the speed a bit, decreasing the reach, distance and all the other stuff in this part. I want to go over and add the possibility to also put in, like the other enemy shells, like the medium at the boss ships. And basically, we're going to do the same. But we have to change some things here and there. Before we go forward, I want to add or show you some things to keep a cleaner spawn manager or maybe a one which is visually a bit better for me. I gonna like to add headers in those US grab records and we can put in the head of every time we have a public very able behind it. So we say header and we open close parentheses and inside we're gonna put a string para meter. The string perimeter for me is going to be now intervals. And when I'm saving now and going back to the script, you can see that this is going to pop up above the two interval variables over here. So we have intervals and we have, like, those two intervals and I want to add another one, which is going to be a sitting by between here. Like before the prefects come. So I say, head again Open close parentheses and in quotes I say pre fabs don't forget to save and go back and after that should be now. Ah, like a dark, pre fabs name As you can see, we're gonna clean up the view off everything we're working into And we can also put one on the very end before the wave comes It's like we got just put another header in square brackets Once again header and on goes Prentice season inside with, say waves. You don't have to do this. All of that stuff is optional. But I want to show you how you can simplify later on when you're setting up games and stuff , you want to make sure that everything is like s Kaleena as possible so you can make use of it easier or when you work with other people that they know are There are the brief upstairs, this stuff where I have to change things. Okay, speaking off prefab. So we need to have, like, three more or no to more or game object at the beginning. So public game object, it's going to be the wasp prefab. Once again. I just name them so you can name them small, medium and large, A big game object, whatever or pre fed, it's going to be for the enemy. And if you don't remember or you don't know what the prefects are, you can even say enemy pre fabs. Then we have a game object again. This is going to be, let's say, boss prefab. So in this case, this is the smaller ships, this other medium ships and there's one are big ships, except don't forget to save and once again, go back and see if everything looks as it's supposed to. And all this Yeah, prefab slots are going to be here like it. And now you can see we don't have anyone or boss prefects in here. But here we're gonna have no enemy prefects. So every time we create a specific level or anything else, we can redesign the complete spawn manager per level or per 10 levels or whatever you police. So but like like when you have every 10 or every five level, you want to have different pre fabs. You basically load specific scenes with specific set ups and maybe a specific backgrounds and all the other things, so you can easily see that later on as it's you, as it has to be. Okay, since we have done that, we also need to make sure that in our wire loop in the enumerated or corroding, we're gonna do the wasps at next. Where does that need to be? Is basically before the yield return waste born interval, because we want to spawn them one after another. So basically, we can take this complete port here, duplicated copy and paste whatever this is going to be. The wars WASP set up. Basically also, what we need to implement is now another formation for the wasps here as well as the worst around. So it's a public and make sure you are inside wave. Once a moaned, we can also already implement bust amount so public and boss amount we can basically take the same path. We're gonna fill in, automate the passes later on based on the wave. And we can pick that later on. Also from pre fabs if we like to. And we're gonna have, like, two more formacion. So public formation is going to be the WASP formation. So it's the one in the center, and then we're gonna have the public formation. Boss formation. Don't forget. And the line was a semi colon off corpse. So we have, like, all of the needed stuff we're gonna have in here. But we also need to increments those ideas. So we have a wasp i d here and top is equal to zero. So we start always at zero. You don't once again have to put it to zero. It basically always does it automatically on. We have a boss idea. Okay, cool. So now we have everything set up. I guess so. When not we gonna implement that? So when we go into the wasp, follow up stuff over here, we want to make sure that we're taking the wasp amount. We want to take the wasp prefab. We want to rename this one to be not fly behavior, but actually doesn't really matter. We can also take it like it ISS but to make sure it is everything correct? We just rename this toe wasp behavior. Same. Here was behavior that's been set up. What we want to put in is in here the not the fly I d but the wasp I d And here is going to be the WASP formation. The past is going to stay the same. And in here we want to increment power was I d Okay. And that's everything. What we need to do for the wasps. We can copy that once again. It is the same for the bosses. So control, they rename this year bosses once again And here is going to be the boss amount the boss prefab And here is going to be the boss behavior. So once again we just rename it. We need to do this twice he and there What we didn't do is actually we didn't renamed this one here This new game object probably we can I know we shouldn't reflected this. We just name it. Ah, new wasp. And here, like because we're here in the worst and in here, we're gonna say also you want, and that's pretty much it. And we can basically say here it's like going to be a new boss And here's well, new boss. And then we're gonna say, Of course, we want to increments or take a bus I d. And here the boss formation and we want to increment both I d. At the very end. This well, and that's everything we need to do over a year. So again, easily put it now a good amount of sets for bosses, wasps and flies When we don't have any arrows as against, he's going to become a bit more crowded now because there's a lot of stuff to set up, so you might want to think about how you want to put all of these things together later on . We probably put in some range sliders or something like that. So they are rearranging themselves based on the car car, yet the correct amount, or we're gonna give it some limits. Whatever, we're gonna have a lot of possibilities, or we're gonna create the some debunking inside the console so we don't overdo it like when we have like 20 waves, and we only we had take, like, four ships, something at the same time. We don't probably don't see what's the current amount off the off this particular wave. And maybe do we know if that is overtaking over doing it? We don't know. But that's basically everything we need to do. Now. We can take the wasp and the boss formation. So transformation here wasp information there, and we can do the same for the other ones. That most easy part is we reduce the size toe one and bring this one back to stray. But we need to make sure that we don't overdo it with the fly amount and said this one at first to be five once again. Currently, we don't have any boss Prefab and Watts prefer, but we're going to create this in the next video 23. #22 More Enemys: welcome back to the course in the last video where we're actually setting up the way for this two bit more dense. And so the fly information was permission and the transformation is always on the same spot . Also, we are We have set it up it so that we're able toe incident jade wasps and pulses whenever we need toe and what I want to do now, as I want to implement to more models for the Boston Center Wasps. So if you like to, you can take the ones from, ah, the course itself. So probably they are currently in the course to download, or you gonna have them