Unity Tutorial: Making a Mini-Golf Game!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
because we are in fact making a little mini golf or Mini Putt game growing up I don't know like mini boy always called Mini Putt here as opposed to mini golf but depending on where you're from though there's gonna be different preferences growing up it seemed like Mini Putt courses were everywhere you couldn't turn a corner without there being one and not only that but like every computer had like you know 20 different Mini Putt games available for it that you could purchase it way way way back then it was um I don't know it was very in and now like I don't know I don't like I can't remember the last time I've seen a Mini Putt course anywhere in real life and not that many games for it I don't know I always really really really enjoyed it was just a fun thing you know to go the whole the family bring a couple of friends that sort of thing you have 1700 hours and stardew valley holy crap cool man that might be more hours than I have in any game trying to think about it I don't know yes this is the first dream for this project and the intention with this one is actually to have the idea was to pick a game that would be relatively limited in scope so that we could finish it in one go I don't want this to be one of the things that we need multiple sessions for because sometimes they sort of fall off and distraction and life comes up and then too much time has passed and I don't know where to go anymore so we're gonna hopefully be able to do it in one go okay wow you're right world of warcraft Oh doesn't have a it doesn't have like a steam thing for the time but yeah I know that some of my characters and Wow the slash played time is it's very very high we're gonna say that but in terms of steam I don't know which what what I have I mean I know I have an over a thousand hours in you for and possibly both to 5 and sub 6 SIF 4 is a little fuzzy because I played someone pristine versions and things like that I don't know we'll see if a mini golf course right next to your house oh my god that's amazing alright let's uh let's talk about the program here so we're making a little mini golf game which is gonna involve making you know we're gonna have a little hole or a level let's call it level okay I mean technically you know if you're if you're going whether you're golfing like real golfer or Golf you know each each thing it's a whole but to me the whole like we're talking about here would represent the actual you know whole as opposed to the whole course track whatever so will probably refer to them as levels here because everyone will sort of understand what we say when we mean level Plus this is you know it's a game so level seems relatively appropriate what we'll probably do is whip together maybe to just to technically have the ability to swap between a couple and we'll do that and then we're gonna want to have the ability to bounce the ball or the the bounce of the ball around and score some three-pointer Grand Slams right give me something along long see I've never played golf your friends I was gonna say golf with your friends as far as I know is the only sort of Mini Putt game that's no boot these days and I've actually never played it but the interesting thing is it wouldn't be that hard to add multiplayer to this either if we do a follow up stream it might be some multiple for multiplayer if ocation of it although we had issues the last stream that we did was a multiplayer stream we ran to the problem where the current multiplayer stuff in unity is deprecated but the new stuff isn't quite out yet so we're in this really fuzzy in-between time that's a little bit awkward there so we'll see how that goes I said I don't think there's a programming category there's a creative category and then I think what you do is you add I guess there's basic programming there's science and technology I think the idea is to put hashtags in for things yeah programming game programming game development there you go oh I played that so we've got some tags for it but science and technology for game dev I guess that we made the most appropriate used to be just had the the creative category and then yeah you'd use the tags but there you go we'll throw that in and see if that's the most appropriate for twitch science and tech which is weird cuz encapsulate all it to computing I know it it's weird to me that they don't have just a clear like like game programming category because it's actually something that it's fairly frequent on Twitch and and tuff tails nicely with their their gaming audience anyway we're gonna start off we're gonna just make the first level real quick and for that we're gonna pop into blender over here so blender is free open-source 3d stuff we're all fairly quick with it it's it was bit from a broken dick thank you very much mmm oh subway oh that's right because subway is like sponsoring twitch this month they've got the custom emote but also it's September so if you haven't subbed before subs are half-price for September so it's a good time to do it if you haven't done it before oh wait this is not going to be sort of a too much of a blender tutorial but I'm gonna give you enough that you can easily replicate this so this is a blender I have an empty scene here normally if you start with a new project there'll be some some garbage in here like they'll be it there's like what a default cube and things like that that you'll want to get rid of the easiest way to do it the a key in blender toggles between selecting everything and selecting nothing although sometimes for some reason it seems to stall out on me like I don't I don't know why it sometimes it seems to like stop working just in blender 2.8 which I think this is the version number here I don't know what happened there but you can select it all with a and then hit X to delete everything what I like to do clear out everything and then go and save defaults save startup file and so that way you'll start with an empty project instead of the one that's got a cube a light and a camera in it because we don't need any of that over there yeah blender 2.8 is really pretty and I suspect the UI is is much stronger for it I'm still I'm still actually adapting a little bit to the the new blender UI because it has been a while since I've worked with things but we'll see how it goes thanks for all the we got some gift subs coming in from from seanix they think you're on chanak's and oh yeah we'll have to do maybe we'll do it between the programming stream in the start of gaming will do a read of the of everyone normally did stir the a shortcut changed you no longer toggles like it used to a selects double-tapping ad selects hell I could probably change that one of the things I changed is the preferences over in key map over here the spacebar action listen defaulting to play or something anyway I put it back to search that it would like to use okay thank you very much that anyway we're gonna be the course so what I want to do for the the track the level here is I'm just going to start with a flat plane and sort of stretch it out now we need to figure out kind of units like what size things should be the the standard way of operating in unity is to treat each war each unit each world unit as one meter okay and I think that's probably fair I guess we'll sort of work with that how big is your is a normal sort of kind of you know Mini Putt little track I don't know you we wanna do the first one four meters long by one meter wide I mean that's not very big but we can just play with that and fiddle around with it and it'll be a good starter most likely so what we're gonna do is we're gonna add in there we go shift a add in we're gonna add in a plane it's a bird it's a plane it's a well it's a plane and put one in so this is just a flat little mesh in here and by default it's it's apparently two by two maybe about two meters wide is gonna be okay I'm trying to think if you're the thing because one meters like this now two meters why does kind of make sense because when you are your well you don't T up in Mini Putt but if you imagine it the the T is gonna be sort of like where you start your balls sort of gonna be in middle here and by one meter to each side gives you just about enough room to sort of stand here whether you're left-handed or right-handed to put out two by six or seven seems usual yeah I kind of like that idea so what I'm gonna do here right now in object mode if I hit tab it will go into mesh mode over here so yeah single a select all but double tap ad selects okay I suspect my muscle memory for it is still gonna be different but um but that's fine so we got the plane over here so it's two by two we'll leave it a width of two what I'm gonna do is I'm going to hit B for a box select drag here to grab the first two vertices and then I think of g4 like grab and we can start pulling this around what I want to do is I want to lock this to just one axis so if I hit Y I'll only be dragging it along the y axis over here and actually I could even hit a number so if I hit four there we go so it's gonna move it four meters along the or four units along the y axis and I think that's pretty good enter to stop that DoubleTap a to deselect I'm gonna use to it and there we have that the the zero zero point here could be where we start the pudding from I suspect what will happen is we'll be placing the the key in inside of unity for where the ball starts similarly to how we're gonna place the whole one of the most annoying things and this is something I learned from trying to do pinball games for a while is when you're the cutting a hole into a surface your ball to fall under it's kind of a pain in the ass it actually leads to really ugly geometry because cutting a hole like to roundish holes may be gonna have like 16 or 32 vertices along the way and then it's gonna craft to create all these triangles as part of the mesh to connect over here you're doing awkward boolean operations to carve that in and then the worst thing is what happens if you decide you want to move the whole yeah in your you know your pinball machine or your Mini Putt thing it's hugely annoying to do that really really really miserable to do it which is why I actually made a whole tutorial a whole tutorial sorry I didn't mean to pun but it was it was delicious apparently at least to me for making fake holes in unity if you watch Rick and Morty you got real fake doors well we got real fake holes here anyway that is this is gonna be our little starting area what I want to do is I do want to get some some walls up here so that we can't very wholesome so that we we can't lose the ball all right so what I want to do is I sort of want to like extrude upwards actually let's make a little bit more interesting let's use if I could control our and mouse wheel up we can put a couple of little cuts in here and then what I can do is maybe there you go we could have something a slightly more interesting that way now I'm trying to think of the best way to extrude the walls up probably is just selecting the edges and then extruding that way how do we actually first of all go into well if I just select everything and go extrude edges I don't think that's gonna do what I want no that is not quite what I want we just want to select just the edges you know what's actually the best way to do this I think where's okay where's the selection modes the UI has changed so I'm a little bit lost if if I just hit L that's not really gonna do what I want yeah copy the edge vertices is sort of what I'm thinking the extra edge because like it could it could hit E escape and then scale out where that's not really what I'm looking to do though because normally what I would do is that was extrude like up and then inin things a Luke slice what I'm just trying to think of the best way to select this okay and select maybe I'll just okay here's what I mind you I'm gonna duplicate what we had here then what I'm gonna do is it P to separate the selection so now I have two objects I think this is probably gonna be the way I'm gonna be the happiest with doing it because I want to keep the ground plane separate from the wall objects it'll make it a little easier to clean it or something like that so let me call this the walls so in my wall object I'm going to tab into this and then here I'm gonna extrude this upwards you scale it up slightly I'll just extruded upwards and remove some planes and invert things it's not exactly what I was thinking of doing and I'm sure there's a better way but I'm just gonna get rid of these faces here here here and the ground one okay so what I have here is I have two objects I have this one here which is just the walls and I have another one that's just the flat part of the map I think that's probably a slightly cleaner way to do it but we'll see now the one is she going on here is that the normals for this are going to be facing the runway in 3d gaming stuff polygons like faces and whatnot like this only render on one side for like many many many many different optimization bonuses in a blender by default it renders both sides of something but if we were bringing us into unity only the outside would be rendered the inside face here would be invisible so I think what we'll do is we'll just select this and there see here's the thing with the new version of blender here I don't know how to get it to show the normals which would make it obvious what the heck was going on it's really easy to invert the normals but I'm trying to see how do we show the normals cuz I mean you can just invert normals that's easy but I'm not sure that's showing the normals is gonna be in here because we're just looking to flip normals but you can't you can't see that anything has happen here um oh well I can turn on back face culling there we go at least this will show us so you can see here now what's happening is it's rendering the inside of this but not the outside that's not necessarily what I want to do still but it'll work for now it'll work for now it'll still look a little weird in unity but it's not too bad what I might do is just lower the walls a little bit at least this will function the idea is we're gonna get something that works okay that doesn't just toggle the wireframe mode anymore that's interesting I'm just gonna shrink this down a little but there we go and then go back to showing me render or solid and yeah let's see that's what I was doing before I pop this up with n but I can't see the display normals anymore like and would bring up this little property page and would have a little checkbox to display normals but they've moved it maybe I shouldn't have upgraded to the latest version of blender because I ain't know I don't know nothing about it anyway let's go ahead and save this F unity project mean you put assets levels so we're gonna call this uh level one boom dun dun dun and we'll just pop back into here I'm going to do it in button with two rings on the one one top filled one empty has normals um this guy over here oh if we had the solidify modifier maybe so the modifier is still over here oops you know search that window yeah good call the solidify that probably is gonna be better okay so we'll go ahead and do this I don't know if we've gotta do anything with the slice and the normals we'll see so we've saved it into level we've got level zero over here let's see what happens if we just drop this into our scene and are we happy with things look some looks about right to me today so orientation that drop down to the tip it's not face orientation that I was looking for in these pop ups it's theirs um to show them normals they'll be a little line face Orange I mean maybe but that's not what I'm looking for either the this show normals was would draw a little line but anyway to do fix the shadows yeah so there's a little bit of a shadow difference thing we'll deal with that in a second anyway we've got a little level in here excellent um one of the things we're gonna want to do is probably have a mesh it looks a little weird cuz I was in perspective mode but there we go that looks better I some I like to work in isometric mode because I find it a lot easier to work in in particular what I like about isometric mode is that the camera is on orbit around whatever object you're sort of centered on whereas when you're in perspective mode in unity the camera instead like I don't pans I don't know the camera terms in here but that's not usually the mode I want to work in because mostly I'm using it to you know work around whatever I'm object I'm in and placing things mm-hmm we're gonna ignore the viewport thing because we've got to move on guys so we've got our simple little level I've got oh we do have to do one more thing because I want to apply texture to our plane here in my fake whole project when you get with diet download this w readme explaining things included link the old the original fake whole project which explains how we did this but I do have a grass texture I want to apply to the plane but oh I guess it actually started with fairly saying you you v's did it really why does it have fairly say movies I don't know but we'll take it done we're gonna leave the walls white so there's a little field that we're gonna be going on boxes have good using but but it's because I've got a I made this a plane and then I jerk these vertices side to side so I was expecting there to be a bunch of distortion I guess there is actually where it's there it's just the texture doesn't really show it so all right well we'll just move on we can when we get a more complicated thing we'll probably have to look into UV stuff but if you're gonna ignore that that's great alright we're also gonna need a ball in the level right so let's go ahead and just go and make a what's the best place to do it probably in here great the 3d object will get ourselves a sphere which is gonna be our ball now this ball is way too big because by default the ball spawns in with I want to say a radius of 1 nope diameter of 1 okay so this is a 1 meter by 1 meter ball so what we want to do is shrink it now the question is what is the diameter of a golf ball for 22.6 2 millimeters I mean it's probably Imperial one point six eight inches even in inches it's kind of awkward let's go ahead and that will call it 43 millimeters as a diameter so since right now it's currently one meter on a one scale we can safely go and say 0.043 in all three scale directions we should end up with something that looks roughly golf-ball-sized on this it looks it looks tiny to me but I don't know if we go in position U at 0 0 0 um I guess if we do that you'll actually be 1/2 embedded into the ground here but there we go is that appropriate I guess it's I guess that seems about right sure can we make it 42 that that would be pretty good wouldn't it just because the answer life the universe and everything technically we're rounding down incorrectly but there we go well our golf ball will be 42 millimeters in size now if we want this to be a physics enabled object it does need a Collider on it as well as a rigidbody but at this point if we go and hit play of course it's gonna fall through the ground because we have not told unity that there should be any kind of collision on our level geometry over here so that's what we're gonna do now on our plane we'll add in well we'll use a mesh Collider so a mesh Collider will be will use the triangles of the actual like graphics of this although I mean you can replace what mesh is being used but by default it'll use the same mesh as what is set to the mesh renderer on this object so it's using that that object called plane over here and that's gonna be good remember we might decide later on to make levels that have like hills and bumps and things like that so we can't just like cheat and like throw a big like you know some sort of invisible plane in here we have to use the mesh Collider so now if we hit play the ball there we go hits the surface we'll want to do the same thing with the walls and I will use a mesh Collider over here the one thing you have to remember about mesh colliders is that two different mesh colliders can't really collide with each other so if you're doing physics see things and you want like - like oddly shaped objects to be able to enter collide in some sort of physics e-way generally speaking you're gonna have to take one of them and build the colliders out of other types of primitive shapes so if you do convex stuff that can work as well and you get this sort of fuzzy thing but anyway we're gonna be fine here but random invisible Walters fun oh yeah fun that does sound fun yeah we can talk about making things static as well but we'll we'll leave that there for now let's go and give a little bit of extra flavor to our ball over here I have a of material ready to go here which is gonna add dimples to our golf balls hey excellent stuff yeah we've got a proper golf ball loaded in so I just I wanted to get some of the the visuals ready a little bit ahead of time so I wouldn't be spending my time googling for an appropriate texture I got links to the the source of these in that readme okay good so we've got a ball that can land lovely what we need now is let's get the whole figured out so again getting the whole carved into the mash is a big pain in the butt especially if at any point you might decide to change where the hole is which is why we have this fake whole project and again I have a full video for this but I'm gonna go and talk about how it works a little bit this whole prefab here if I go and drop it into our world it's gonna be way too large scale difference but let's do the same scaling because I think this was set up for a default ball that's like one meter by one meter so let's shrink this down in the same proportion and we'll check to see how that feels next to our ball so that's zero zero zero you come down here I think I think the hole needs to be a little bit bigger I think a golf hole is a little larger than this compared to the ball stream is gonna be full of ball and Wolff raisins golf holes are 4.25 inches so that's like two and a half times bigger in diameter than a golf ball ish just ballparking it something like that I'm it's already bigger here I think what I'm gonna do is do something like point seven just arbitrarily there you go that may be a little larger than it needs to be but you know it's it's just Mini Putt we can make it a little easier we can scale and 4.25 freedom units yeah yeah I think that's pretty good over here now this whole visually changing here if I hold down the right click and mouse wheel is it changing some sort of snapping distance or something huh that's your camera speed it's not it doesn't seem to be changing maybe camera movement or maybe if I was in perspective mode anyway we'll leave that there scroll and move speed Oh what when maybe when I'm using the arrow keys to move around let's see ah yeah if using the arrow keys to move around okay that's good to know hasn't come up before so right now this whole is a visual trick it is not actually yes see I'm used to I don't know when they added in there's probably way too disabled I'm used to holding down the right mouse button and doing this and then scrolling in and out and continuing to the cycle around here the little annoying to have to drop that drop the right click and then pan around there's probably way to disable that but that definitely didn't use to be in there this camera trick works with us Lee again I've got a full tutorial for it so we know we're not gonna go into nitty-gritty here but the this hole has two different visuals to it there's this mesh that I called kick out hole because originally this was made for pinball and you can see from the outliner like what this looks like over here and then there's this thing called depth mask over here and it's just a cylinder the depth mask what it does if I go and disable the kick-out hole you'll be able to do death mat that mask does what it does is it prevents rendering of objects over here it gets rendered before everything else and in terms of the 3d generation engine when the 3d engine is then going and putting down the terrain the Train thinks oh there's already some graphics here that I'm not supposed to override is basically what's going on so it's leaving that unpainted and then after that as a separate sort of layer in the rendering then we go and have the kick out hole here I did this in our tutorial by having custom shaders put in here technically the render order so the render queue apparently you can change it on the fly through code but it's fine so we've got a depth mask shader over here and the whole shader the whole shader here is just a standard material and every way it's a standard material it just has a slightly different render queue you can see it renders on one nine nine eight whereas the depth mask renders on one nine nine nine and the ball also has its own custom shader also on one nine nine eight which is basically the same over here you can look at that video which will be linked in this project or you can search my channel for it for exactly how we figured out how to make this work basically it's tweaking the order that it renders things in and prevents the grass the grass is actually here and actually you'll be able to see it if I get play the ball is still hitting the tabletop over here it's still physically there we're just using visual tricks to not show you this grass texture just as close they can get to sort of like that green carpet astroturf II kind of thing on a quick google search it's still physically there which is why the ball is hitting it but we don't see it so how do you make it so that the ball can actually fall into this hole because it's hole well I mean the whole object exists but there's still a tabletop here well again if we watch the tutorial what we do is we have a slight trick where we have this Collider here we have this trigger over here that detects when the ball is entering this area and when the ball enters this area we change the collision rules with the ball so that it can no longer collide with our tabletop or our grass surface we tell it they can no longer collide with the tabletop instead the only thing it could collide with at that point is this so-called kick-out hole and that allows the ball to drop through the table which you can't see but drop through it into the cup mm-hmm did you do using shader graph or um it's not a shader graph I I tweet just some shader stuff but it's like the easiest simplest thing it's basically the two standard shaders just like render q difference and the mask is also a pretty standard thing which it doesn't like render any visuals doesn't draw anything but it does right to the the z-index buffer to say hey there's something here don't render over me kind of thing and that's it full tutorial you can watch that one so what we need to do now is we have to wire this Collider to change what layer this ball is on now the prefab I have to set up for this already has a script which is from our tutorial which is this boom change ball layer script and all it does it can be even renamed to something a little bit more generic it has an on enter trigger when the object enters here there we go it checks that it's tagged with player which is how we did it we may you may want to change like the the tagging system for detecting of whatever but player work with us so it's just checking to see if the thing that is entering or exiting the trigger is the player object which is a ball so we need to make sure our ball over here has the tag of player and there's other ways to check it but this is going to be what we're going to use here if it does it's gonna change the layer of this object to layer enter and then when it leaves it's gonna change the layer to layer on exit so what we're gonna have for this ball is its normal layer is going to be the default there and in unity we can take a look at our layers over here if we go to project settings and we go to and I've got on the wrong screen but I'm going to bring it over I actually have to clear it a couple things area so project settings and then there's tags and layers over here these are all the layers that you can create you know sort of arbitrary amounts by default everything gets the default layer over here so what we're gonna do is we're gonna make another layer which is gonna be the ball in pull layer in the in there pinball project technically I have a separate layer for the ball on the table because I filter out the collisions in different ways but basically we're just going to change the ball from default to ball and hole and then back to default as things happen what we need to do is we then go into the physics tab over here and we adjust the collisions this is what is allowed to click collide with whatever and basically what we need to do is oh I do need one more layer in here this is going to be the this is like the whole Collider in here because when the things that have the ball and hole there can only collide with the whole Collider and they won't collide with anything else so that's what we need to change in the physics system over here there you go so yeah ball in hole isn't gonna collide with anything at all except for ball and hole and hole Collider they will collide with each other and that is it default will still collide with everything else so normally the ball is gonna be on the default layer so it can collide with the you know the tabletop surface the walls the windmills or or whatever but when it activates this special Collider over here we need to change it so if we check our I need to open this again our layers when we enter the collision we want to change the ball to layer eight which is the ball and hole and then when it leaves the collider it needs to get reset to layer zero which is default and if we do that I have done everything correctly which will see if I hit play layer player oh there you go this has to be on the default layer so that the normal ball can actually collide with it [Music] oh no hold on yeah this whole thing this whole thing needs to be the whole collider layer there we go and I think I've missing something yes I am it's very important that the objects on the default layer still interact with the whole Collider that's why they didn't mistake actually whole Collider can have everything enabled it's just ball and whole can't interact with anything else okay let's try this again because what was happening there we go there we go perfect the ball wasn't actually colliding with the collider because the default layer wasn't set to collide with whole Collider so now what's happening next we could do it in slow motion as the ball falls it enters this Collider the code on this is gonna change the balls layer if we look at the balls there right now it's on default as it enters that it changes to ball and hole at which point it can no longer collide with the surface the only thing it can collide with is is the cup over here the hole so there it has done that and then it falls in and it sits over there we have set things up that if the ball were to somehow come out of this there you go it does it's hard to see if you stare over here it'll pop into default for a second there before falling over there we go if I just move it over here everything is fine if I move it back over here it falls into the hole our physics work and what's nice about the NES this will go on YouTube on the quillion creates channel though it's nice about this is by doing it this way instead of physically cutting a hole in the mesh is I can move the the hole around just by dragging this hole prefab to a different area we can change where this is and it saves so much time because otherwise you'd have to go back and blender physically cut out holes again are you happy with it or you're not blah blah blah and here again we can rescale we can make the hole bigger or smaller depending on you know game balance and various things like that okay so we got you over here um let's get our ball on the other side of this bad boy say over here and now we need to make it so the player can interact with it that's about it mm-hmm you can make a mobile hole in game to that oh my god I didn't even think about that but theoretically cuz this is a computer game if we're willing to like you know become unreal there's no reason you couldn't make it so that through for whatever reason the whole actually moves in the game maybe does a little figure eight over here for super difficulty mode and that would actually work oh my god that's so funny it moves as you get closer to it the whole runs away from you but the hole in the lake is spinning a lazy susan mm-hmm I didn't do it so that it could move it in-game I get it so that I could like move around if I'm not happy where the position of it is out of game as I'm designing the course but yeah you're absolutely right this can change dynamically while you play I had not that had not occurred to me that's really funny could do an inverter mode you hit the hole to the ball you have the whole spit the ball back out yeah I mean and originally again this was a this is for a pinball game this was a kick out hole for the pinball game and the idea was you'd get the ball in there you know the the machine go Bing Bing Bing Bing Bing Bing and then ejected the ball yet look um so that you could continue play that that was the original idea you could do that here although that wasn't really have a place in a Mini Putt okay what we need to do now is we have to get we have to be able to hit the ball around so let's work on that so we're having to do some coding for it at this point we could add the script to the ball but I don't think that's what we want to do I think oh there is one other thing we're going to want and this has to do with interacting with the unity system this is a lesson I learned after like ripping my hair out trying to figure out my pinball game unity has certain limits on how fast things can move but also how fast they can spin and the cap specifically the cap on spinning for the physic system is too low for well certainly for pinball but presumably also for golf for the physics to work properly what happens the ball doesn't spin enough so it ends up like just mostly sliding across the surface instead of rolling across it which is obviously not what we so I do want to add a small script to the ball to get it to remove its limitation on how fast it can spin in like by default it's a smart thing to have in you know in your game design in in unity by default to prevent the physics we're going completely bananas but here we want to be able to be fairly agro with the physics so we're gonna add a component to our ball and it'll be something like uncap physics speeds I know something generic like that I mean it could have just a script for ball but we might want to use this behavior on something else so all we're gonna do is for this we are going to find our rigidbody which technically because rigid bodies a fairly common thing we can just access it you know directly but I'm gonna do a little get component rigidbody check over here I mean I guess I could do a requirement I can do something like if RB equals null debug log well just catch like if we as humans did something dumb no rigid body found on game object dot name or something like that and we'll just return but then all we're gonna do is this there is is it's called max yeah max angular velocity yeah since it has a default of seven and I don't know what seven really represents an angular velocity but I can tell you it's way too freakin low to do what we want in when we're doing the pinball game if you get like the table and you slant it although instead of slanting at what we did is actually just change the gravity vector that way you don't have to work with like a whole model that's tilted all the time which is a pain but the ball starts rolling and then it just never accelerates in rolling it's almost like it's pushing into molasses because it's not allowed to start spinning faster and faster and if you whack it hard enough it'll just skid across the tabletop instead of rolling across it so what we're gonna do is we're just going to set this to infinity mu and just to make sure that it's got no limit on this and for our purses is going to be okay we don't need an update at all in fact if you really want to clean things up you could do something like destroy this so this script will remove itself after it's done running just to remove any possible overhead of its existence since it doesn't have an update routine I don't think there's truly gonna be any overhead on this but technically the script doesn't need to stay on the object after it's done its job so do this DOCSIS radians per second for seven you get about we're on the rotation or second yeah so one rotation per second is not fast enough at all so we do this now the ball can spin at any speed we're still probably going to want to tweak maybe some physics materials to affect the bounce maybe some of the friction dynamics but this was the big thing that'll make it feel pretty realistic okay next thing I want to do so we want to be able to whack the ball so in golf every whack of the ball it's called a stroke so between ball hole and stroke we have a lot of potential for dirty wordplay here but hmm we're gonna be grownups right I think what I'm gonna do is I'm gonna make a stroke manager rather than clutter the ball with a bunch of logic I think it makes more sense to do this and have the stroke manager be aware of you know what your ball is and then apply things that way I don't know something like that we may want to subdivide it even more I it is really nice to try to avoid big monolithic scripts if you can so try to break it down but the idea is we're gonna have something like game object player ball that we will you know somehow find or something like this and there might be a multiplayer thing what if there's a scenario where have multiple balls I don't know there's gonna be something like that and then we're gonna have some sort of some sort of logic in here for handling the the input we clearly are gonna want to be able to provide the ball with direction and power some sort of ability for the player to affect that but in our first test version what I'm gonna do actually even want the game object we might want to store the rigidbody for it - for both that's stupid that's just let's just move on for now we'll figure out a way to keep it clean later on clear the stream is hey so I'm gonna do a really simple dummy thing here which is we're just gonna check if we hit the spacebar we're just gonna go and push it up the ball and make sure that that part works and we'll iterate over that so we'll just do something like if input dot get key up key code spacebar just do this for now Wacka double is what we're gonna do so our player ball dot rigidbody yeah I guess you want to store that let's just do this because we can get the we can get the game object from the rigidbody really easily so we're gonna do this and we're going to add some sort of force to this object so I'll just set they and for now Lou stop there you go vector three for sveck equals new vector3 I'm trying to member in unity Zed would be into the camera or vice versa I know we'll do this and see what happens we'll just give it a force of 10 oh just try to get a vague feel for it so we're gonna add a force to the ball on that I guess we want impulse don't we for the force mode which best represents like a single instant hit the numbers that you're going to be passing into this vector are gonna be slightly different if you're on the default and what's the default force mode if you don't do anything it's implied to be well just dot force because by default like the numbers with the dot force which is default it's sort of if you're adding a force like frame to frame to frame as opposed to just being a one-shot over here one thing is normally you don't want to do changes in the physics system on update because update runs on every on every frame in terms of every actual frame every refresh of your monitor basically whatever we're not going into frame rates but it happens there this is different from the sort of fixed tick rate of the physics engine the physics engine is operating at a in in a way that's disconnected from the visual frame range things like this because your frame rate can go very slow or very fast or things like that and you know with delta x and things like that you can you can balance it out but you're still not supposed to make changes to the physics engine outside of the outside of the fixed update because that's only when it happens technically speaking if your update here let's say your game is running you know like my mom who's got 144 hertz refresh rate and if you turn off vsync you could run even faster this thing this game here it's so simple so far could run it a thousand frames a second and so you could be trying to apply a lot of things to the physics system but it's only when the physics system is doing an update which by default is one every 50 or 50 times a second that it will actually take effect so generally speaking you want make changes to the physics system in fixed update you know everyone knows this but on the flip side what you don't want to do is you don't want to read inputs in fixed update because fixed update doesn't run on every true like on every effective frame of the actual game it's only running on every physics tick so it's entirely possible you could miss some of these inputs he up he down on a fixed update check so really the best way to do this the correct way the correct astray may be to do this is actually to use both update and fixed update because this runs a once per visual frame use this for inputs and then fixed update runs on every tick of the physics physics engine use this for manipulation this is sort of correct and then what you tend to do is you might set a flag like we could do something like in the input do this have a boolean here do whack which is set to false all this is gonna go away later but you know for the sake of argument so if you hit the spacebar we said do AK to be true and then in fixed update we do if do whack I was hoping it would fix our indentation there I think there's a hotkey for it but there yeah there you go if do whack whack at a ball set this back to false and do that this is a little overwrought for what we're doing here but it's it's a thing you will run into issues you'll run into very weird and hard to debug issues if you are doing your inputs and your physics in the same update whether that's update or fixed update which every one of the two you use if you're doing both the inputs and them in the physics and the same one one thing or another will sometimes go wrong you know weird that way that's really hard to reproduce and track down so one of those things to try to keep in mind I'll attend debugging trying to figure out what my input Keys only work sometimes before I realize there weren't fixed update yeah and you can hide the problem if in fixed update you're doing if you're checking input dot get key for something this will work fine and get fixed input because all this does is return true or false if you're currently holding down the key but get key up and get heed down only returns true if the key was pushed down or released on this frame and by that I mean this visual frame as opposed to a physics rain so it's on the get he ups and get key downs that you get totally borked if you do it inside a fixed update so anyway we do this done that all right so what I'm gonna do so the player all over here we're gonna do a thing or we're just gonna find it yeah we'll figure again we might clean this up and do things in a different way find player ball so what we're gonna do is game object dot find object with tag where the tag is player this slow and dumb and could do badness I really don't like finding objects with tags because it's a string and you could forget to put set up you know did you remember to set the tag on the ball these you remember to set it on the prefab because otherwise when you drag the next prefab in here it may not have the tag for you to find it I actually really tend to like having a unique component on my object and searching for something with the component because the prefab will have it and presumably the component will need to have it like if we had a script on here that was just call you know it was just oh sorry create a new script called ball all right if we do this then what you could do instead is game object dot find object of type ball what's nice about this is it also confirms that compile time like what if I made a mistake what I made a typo here right if I make a typo here and then I mean situations like why is it never finding my freaking object why is this not being set correctly what's going on typos in the string is really hard to find whereas if I do this it's not going to compile because this doesn't exist and that the compiler is gonna be like whoa whoa we've got an error on this line so I like to move things towards a place where like I don't trust myself so try to make things impossible to F up for example so we could go and do something like this the interesting thing about this is by sort of looking for objects and thinking about objects in terms of a ball is an object that has a ball component on it this is actually sort of leads you into the the doesn't say unity component system that's not the word I'm looking for that new a new system that they introduced the year or two ago that's really fast for processing a lot of objects simultaneously it's works of threading the job system the something component ECS thank you entity component system it's like not unity component system what is it the entity component system is effectively works not with this the implementation isn't the same you're not adding components to a game object but the way it works is the same sort of logic you you filter and organize things based on what components the entity has and you run scripts of like I want to run this function on all entities that have these three components on it if you if an entity has these three components on it this function is going to run every frame like that and it doesn't really fasten off to my his way so I like doing this sort of thing and that's the thing so in this situation and again finding something by name which is also possible right you can find an object based on its name is also sketchy for the same reasons as above all right fine find an object called ball this is particularly bad and annoying because I believe this can only ever return one I don't think there's a fine fine several is there know what's nice about and you can do a tag so you can find objects with tag or find objects of type it can return an array as opposed to just the first one it finds which isn't always what you want for our purposes here I think we'll just go with that and we'll see if we can find a better way to organize especially we start thinking what if there's multiple layers and things like that will clearly need a better a better and smarter system but for now we'll call that good enough so game object geo is equal to this am i covering any of the code with my head I think we're okay right no well we're okay right now so we want to set player ball RB is equal to this dot get component a rigidbody like so you might want to do like if geo equals null debug log air couldn't find them all and then you actually don't mind also want to do another one you know case it just in case something dumb is going on if player ball RB is equal to null debug.error could let you know that you've done the dumb but in theory then we've got stuff so if we get here we can do a thing like we might want to do a check like if player ball rigidbody is equal to no we might just want to return this might not be an error might not be an error maybe the ball is fell out of bounds got deleted and hasn't respawned yet right we don't want to do the fixed update we don't want to run if the ball doesn't exist but we don't necessarily want to throw up an error if it doesn't because there might be a legitimate reason for it and depending on how we do our game I don't know we'll see actually and that might be a good example of code that we could actually add to the ball what happens it falls out of bounds right what if it hits a ramp we hit it hard it hits a ramp flies out of bounds of our little level over here we could have the ball check to see if it's fallen below a certain level you know if it's hit like you know negative 5 and the y axis then clearly it's you know maybe falling out of bounds I think the right thing to do though is probably to have some sort of what I'm looking for in here sprites no not here okay over here then 3d object plane round plane have it just below here so it doesn't clip in minus 0.01 or something like that and then put a a collision logic on this we're gonna have this big huge have a collision logic on this where if the ball hits this then clearly it must have gone out of bounds and we should do a thing with it we'll leave it be for now I'll do um just because it's looking but ugly here let's create while it's still gonna look but ugly but less overwhelming ground material I'm just gonna make it brown there you go just that doesn't hurt my eyes quite as much these white walls are still driving me crazy and it's funny an isometric view how like wrong and terrible this looks but there you go oh yeah okay so in theory if we hit play the stroke manager should hopefully find the ball and if they hit the spacebar do N equals true let's make sure this is working and do whack player ball ad force debug dot log whacking it prone dirt so much realism whack it goes but fixedupdate does not Oh mmm why'd you write a function make sure you call the function or weird things will happen hey hey do I know if colliders on the walls I thought I did yeah else why did you go through that how'd you go through the wall heat into the Sun you need a little drag on this it may it may it may have just been going too fast oh we probably have to enable some dynamic collision modes on this bad boy did you do mesh renderer rigidbody there we go we want continuous continuous dynamic doesn't really have to happen so let's let's see let's say I just set it to continuous and let's go back over here and set it to 10 again is you I'm gonna go through the wall there we go you didn't okay so what's the deal with the collision detection mode over here you can read about in the help for full things but basically this has to do with when something is moving so fast we're on one fright so let's say this is my solid object and my ball is here and on one frame it's here but it's moving so fast that on the next frame it's over here on the youth in the discreet collision detection it may not notice that it will only notice is on a frame it ends up like being sort of clipped into this then it will correctly figure out okay there must've been a collision and bla bla bla bla bla with the continuous what it does it's a little bit smarter about not clipping through things when you're talking about a collision with something that is static like if you have one one dynamic object and one static object as far as I know continuous is going to be everything you need to handle that properly when you're concerned about multiple moving objects multiple dynamic objects that may or may not be moving quickly and you're worried about them you know their interconnections not being looked at as much those are the other moves speculative this new I'm not used to seeing that but I think we're gonna be ok with just this the other thing you can do is if you are running a game that is heavily reliant on physics has relatively fast moving objects and you need a lot of accuracy you can change the physics tick of the engine over here um I think so it's not here it's in time isn't it yeah which is always kind of annoyed me it's like you're trying to change the physics tick you would think it's in the physics tab no it's in the time tab this fixed time step this determines how many times per second or how much time in between ticks of the physics engine there is so by default it's got a point oh two seconds so it runs 50 times a second you could do something like this so now runs a hundred times a second and keep in mind the physics system tick rate is different from the visual tick rate in theory it will be truly fixed at that it's fixed ish if the physics system runs too slow for some reason it can start skipping some of these but you can turn this up a little bit and it'll give you a little bit more accuracy and things I think for us mostly because we're not going to have the objects aren't going to move that fast and there's not that many dynamic things it's a real problem the pinball game because in pinball it's a fairly small environment but the balls go really fast and the bigger problem was in the pinball thing is the ball has to collide with other dynamic elements mostly the flipper I was using an actual physics like using the physics system to run the flipper and the flipper flips super fast and it's also impacting another ball that could be hitting super fast so it needed a really aggressive time step in here that's not going to be the case in here because we're not going to use a physics putter what we're doing here by adding force directly to it this is exactly how the pudding will work in this game um and as such it's not gonna be a concern we don't have to mess with that at all but yeah when we were doing the pinball game it's like we really pushed the physics system to its extreme is it a good idea to make your wall cloud as much thicker since there's nothing outside them um it might be the other thing that you can do rather than you know trying to figure out how thick the wall Collider should be and all these different kinds of things is you could get better faster operating collision behavior if instead of using a mesh Collider which you're using here use a series of box colliders or other primitives so what you could do here is like not use this mesh Collider and instead you're gonna want it like a series of empties that have box colliders on them where is you and then you're gonna want to go go and position these like manually sort of in line with stuff because what happens box colliders box Collider sphere colliders something else colliders may I guess capsule colliders because they are predictable physical objects they the code to run them is much its runs really fast and it's much more accurate and much more bulletproof than mesh colliders the downside is that you would be you'd be creating a series of these by hand and having to hand place them but what you would have and this might be good if you're looking into development for mobile stuff because even though you're gonna end up with more colliders here these will run a lot faster and be much more consistent in bulletproof and you can set up these invisible colliders that are you know much bigger and wider and how you can have them meet much taller as well to minimize the chance of the ball going outside the bounds hell you could have non visible walls if you wanted to for some reason and do that sort of stuff so these are very performant and they're great way to do a variety different optimizations but for our purposes this mesh Collider can be fine and yeah the other thing we can do is we can declare that this level here is static by setting the static flag a number of different optimizations occur the lighting engine and the physics engine both get dramatically optimized in a variety different ways if we tell the system this object will never move it is fixed in place and that can that can do a big differences for you so using that static tag is really handy both for lighting and for the physics and yeah our shadows over here are detached from things we need to tweak the the shadow by over here this bias is a bit of a hint that kind of comes into play about like distances there I think there's a couple of different ways that we can adjust to make the shadows actually work better it has to do it with the with shadows the amount of sort of like graphical memory and processing for a shadow on a larger object is supposed to very fine object is a very very different if you if you optimize the shadows to be able to deal with very fine objects but you're in a world with many both big objects you're just gonna slow down the game like crazy for calculating that so I mean we'll have to mess with some of these some of the strengths and planes and whatever to get the shadow to show up properly over here but that's probably outside the scope of this all right you got that let's um I'm just hoping to get a little bit more done by now what I want to do is I want to work out the input for our ball controller over here because we want to be able to you know not just hit spacebar and have the ball go straight all right which is still constrained by the wall but we want to be able to aim and whatnot so I think what we want to do is we want to have some sort of arrow we can steer and then presumably when you hit spacebar maybe we have like the power meter that goes up and then down and you hit the spacebar or a second time till to lock in I'm a certain place and that's pretty typical right increase the camera near clipping plane to fix those is it camera or is it the like is it the near plane over here or the camera clipping but I don't because there's the there's a near clipping plane for this but does it affect the shadows I mean it's pretty near like yeah I don't think that's gonna have any impact on that we do want a fairly close clipping plane in fact we really don't need a very distant clipping plane we can set it like a hundred meters because we're never looking at things very far away but okay we could we can mess with the shadows forever let's let's move on to the game here so let's get a sort of arrow I think what I'm gonna do do I'm on it a 3d object or texture on a plane in a sense it doesn't matter because even a texture on a plane the planes a 3d object that's something that's gonna be scaled I think what I'm gonna do is I'm gonna go into blender you don't save anything and I'm going to make a cube I'm going to go into the edit mode for the cube I'm gonna hit G to move it while I'm on that axis minus one so I'm gonna back it up but I mean leave the origin point here and the reason for that is when we scale it inside of unity it'll do this so this okay nice wraparound but hey let me let me complete this so that you you you can you can pick up what I'm putting down I'm gonna add a new object I'm gonna add a cube I'm gonna go in edit mode here I'm gonna gy1 lined up that way um go to wireframe mode I want to scale you along the X say like this then I'm gonna grab the top bits over here and scale them on the X this way actually I guess I'd want to merge these so if I deselect everything if I grab you there's a hotkey for two but just mesh merge at center measured at Center there we go so now we're gonna have a little 3d arrow ready to go in here so let's save this come down here 3d arrow save okay dun-dun-dun that's gonna get imported so the idea is gonna be if we drag this in obviously it's huge but we knew that what I want to do is I want to create an empty and put it inside of here always and I've talked about this before you never want your model to be like sort of on its own because what you want to be able to do is make changes to this model that won't get broken like for scaling in particular here for example my game object I want to wrap this I want to scale down this arrow like 1.1.1 probably smaller than that it's not too bad but see my base game object here so with our 3d arrow or something like that let me just reset this over here that's not actually what I want to do this thing is still at a scale of 1 which just keeps things cleaner so it's sort of like wrap things in a game object like that it'll be a lot neater plus if you want to add any code to this do it on the empty game object as opposed to the model because if you decide to like let's say we draw a completely new model right in in blender then we want to be able to like delete this dragon the new model instead but then all of our code all of our components will fill it existed on the base object here and be untouched what I'll probably do as well is rotate this a hundred Oh rotate not position shut up you guys saw nothing so that it sort of by default points in the way I want the other thing that's night make sure your model is at zero zero zero inside of the game object over there so the idea is when you're putting this thing is going to come up and then when you are powering up I'm probably gonna scale this thing nope not this thing this thing up in the Y will do some sort of positioning tricks or something like that to show intensity maybe no maybe I was going to talk about doing scaling trips with this to show intensity but I think they look kind of dumb and not what we want I think we'll have the power meter instead although you could also do you could as an alternative to your control instead of being like spacebar to activate the power meter you could do a thing where you are clicking and dragging they like arrow right for the direction click on the ball drag out release and then the ball sends out that way there's no reason you couldn't do your input that way as well also that would work fairly well on mobile or would it though I mean it would be work well on mobile if your view was here for the problem is if you're zoomed out to see the whole course the click and drag with that the awkward or not I don't know where's I mom oh wow you could have this like like arrows you know rotate right rotate left rotate right rotate left okay hit it and hit it at that power I think that input would be a little easier on mobile place the ball is a small dog near there wait what texturing the arrows of power meter thank you cool you can have it glow you can have to do all kinds of different things you might want like a little a little animation for the arrow like it sort of just woop woop as it's waiting you know just cut your attention there's all sorts of different ways you could you could do that but we want this thing to be demonstrating a sort of direction and this is the other incentive to having things sort of locked in and one another what we can do here ideally I would like to be able to rotate this object but instead of having a rotate on its center what I would like it to do is I would like it to rotate sort of orbit around the ball so here's what I'm going to do just for now I'm gonna take the 3d arrow I'm gonna put it inside the ball and just set the arrows position to zero zero zero that way the origin of this 3d arrow game object is centered here I'm just gonna again pop it out of the end of the hierarchy again then I'm gonna take my model and I'm gonna offset the model over to something like this then if I go back to my game object and I rotate ah right that's alright to show direction I like it so we're gonna go back to the stroke manager at this point so the stroke manager is going to want to know about this arrow because it's gonna be responsible like we're gonna have in here we're gonna have a float for stroke angle and then we're gonna have a public game object for stroke angle indicator something like that boom and put it in there now I guess one of the things at this point is the that's a good question do we want the stroke manager to actually be responsible for rotating this thing I think no I think what we're gonna do is on the 3d arrow which I'm gonna rename to stroke angle indicator because that seems pretty smart I'm gonna add a component to it called stroke angle indicator and what we're gonna have is we're on this we're gonna have a public function called set stroke angle and it's gonna take in a float with an angle and that is that and so over here in the stroke manager instead of a generic game object we're gonna know it's gonna be a stroke angle indicator over here we can do something like stroke angle indicator is equal to game object dot find object of type oops find object of type so it's gonna find an object actually it's gonna find a component of this it's gonna return the first one it finds if for some reason we had one more than one of these in the scene it would return the first one I don't know why we'd have more than one in the scene we'll do that we'll save this and on update so in here we are going to have some sort of if true or something like that update angle angle equals oops what's called a stroke angle which shouldn't be capitalized because it's private there you go lower case stroke angle will be set to something I'm just going to force it to 45 degrees just to say and then what we're gonna do is our stroke angle indicator we are gonna call set stroke angle and pass it so we just need to let this thing know hey the angle has changed the alternative is the stroke manager the stroke angle could be public and the stroke angle indicator could just check it every frame to see what the angle is actually that's probably cleaner you know I like this f this F that do this have this be public yet and a protected set yeah I like that semicolon there no there you go so stroke angle can now be accessed from outside of stroke manager but can't be changed I like that done tell you what if input dot um yet access actually not even get access what we're gonna do is input dot get axis horizontal looking forward to new input manager that's going to be added into unity here soon they've been previewing it no probably like some sort of multiplier times time to built the time there we go so by default the horizontal axis is the left and right arrow key I believe a and D as well or if you have a joystick um you can do that and actually we can have input got yet button fire I think is a default button that exists which is mapped a space bar but we can do that and the nice thing is that we're all set up to use the controller instead okay dun-dun-dun so the stroke angle indicator so we're gonna be doing it differently it's gonna know about stroke manager so it's gonna be responsible for finding oops okay game object it's gonna be responsible finding the manager and rather than having a public stroke angle what it's going to do is every round it's going to set itself this not transform dot rotation is going to be equal to a return ian dot toiler zero yeah y-axis where it's getting this part stroke manager dot stroke angle zero so every every frame it's just gonna rotate itself to match this the other thing it's probably going to want to do is track like the player ball so in the same way we've got our our this sort of find player ball actually maybe we can do is make this visible as well I don't know I'm not sure what we how we want to manage it but transform player ball transform transform so find the thing called player save that this like fix me this is prone to all kinds of things and weirdness and if a ball V spawns and all the sudden transform and become a null for whatever reason but it's gonna be okay what we're gonna do is we're gonna set this dot transform that position is gonna be set to the player ball transform job position so we're gonna stay we're gonna be lined up with the player ball at all times and then rotated based on the stroke angle so I can take the the stroke angle indicator and put it anywhere so if I put it over here and hit play there you go it's gonna go and set itself there but apparently I don't have an input for fire okay they may have changed some of the defaults they haven't changed the the new input manager yet oh it's called fire one which is left control always jump map the space yeah okay well that's um delete and we can mostly just clean this out literally three axes actually really only need two we just need horizontal and fire so we'll just call this fire and space excellent I hit left and right oh it's way too slow Oh hold on I don't have the yeah oh when I clicked it um the focus wasn't set in the right place fire I don't want to fire on the mouse button anymore okay oh yeah no the rotations way too slow oh I'm setting the rotation to this no not here yeah I'm setting the rotation to the input as opposed to modifying the rotation or modifying the angle by the input that it needs a little bit plus there hey there we go that's too slow so we're just going to I don't buy a hundred it's probably gonna be too fast but let's see oh that's not bad actually I like it now the input has a little bit of gravity to it so even after I let go it takes a second well not a literal second but it takes a moment for it to come to a halt and that's because of the gravity and sensitivity um because this is basically simulating a joystick and the idea being if you let go of the button it takes a second to go back in a thousand is pretty strong though isn't it I would've thought that would've been that we felt like instant Oh hmm not the fire axis its horizontal there is go I was gonna say the horizontal axis had a really low sensitivity and gravity like even like a hundred is probably all you need but I mean I just reset those go thousand a thousand it's gonna be basically instant where the second you let go it's gonna drop down to zero again there you go although there was something kind of nice and organic by the other way one of the things you could do is while you probably want gravity maxed out you might want to keep the sensitivity in fact quite low so there's a bit of a ramp up so that if you just if you just tap it'll move just barely because it will take a moment to come up to its full strength there you go see how it like ramps up so you can do very fine-tuned control or hold it for just getting around faster that might be good the other thing you can do is maybe modify our keys so if you hold like shift then it'll move very slowly for fine-tuning something like that yeah I guess you could use get access raw but I like getting access and then being able to tune some of that a little bit here but yeah get access raw will ignore the gravity and sympathy and you're absolutely right there but I don't know there might be some value from this I don't know I don't know you know anyway okay so now in our stroke manager we have an angle which means when we whack it over here we can rotate this vector x quaternion dot Euler zero stroke angle zero oh wait you always put the returning first so now if I just hit space okay you go straight if I go and do this you go that way that feels like really strong I mean obviously we still need our meter but like I think it's telling us that like 10 is like way stronger then we're gonna want for our max I think for a mini putt 5 5 still pretty goddamn fast we also don't have much of a bounce going on here unless I'm doing something wrong and it's not a pliant we don't need a time.deltatime in here there you go let's say like that the one still feels that feels pretty good obviously we need to do something about this lack of bounce and potentially some friction and things like that so we have angular drag I don't think we need well we might want some actual drag yeah copy this in here first of all let's see how that feels so that will dramatically change how much force it feels we need to do stuff okay we're not really seeing the slowdown but in theory it's happening some the big thing and ignore the mass the masses is just fuzzy it's it's mostly relative mass for things so there's no there's no necessarily accuracy of anything in there why not time to all the time because it's just a fix when we hit it we're hitting it there's a fixed force being added to it as a single impulse it's a one time boom we're applying X amount of force there's no time there's no logic to timed out the time here the motion of this like if we were running the update to actually change the position based on the velocity then we'd do that but the velocity is being handled inside of the physics engine anyway I think that's okay but yeah this lack of bounce is the poop so what do we want to do about that well for that we want a physics material so in the collider itself there's a slot for a physics material here by default nothing has anything in there and instead what there is in a project setting if the physics material on a Collider isn't set its instead going to use the defaults as its material from this window which is currently blank but it still has values if we go over here we can create a physics material down here so I believe these defaults point six point six zero bounciness I believe this is exactly what you get if you know if everything is empty so what we really need to do is just add in some bounciness now technically we only have to add it to the bat ball itself but we could replace the default physics material as well you know if everything wants to interact that way I think what I'll do is I'll just call this ball phys Mac I'll just add this to the ball itself and the big thing is we need to go and add in some amount of bounciness how much I don't know let's find out and yeah the actual bounce in the end is going to be an average between the bounciness of the two objects involved in the collision so if our bounciness is 0.5 and we're clouding colliding at something with a zero bounciness then it'll be 0.25 which is fine because we could just we could just keep tuning this number I guess one is the maximum to end up with something but in a sense the walls are bouncy the balls are not perfectly absorbent things in a sense everything in the system has the same amount of bounce so I think in practice what we're gonna do just because it'll simplify some of the comparison math is I'm just gonna set this to the I'll just have default phys mat here and I'm just gonna add that in we could if we if for some reason we get in a situation where we have some objects that are supposed to bounce one way versus another like if there's debris or something like that then we might end up splitting this down but for now we can do that and then we don't have to worry about remembering to you know if it's been added or whatever we'll just do this and we'll just add some bounce to the world so let's say point 5 so everything has point 5 bounciness hit play I should have aimed at a wall but okay that's not bad you're still moving surprisingly much I think what we need it's not so much the we don't really need that much drag so drag is basically like air resistances and slow down the ball that's not really where most of its gonna come from it's probably we need a little less angular drag because it needs to like stop rolling as much let's said it's something crazy like 0.5 just to dramatically increase the amount why don't you stop dead on the wall okay oops grasses Fairley should be fairly slow e let's go ahead and give it some more just actual drag and see what happens um I mean we could also just increase the friction between them I don't think that's what we need to worry about I'm just surprised how much drag it's actually needing to sort of feel right but I think it's because the default mass and scale it's assuming that this is sort of denser and just generally heavier than it is and not as affected by stuff actually I think I realize what it doesn't feel right because the ground our ground here is flat whereas an actuality this would be rolling on a very uneven surface right which I think would SAP effectively low speeds it would effectively add quite a bit of drag to it I think like that's why I feel like we're putting in an unrealistic amount of drag here in terms of like if this was rolling on a flat surface that behavior that we're seeing is mostly right but it because we're not we have to artificially add in a lot more drag yeah that feels better although it really it feels like when it gets we may want to have it stop sooner I think that might be it rather than rolling at very low speeds because of the bumpy surface what actually happens when the ball gets quite slow it almost can't like make uphill because what it is the bumpy surface is like a series of hills when you're going fast you just sort of skipping across the top that's fine when you're going really slow you sort of dip into a valley and then can't quite make it up he'll I think more than adding drag we mostly just want the ball to stop when it reaches a certain minimum speed and just like hit the brakes at that point I think that behavior would end up feel correctly and more correct and also what I'm going to do is I'm gonna bring down the angular drag again to its original default I'm just gonna use just straight-out drag I think yeah go that's feeling okay I think overall that feels much better um but yeah we might go and add in we've got a ball script over here that we're just using it as an example for something but I think with the rigidbody remember there is sleep speeds and things you can set sleep threshold that's normalize energy threshold below which objects start going to sleep I think what we want to do is we want to increase that the questions I don't know what it is to start off with so I know debug log show me the threshold I'm search for friction coefficients for grass okay point 0:05 and I can't set that over here can I know so 0.005 is what's already there so let's set this be 0.05 so theoretically it much lower threshold of speed for it to stop we actually might want to lowered even more than that we might want to go quite it definitely stopped a little sooner if I did something like this would just feel like all of a sudden it stopped like inappropriately all right that that I think is okay it's interesting that it's bouncing in very different ways each time yeah it really it really is because it ended up here this time now why is it ending up over here Oh Durer hmm yeah sorry it's in the fixed update because originally I was gonna manually check it but you're right it doesn't have to be reset all the time I don't think it was doing anything bad yeah I felt kind of okay why are you changing your collision angle all the time I think it has something to do with the friction um as things collide yeah I guess because it's spinning that might be part of it yeah yeah a little bit of the English because of the spin which is probably okay but yeah I think a lot of it probably has to do with the the friction too and the and the drag so when we were doing the pinball game for example I think effectively the drag was basically nothing I think like the actual drag was effectively nothing I think there was some anger or drag in there that was being used and at between the two of them you can lead to some kind of slum what bizarre interactions and sometimes things can feel like too much English or not enough English now we'll do that we can like micro that for like a million years but that's not what we're here for okay we had about 20 minutes left and I think that's gonna work out nicely for us to make a little power meter I change density therefore more drag we're using the drag to fake the uneven ground which is neither friction nor drag and at the and the amount of slowdown you get from going over the uneven ground is very changes dramatically on a curve based on the speed of the ball - but anyway all right so we got that and if I do this we can actually shoot that way we need more bounce we need to be quite bouncy in fact the whole thing where it sticks there we go that's much cleaner oh the other thing and I think this is in the physics system that's right there's something else in here there is a bounce threshold we want to bring the bounce threshold all the way down that's why when you end up with that sticking it's because it's not it wasn't high enough of a hit for it to trigger the bounce threshold so the bounce was just ignored so it just ends up just sticking to the side which isn't what you want so we probably don't need it to be as bouncy as long as the threshold is basically zero there we go that's good he's stopping a little bit too soon now I mean it could be it's always gonna be a bike balance between how does the power feel versus what that seems kind of okay to me remember we're losing a lot of energy when we bounce as well so that's part of it we're gonna call that close enough let's work on the little power meter I think that's gonna be UI element I mean it could be literally anything but let's say so our stroke manager we're gonna have a stroke force okay so there's a stroke angle we're gonna have stroke force in here and now finally we're also gonna have a bit of a mode selection so we're gonna have we're gonna define an enum called stroke mode sure how do we do we specialize this I always get the syntax confused so basically there's two modes we're gonna be in one where the ball is is still and we're waiting for the player to whack it and mode two is the ball is moving around and so no player input should be available because right now I can keep whacking space and it'll just keep hitting the ball as we go I mean there could be a check for things so whether or not we actually need an enum versus a stat a state check or whatever there's lots of different ways you can think about it there may only be two modes Bailey may only be the the ready to whack and the we are currently rolling mode but there could be others I mean maybe there's end up a third mode for when the ball is using the cup or maybe there's gonna be another mode for multiplayer where what we're doing is waiting for another player something I don't know ready to whack versus ball is rolling I kind of want to be public which means I sort of want to be called like this and again because I want maybe other piece of code um I don't know if you want this internal or not or we might and I'll have some sort of function call to check the state I know let's assume we're just gonna make it like visible here but yeah because of scope I can't name these the same thing unless this is like stroke mode you know I'm a little awkward oops protected set is actually how I want to write that Oh public enum there we go I don't know if this is actually what we want but just in the interest of moving forward for now it's like you what ends up being the cleanest code that's you tend to refactor but we're gonna enter into the like the let'em door portion of like let's make sure we just keep this working so really what we want is probably in fixed update is where we're going to check well if ok if stroke mode is equal to ball is rolling nothing to do but wait for it to stop so what we'll do is the planned return here but I think it's gonna be some sort of check ball status or something or update update stroke mode right so if the ball is rolling we're in ideaa and so all we're doing here is is the ball still rolling so if player ball RB dot is sleeping then we can change the stroke mode so if the ball is sleeping i if is extensor it's not moving around we can say hey we're ready to whack at this point check ball status I'm gonna have to check ball status it make sure to check ball status you know I want to make sure to catch your uh-oh you know any any cancer as early as possible check that ball status this is a public service message there you go is ball sleeping that's basically it I feel like update stroke mode is maybe the wrong name but anyway some sort of thing like that is the ball still rolling if so do that otherwise nothing because basically after we whack it what we're gonna do is we're going to change the stroke mode to be ball is rolling in a sense I suppose what it could do is not do a check here and an update stroke mode is sleeping if so set this mode if it's not sleeping then set a different mode but I think this is gonna be okay and we're sort of building a state machine ish kind of thing here there's a bunch of different ways to do it but there we go so now we can't actually whack it a ball if if it's rolling because we're just going to return over here we can only whack at the ball when the ball is no longer rolling dun dun dun dun dun actually I'm gonna move this stuff over here okay or we could do is something actually maybe here this would be better if stroke mode not equals ready to whack then process the stroke mode over here there that's that's more sane because we only want to continue down here if the ball is whack of all these are technical golf terms shut up I'm an awesome golfer bah bah bah bah bah bah bah okay so that's one thing next thing yeah we're gonna do a little UI imitation well just as a test if I hit play I hit if I space Smarr nothing is happening okay perfect wonderful so let's make a user interface so UI what we're gonna do is we're gonna be making an image I mean they'll probably be more than that to it but for now let's just do an image so this is gonna be the stroke force and what we need is yeah right now it's just got a single plain rectangle which is okay we'll put it down on the on the bottom right corner we'll set the width to 20 sure that's fine we probably want to have something inside of it let me duplicate this put it inside this thing is actually going to be stretched to its parent but with a 2 by 2 by 2 by 2 pixel border so and this will change the background to black so it'll be a nice little border switch this to 2d mode there you go come I can actually see the black line over here it's clearly within the the frame I don't know but I might want to just give it a little padding here um - - so we might doing like minus 4 minus 4 or plus 4 there you go so it's got a little bit of spacing in here and then this stroke force here we are going to be giving it a what am I looking for here is it just part of image how do we get the slice oh I don't remember is it masking no oh you know what I need an actual sprite I think let's make a we can just create a sprite here right if I just create a square stroke force so now I have this if I actually add an actual graphic to this yeah there we go image type lovely so we want filled mode that's what I'm looking for in vertical mode yeah ah there you go so all we need to do to make this little stroke force graphic work is changed to fill amount so we're gonna add a component stroke force UI there you go open up so what its gonna do it's gonna work a little like the stroke angle indicator first of all where it's gonna grab a copy of the stroke manager and once per frame all it's gonna do so we need to use unity engine dot UI because we're gonna have to reference some uie phase because we have an image component on ourselves so image image so we're gonna get our image component over here and on every update what we're gonna do is we're gonna set image dot or that thing called fill them out fill amount to be equal to stroke manager as I say strike force or stroke force but not quite because this would be an absolute number what we need this is as a percentage so our stroke manager we ever this our current stroke force but what we kind of need is a max stroke force this as hard as we're allowed to hit a thing and what should this be well let's come over here so we're I know we're getting it a 1 if we were to hit it a 5 again because we've changed a lot of our of our numbers right so how would this compare they go along thank you so if I already hit play here my stuff did adjust the camera input button submit is not set up oh uh let me disable the standard input module there you go here were that whining I hit you that doesn't feel very different from it's 10:50 yeah where I'm trucking here is what is the hardest like the hardest possible stroke 50 seems like it might be a pretty did I double click this it do act twice Oh mmm yeah it did load up to do ax in here Oh which is probably changing it but that's why it was inconsistent yeah cuz it wasn't every frame and it's running very quickly right now every frame that I had held the spacebar down it was whacking it more than once so our numbers that were checking before are gonna be a bit different now so now I hold down space nothing happens by a release space it goes and only the one time okay that still feels like a pretty intense hit over there I think I'm kind of okay with that if I change the the default angle just do this leave it at zero boom it does lose a lot of energy on the bounces how do we feel about that I mean I think it would be a good idea I thought I set this to a higher number then that's at the bounciness up to like one at some point maybe I did it while the game was running okay I mean I think I want is a little much we're gonna do that let me cut down the force over here now that we've made a few tweaks let's set it to a 20 yeah there should be some loss there's problem there might not be enough that's some 75 on the bounciness and let me reset this to that okay five is definitely not enough 15 we may want the strongest stroke to be a little harder than the 15 but probably not much let's figure 20 okay so what we want to do here is this is actually going to change to stroke force and what we're gonna do is we're going to set the max stroke force to be equal to 20 just for the sake of argument we could we could expose that but I think what we're gonna do is we're gonna have a public float stroke force percentage which is gonna just have the get over here know set and all its gonna do is return stroke force divided by max stroke force OH return there we go so now our stroke force UI is just gonna ask for the stroke force percentage which is gonna be the float that theoretically caps at 1 unless we did something really weird so now if we do this when I set this to say 15 for a second here we should end up with a bar on the bottom right that's 3/4 filled okay so obviously what we're all really gonna want is this is gonna start at a zero which I mean it'll do by default if I don't feel anything and same thing with the stroke angle let's zero that out that's going to be okay and so now the difference is when we hit the space bar here it's not gonna set do whack it's instead going to start the power meter filling up or going down buh-buh-buh-buh-buh ya lap that it doesn't work to highlight a message if you you know want it to be more visible in general but yeah people have been putting it to pretty good use which is nice so we're gonna want a stroke force fill speed how long should it take to go from the bottom to the top a second two seconds let's set it to 10 F and then we'll want a int fill deer which is gonna be a one for now two seconds yeah maybe we'll see well we'll try it and see how it feels this could be something we expose in the the options as well to tweak although I guess that the fill speed is too slow it makes it easier to get accurate amounts anyway boom I'll do fill although this could be a mode right actually so can do whack so right so not sure I have stroke filling actually I guess our moats could be like aiming feeling do whack ball is rolling yes I like that if stroke mode is equal to aiming then we are processing the changes to stroke angle also if we ran aiming mode and we hit the fire button what's gonna happen is we're gonna switch to stroke mode is equal to filling so if we hit the fire the first time the meter start to fill if stroke mode is equal to filling then the stroke for stroke force plus equals stroke force fill speed times time Delta time so it's frame rate independent if stroke force is greater than max stroke force then we are going to set the stroke force to be equal to max stroke force and set the this times fill direction and set the fill direction to be minus one so if we've overshot our max we make sure we don't overshoot the max and then we start going backwards else if I mean we don't really need the amount sure why not else if stroke force is less than zero then we set stroke force to be equal to zero and set the fill direction to be positive again and then finally we check again on the fire button and if it's hit we switch over to do whack instead so we're either aiming filling or it's time to do whack so here yeah let me I'm gonna get rid of this update stroke mode if it's not equal to do whack then we'll return [Music] change my mind again I just want this back here it's not equal to do whack we return I'm going to do a different one if stroke mode is equal to stroke mode dot ball is rolling then I'm going to rename this to check rolling status ban and return I mean it's like it's slightly redundant in a way I mean we could nest it because it's sort of that but I think this is fine so if the ball is rolling we're gonna check the rolling status see if it stops and reset it and then return in any case we don't want to continue down this unless we're in the new wack mode and then we'll do the do wack logic now do wack shouldn't exist as a boolean anymore I got rid of you here we do that so we don't need a test over here at all because if we get to this point it's time to whack it a ball right if we get to do if we if we're not in phase do a query return if we get here we whack at the ball and then we take the shot and then we set the stroke mode to a ball is rolling and then we go back into waiting status yeah we couldn't do a switch but I mean technically be two switches but then you'd be nesting it I guess you could call a function right if it's the status I would personally rather than enums which I'm using here for slightly more simplicity as well as the ability to you know maybe maybe check the status over here like we could expose the the stroke mode so that you I the you I can do things the camera might want to do slightly different things depending on the stroke mode we might want to enable the Arius graphical things I don't know like we might want to expose this but I'd be really tempted to use like delegates to implement the state machine so that our update gets chosen but I mean that's fairly ok there you go so um it says your oh you know what I'm thinking we're gonna do just for visual thing cuz we'll have to remember to reset the the stroke force to zero which I guess can happen here reset it to zero anyway there's nothing weird graphically going on filling isn't gonna work like you think okay could be so aiming mode is engaged its spacebar we're still in a mode oh oh yeah so it sets the filling and then immediately goes here and this is still true because it's the same frame I think I'm gonna want to put a return here so there's at least a 1 frame delay there's other things we could get we could reset the get button up but yeah it's it's detecting us firing setting it here and then immediately running here I say we put in else as well might be a little cleaner than the visual return although I don't tend to like nesting things too much because either way we need like a 1 frame delay and an else or the return works for it let's just do this also reset the stroke direction thank you hit this there you go that's failing shrinking growing whack it okay oh yeah we did set I set the the max stroke maybe I will sit and keep it at 15 so let's see can I get a hole-in-one well it should actually skip over the hole really half force we'd probably want to hide the arrow while we're in this mode as well okay that's not too shabby though why did you just bounce I think we may need um with the force meter I'm wondering do we want something like a little bit more awkward I'm wondering if because of the bounce if it's bouncing off the edge of this that is a trigger but yet because the physics material it may be hitting little edge of this and doing a bounce off it yeah what I probably want to do is leave the bounce on the walls quite high um but bring down the bounce everywhere else and I think what we may do is duplicate duplicate the default physics are going to be non bouncy ball fizz Matt will be bouncy and the wall fizz Matt will also be bouncy we may actually want to use like the min or something but we'll see mostly though it is the kick-out hole over here which is a mesh Collider on it needs to have hmm actually how do I want to do this you know instead of having I'm gonna keep the default physics to be bouncing and chain and just make a no bounce fizz mat do the things that we don't want it have to be bouncy for example the floor itself we actually don't want it to be bouncy I mean because of the astroturf on here it would absorb all the bounce anyway so we're gonna do that and then you have the kick-out hole I will also set it to be no bounce on it yeah a logarithmic stroke might work really well that's that's what I'm thinking oops [Music] now the bounce combined I think it's the active object that uses its bounce combined so we sort of want this to be set to minimum perhaps or maybe multiply so the minimum of material will get used but still bounced a little bit on the surface all right why would you do that the plane is set to the no bounce material the ball Oh needs its physical material there you go it's still bouncing on the tabletop do they all have to be set to min oh I think I was doing it while the game was running so it didn't save the bounciness change why are you not on the ground and the arrow shouldn't have a collider but let me check on that I mean and it wouldn't matter anyway like it doesn't have a collider although it probably is a good idea to like make it less thick because it does look pretty stupid I think it may have to do with that may have to shrink down a bunch cuz it was a one centimeter contact offset at point yeah point oh one it had one centimeter contact offset it wasn't a precise enough there so that mean that's one thing hold on did play there we go and correctly doesn't bounce off the ground that wasn't the bounce what was going on there wasn't a bounce it was a jitter because our collision offset was too large there's a minimum distance at which it will try to resolve certain collisions just for optimization and to avoid like weird jitter effects but because we're operating on such a small scale we need to adjust that so now if I hit this hey yeah that's why I couldn't go in the hole properly and everything like that it was entirely because of this value here the contact offset which I should have actually taken a quick little look at earlier to make sure everything was okay now we've got that how's our wall bouncing did we break that aspect of things No there you go the walls are quite bouncy I mean arguably maybe too bouncy or not but that's you know that's like infinite tweaking you can do I know the feels all right kind of feels okay we are now 15 minutes over where I'd sort of plan to be because we're gonna switch to the gaming shortly we can very quickly consider other UI things like int public int stroke count get protected set a stroke count wouldn't start at zero right like because this is if you were to sink the ball now that's what you would mark down on your on your score sheet alright so when you start a hold of stroke count you start at 1 and if you go into like the UI system canvas so what you do is switch to 2d mode again so I can see things properly add in UI text probably text messages for um you know what no I'm not gonna import anything no stop I'll keep it I'll keep it delete go away I'll keep keep the project a little simpler we'll just use the regular text thing even though it's not it's pretty you know you can do something like stick it in the on the top left corner oh I'm putting in the wrong box canvas top left corner there we go and then give you a little padding stroke huh replace Holderness and then do something like stroke couch UI there you go and just like the stroke force you I just copy-paste except stroke count you I not gonna get an image I'm gonna do that plus stroke manager dot stroke count there you go and then so every time you whack it a ball plucks one it really just plus one when it comes to a halt yeah it's almost here stroke count plus plus you know unless unless we scored so to check the scoring you would add a Collider a trigger I should say well I mean a trigger is just a Collider that isn't a Collider hard to describe inside the hole over here so like I have a Collider on top of the hole this is used to toggle the ball from you know for its collision status but what we sort of want is we might generate a second version of the collider here we'll remove the change ball layer component this is you know scoring Collider it's set to is trigger and what we want to do is want to move it to the bottom I mean it could shrink it as well we could make it very very small but we want to basically be if the ball has gotten to this bit then we can we can count that as a score so we'd have some sort of scoring Collider there we go and we'd have a void on trigger enter like that debug log score well it's not score it's like whole complete so I mean we didn't do the camera work but that's not I mean you know a little follow cameras fairly simple I think we can probably more or less leave it here but you know I think the max power does have to be brought down because that was like what 1/4 1/3 and still goes across the whole thing I think we'd like a little bit more fine control Wow yeah we need to we need to dramatically drop the max power I think 5 the effective feel the power is also going to pend a lot depending on how much things bounce oh I probably have to change the speed at which it accumulates all right let's go to 10 but yeah bring down the the fill speed good jorb and just tap it in okay I was a little aggressive but it still got in and it did trigger the whole complete event so at this point what you do is you know score you know yeah you could you got it in in two strokes kind of thing oh it was a stroke counter updating it should be right yeah there you go well I guess it'll update when it stops there you go stroke two and then loading a level now loading a level levels you can think of them in two ways you can think of it as losing a scene but I don't think we'd want a separate scene for each level I think instead what you have is some sort of we'll call it level manager even though you know in golf parlance you would say hole manager or something but I think it's a little bit more straightforward here and then we'd probably have some sort of thing like a public game object array of levels and then you would have game object cur level like this so our level that's just that in that and presumably has a prefab assigned to it yet okay so yeah our level manager is just gonna have in this levels array oops didn't it should just go technically this should be a prefab this level is a level model we might want it to be a level prefab anyway we can delete this boom you know something like this and then like avoid despawn level is do something like destroy its destroy cur level like that so you're like level complete code is gonna be something like despawn the current level and then spawn the next one like that increase the number something of that nature boom boo-boom boo-boom okay so you just need to like you know call at some point level complete and it'll load in the next one so you just set up all your your levels as some sort of prefab I mean here it's a model but it can work so I mean theoretically the better way to do it is to drop this in to an empty like that let's make sure to Center you up inside and call this like level zero one underscore prefab just because you might you might want to do other unity things to this drop that in there and in practice oh yeah let's see it like the whole back up this whole prefab needs to be inside of this so there's the whole model and then the or sorry there's the level prefab and then there's the whole prefab as well let me reset the position in here just to make sure this is looking okay undo undo undo undo prefab out reset this positioning there you go then put the whole prefab inside of this there we are and yeah the other thing it didn't keep it didn't keep its colors and things either for the level so the plane over here wants our grass texture on the plane excellent so yeah this becomes level zero one prefab delete that one put it in here and their level manager will actually be loading from that prefab instead so if I get rid of the prefab that's in the level and over here do something like us on level on start and hit play hopefully the ball doesn't have times like fall through the world there you go some crap out there oh it's the arrow that I'm seeing okay hit play it'll spawn in the first level there you go and we are back to being able to play the game and yeah in theory you get in the hole trigger some sort of you scored a point oh there is the other thing with the prefab is the oh man all the materials the colliders yeah it's actually good that boom mesh Collider the flat plane wants to have the no bounce physics material on it and the walls do need a mesh Collider but they're fine with the default that's gonna be okay oops apply all delete there we go all right yeah the what ball went past the wall because the the colliders weren't actually installed hit it too hard but almost on the bounce back almost on the bounce back yeah hole complete and then yeah you would just trigger fireworks and things done I'm easier start the strokes is your only increment after you fly yeah maybe yeah it's weird because I'm just thinking from display point of view right you're thinking this is my first stroke like you're teeing up and you're looking display just a stroke one I mean unless does it's a zero at you would you think you wanted to say zero and then you as soon as you hit it it goes up to one maybe yeah I guess maybe which I mean takes two seconds to change I supposed to yeah how how do we want the DUI to sort of set so I mean reset this to zero make sure that's okay and then the right stroke count over here whacking it stroke count plus plus yeah that's probably gonna end up being better good free camera system maybe a unity that's true actually so import I used to get it from this thing but yeah I mean doing follow code for camera is pretty easy I just don't know what the correct one would be and what probably we'd want to end up doing custom camera code because it's not just a question of following well I mean once you once you whack the ball you probably want the camera to sort of you know follow the action but when you're in like the setup phase where do you want the camera to be you want to be able to move it around you know um should it just be from your point of view like sure the camera almost act like this and then you can sort of a look a little and plan or should it be top down should be toggleable so that that's a whole other like sort of discussion on usability in various decisions like that like like the idea that's like sort of vaguely first-person this kind of thing but it's not as handy for planning especially if there's a bunch of stuff like what if there's like a big windmill in the way so you can't actually see the whole but you want to be able to see the layout maybe there should be a button something I don't know at least be behind the ball over the camera yeah it could be I mean that that looks kind of you know could look kind of sexy over here right the camera set up this way oops wrong context the other thing that might be nice is you could put a little have a little flag in the hole with no collision right so make it a little easier to see I think that would be a good a good idea just just me know model up a little flag put it in the hole but put no collision on the flag itself or you could make it so that when your ball gets close to hold of the flag gets removed or something which is how you do it in Gulf I mean you'd still wouldn't put a collision on the flag because it doesn't need to exist doesn't need to tie up the the physics system or anything but yeah if I can hold exactly yeah I mean in this mode especially you don't need it at all if you're playing top-down you don't need a flag because do we all have a flag because you can see the hole really easily right in top-down isometric mode pretty decent and yes the arrow should definitely be hidden when the ball is in a rolling state and that would be easy to do but we're gonna leave it here because the core of the game is here I mean really at this point I mean a couple of cosmetic niceties and and just finish the the logic for when the game ends right because instead of just going into our ear you know to do I mean literally just find the stroke the the level manager game object dot find by type level manager go to the complete level complete I mean to do maybe wait until you congrats the player I mean they're you now all of a sudden multiple levels of work I mean here would just redo that the one thing we didn't do is on level load in our level prefab there should be a spot to set the ball so in inside of here either we can actually have the ball already plays at present or maybe what we do is you have something like ball spawn spot and so you just put this where the ball should start so right over there for example and yeah then the ball will spawn in that area and have that be part of the prefab and then reset the ball position level manager to do reset ball position if you do that all of a sudden you can have a hundred levels and a fully functional game and then yeah you you sugar it up with how do you want to keep score and do things like that you know do you want to have a par for each hole that's a whole other little bit of info that you could have although there's no reason you couldn't do that you could have in your level prefab you could have something like level stats level level data all right we have a little script on our level prefab called level data and all it really is like it may not do anything level I mean maybe it's you know you can have some various code to you know activate your spinning windmill or whatever but what you're what you're mostly doing here is something like public int par you know par 3 and just expose that and then when you complete the level you can update the scorecard to do whatever oh but yeah this project is is all that all the broad strokes are ready to go now I'm tempted to do a mini putt game for for let them dare wonder if there's gonna be a theme that would be vaguely compatible we're not going to add multiplayer today we could conceivably do it it wouldn't be that difficult and it could be a lot of fun you have the whole golf with friends kind of thing but we're gonna wrap up the program here this thing will be the video will be uploaded to the up tubs very shortly and the files here will be uploaded github in theory after the stream ends and all the broad-strokes a so many puns available for us but we're gonna wrap it up here and we're gonna go and play some computer games now we only have an hour and a half left to stream you guys have to give me some feedback do you want to do we want to go and do some some ckq do we want to jump right into multiplayer do we want to do something else I'll see ya but just see cute to follow theme Vinnie golf ball UH one of the things you know what I've been playing what I've actually did load up fallout but hearts of iron for playing with the old world blues mod show you in the list all the world blues is a complete mod for hearts of iron that makes it the Fallout universe it's insanely good it's insanely good and there's gonna be a video or let's play for it this might be the thing that that we do after we finish our stellaris run I don't know but it's it's really quite a nice mod
Info
Channel: quill18creates
Views: 21,165
Rating: undefined out of 5
Keywords: Unity (game Engine), Game Engine (Software Genre), programming, tutorial, fps, howto, how to, beginner, guide, unity, unity 3d, unity 4, physics, blender, 2d, 3d, quill18, quill, multiplayer
Id: fvlakpubZQk
Channel Id: undefined
Length: 150min 8sec (9008 seconds)
Published: Sun Sep 22 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.