Fish

The Fish Master The Fish Master
22 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€64.98
List Price:  €92.84
You save:  €27.85
£55.64
List Price:  £79.48
You save:  £23.84
CA$95.72
List Price:  CA$136.74
You save:  CA$41.02
A$105.61
List Price:  A$150.88
You save:  A$45.27
S$94.51
List Price:  S$135.02
You save:  S$40.51
HK$546.96
List Price:  HK$781.40
You save:  HK$234.44
CHF 63.39
List Price:  CHF 90.57
You save:  CHF 27.17
NOK kr759.29
List Price:  NOK kr1,084.75
You save:  NOK kr325.45
DKK kr484.72
List Price:  DKK kr692.49
You save:  DKK kr207.76
NZ$116.27
List Price:  NZ$166.11
You save:  NZ$49.83
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,668.91
List Price:  ৳10,956.06
You save:  ৳3,287.14
₹5,843.17
List Price:  ₹8,347.75
You save:  ₹2,504.57
RM331.68
List Price:  RM473.85
You save:  RM142.17
₦86,437.65
List Price:  ₦123,487.65
You save:  ₦37,050
₨19,439.77
List Price:  ₨27,772.29
You save:  ₨8,332.52
฿2,571.29
List Price:  ฿3,673.43
You save:  ฿1,102.14
₺2,259.44
List Price:  ₺3,227.91
You save:  ₺968.47
B$355.04
List Price:  B$507.22
You save:  B$152.18
R1,290.39
List Price:  R1,843.50
You save:  R553.10
Лв127.12
List Price:  Лв181.60
You save:  Лв54.48
₩94,866.43
List Price:  ₩135,529.28
You save:  ₩40,662.85
₪261.89
List Price:  ₪374.14
You save:  ₪112.25
₱3,999.98
List Price:  ₱5,714.50
You save:  ₱1,714.52
¥10,762.93
List Price:  ¥15,376.28
You save:  ¥4,613.34
MX$1,185.03
List Price:  MX$1,692.97
You save:  MX$507.94
QR254.87
List Price:  QR364.12
You save:  QR109.24
P951.97
List Price:  P1,360.02
You save:  P408.04
KSh9,396.15
List Price:  KSh13,423.65
You save:  KSh4,027.50
E£3,355.96
List Price:  E£4,794.44
You save:  E£1,438.47
ብር4,011.08
List Price:  ብር5,730.37
You save:  ብር1,719.28
Kz58,466.37
List Price:  Kz83,526.97
You save:  Kz25,060.59
CLP$65,872.48
List Price:  CLP$94,107.58
You save:  CLP$28,235.10
CN¥495.49
List Price:  CN¥707.87
You save:  CN¥212.38
RD$4,060.47
List Price:  RD$5,800.92
You save:  RD$1,740.45
DA9,414.39
List Price:  DA13,449.71
You save:  DA4,035.31
FJ$157.07
List Price:  FJ$224.39
You save:  FJ$67.32
Q543.15
List Price:  Q775.96
You save:  Q232.81
GY$14,618.48
List Price:  GY$20,884.44
You save:  GY$6,265.96
ISK kr9,767.80
List Price:  ISK kr13,954.60
You save:  ISK kr4,186.80
DH704.80
List Price:  DH1,006.90
You save:  DH302.10
L1,237.78
List Price:  L1,768.33
You save:  L530.55
ден4,001.09
List Price:  ден5,716.08
You save:  ден1,714.99
MOP$562.43
List Price:  MOP$803.50
You save:  MOP$241.07
N$1,293.49
List Price:  N$1,847.92
You save:  N$554.43
C$2,572.34
List Price:  C$3,674.94
You save:  C$1,102.59
रु9,329.91
List Price:  रु13,329.02
You save:  रु3,999.10
S/260.85
List Price:  S/372.66
You save:  S/111.80
K270.11
List Price:  K385.89
You save:  K115.77
SAR262.50
List Price:  SAR375.01
You save:  SAR112.51
ZK1,884.87
List Price:  ZK2,692.78
You save:  ZK807.91
L323.24
List Price:  L461.79
You save:  L138.55
Kč1,626.08
List Price:  Kč2,323.07
You save:  Kč696.99
Ft25,316.43
List Price:  Ft36,167.88
You save:  Ft10,851.45
SEK kr757.73
List Price:  SEK kr1,082.52
You save:  SEK kr324.79
ARS$61,503.14
List Price:  ARS$87,865.40
You save:  ARS$26,362.25
Bs483.90
List Price:  Bs691.31
You save:  Bs207.41
COP$271,944.94
List Price:  COP$388,509.43
You save:  COP$116,564.48
₡35,713.67
List Price:  ₡51,021.71
You save:  ₡15,308.04
L1,726.17
List Price:  L2,466.06
You save:  L739.89
₲523,116.65
List Price:  ₲747,341.53
You save:  ₲224,224.88
$U2,673.86
List Price:  $U3,819.97
You save:  $U1,146.10
zł281
List Price:  zł401.45
You save:  zł120.44
Already have an account? Log In

Transcript

Welcome back guys Amar here and today we are continuing with our the fish master. Right now we have our hook and what do we have to hook? Well fishes and we don't have one. I mean we don't have patience at all. So let's get started by creating some fishes. To do so go to hierarchy right click on it quick create an empty game object reset its position and call this fish like this.

Inside the fish game object we're going to have another empty game object which is going to be our grad fix. Almost spelled correctly that almost so grad x like this. Inside we will have our sprite renderer. We will have one of our fishes ready crap for example. But our man what happened crab But it's kind of too big. So we're going to scale it down a bit.

Point one or 0.1 10.1, I guess. So this is going to be our fish our crap. First thing we're going to add, I mean, the first thing that we are going to add is our Collider. 2d and circle Collider. Keep that in mind. It's circle Collider.

Make sure you put it to be a trigger. Offset, I mean radius will be 0.2. And as you can see, but you cannot see I mean, you can but I'm going to move it so you can see better. So this is where our fish that so where our fish is. So no matter where do I change, it is always going to be the same. So it is right, right where it's supposed to be.

Should I move it maybe a bit. So like negative 0.2 times, this is like gonna happen. So zero offset on the x. This is where we're gonna catch our fishes. Now we have to save the fish. But how do we do that?

Well basically, when you want to instantiate a game object or your game object, or in this example face, you have to prepare it, you have to store it somewhere. And to do that, we'll have our prefab. So right click on our project, Create Folder and call it pre fab. We're only going to have our prefab for our fish. So I'm going to put prefab and fish, no subfolder for Fishers and so on. So right now we have our fish.

And one thing is missing here, and it's our script. So go to script, create new folder, or subfolder fish scripts, scripts like this. And here we're going to add our C sharp script that we will call fish now When we add our script to our page like this in that hierarchy, let me show you. Come on, let me show you where we add it. You think it's there. But if I were to remove the fish and go back to prefab put it again, there is no script.

And why is that? Well, basically, every time you change the prefab from the hierarchy, you have to click Apply. So if I were to add component fish, I will have to click Apply, so it applies. And now when I delete the fish, and again, I will have the script on and I almost forgot to say what prepared is used for is used. I mean, as I said, it's a game object that stores value, right? Like right now we have our circle collider or fish script or graphics.

But if I were again to create a fish, I'll have to do that all over again. So you see I have that once again. Graphics Collider. script and so on. But when you prefab it like this, it's always there and it will be always stored as it is. So let's delete our fish from the game and open up our fish script.

First we're going to delete the comments as I usually do like this. And in this case, I'm going to start things off by having our series serialize that field but are what's called Siri Siri. Siri, man Why? Okay, something is missing here. Okay, I forgot adequate using the system to actually access the function that I'm searching for. And the function of searching for is Sera, Sera, Sera, likable serum serializable like this.

And what is that? Well, basically We're gonna have our survival public class, which is going to be public class which is going to be called fish bite like this. Let me explain. When you put something to be serializable it means it will be visible. When you put it in the, in the what's called is inspector. What do I mean by that?

Well basically, we are not going to have here like 15 fishes like in our pita then store them one by like fish one fish two fish three. I mean, you could ask but it's too much work. Actually what we're going to do, we're going to have our public int like price in price, then we're going to have our public float. Fish counts like this, then our public vote mean low minimum length, then public float maximum length. Right. And there we go.

We're going to have our public load. Go collider radius. And last but not least, public's right, which we're going to call bright. right ladies. So what do I mean by that? Think once again, well basically, every time I mean in the fish spawner that will come later on.

We're going to have this fish type. And let's say we want to have 10 fishes, we will have some food for every fish there that we have for 10 we have to put in down Sprott price discount, minimum maximum length, length, and to not do that in script we put it to be serializable. So we can actually see it when it comes into the, the hierarchy or inspector. We will see later on when we added in what word is I wanted it in this part, of course, so I'm going to actually cut this and put it to build Because it's not something that we will actually go back to that we need no. So let's start now having our private fish dot fish type calling type. Then we'll have our private circle collider 2d that will call call for Collider, then privates sprite sprite renderer rent so we can actually change the price of our fish.

Private screen screen left so we can have the bounce when we hit the I mean fish hits the left side or the right side it can go in circle looping through so it does not go it does not go out to the parent and then we're going to have our tweener. So using the De that we like this, and it will be our private winner, which is going to call Tweeter, I guess, same just lowercase t. Now in our awake function, which we'll use later on, so awake, first we will use our public to public fish that fish type line type. Here we're going to have our getter, and here we're going to have getter and setter for the type. So let's do that real quick. Get insert to get which is going to return so we'll turn this type come on with red turn. Can I do it?

Yep, I can type we're going to return the type and if we did not have it, since employments capital the type, we're gonna third type which is our fish type right here. If we have one if we do not then we're going to say type equals to value value commodity value comma y my y does not like keeper Listen to me then collider dot radius equals to type Come on equals to type the collider radius and our rents that sprite equals to type the sprite so this will basically we have we have our fish stock is type which actually which actually having the collider radius and sprite from our as you can see here when I click on the sprite from our fish type so we're getting we're getting collider radius and sprite from our fish died if we have one which is going to return it but if we did not have one We're going to set it by saying that type equals to value.

So we're setting it up then we're changing collider radius and we're in sprite renderer sprite and moving on in our awake we're going to say collider we put this bracket down we're going to say collider dot radius equals to type that collider radius like this. Then rent that sprite though I mean this rent the equals to and here it's not collider ama Robin Robin love it. I just I just repeated what I saw here my bed. What I was trying to say is collider equals to get component. We're getting our circle collider like this. Then we will have our rent render equal to get component and we're getting our sprite renderer so bright Right render like this.

And we are going to have our screen left equals to camera dot main that screen to world point, then we have here vector three dot zero, and then dot x like this. So this is this will be our cameraman, and this is this point here or here because it's left to zero to something I'm not know exactly the exact number but it will it will make our face go left or right now update function will not be here so we're going to change that to our reset page we said we said fish and we're going to call it public. So here you may see recess pitch meaning that it will reset but actually it will Given the reset, and it will put it in our game, so it will, it will organize our fishes to go I mean not to go but to be all around the place.

You will see. Now in recent fish, we're going to check if we have a winner. So the winner is not equal to No. If that is the case, then we're going to say winner dot kill equals false means we have something and we will not do it. Because of course it's false. He'll Boolean equal to false Yep, kills it we now that's off we're going to have our loads now.

So here is going to be a bit of math that you'll see nothing too much. So now equals to Unity engine or actually a random dot range. We can accuse it like this we have to Unity engine, that random dot range Then we are having from the Type, Type minimum length to our type to type the maximum length. So this is our minimum. Here we're seeing our collider dot enabled equals true. There we're setting our vector three, vector three position to be equal to transform.

So friends form that position for our fish, then we are changing the position dot y to none. So now is actually minimum like maximum length, where our fish will be so random point in there. Then position x. position x will be equal to screen left. Yep. We left like this. Then we're saying transform dot position equals To position Yes, so this is one separate thing.

So here we are setting up where our fish will be. So it will be around here from this side to this side. And for the wall it will be some length random that we will that we put in. next hour we'll have our float number two, which we which is going to be equal to one that float y equals to unity. And Jen that random dot range ever going from num minus two this is the minimum number minus two to our num plus two. And again, I have this on I always forgot but also num plus two.

Like this. next hour we'll have our actor to be Which is going to be our new vector two sub position it will be for negative position dot x and then y. That will be it for number two and last but not least, it will be our number three, which is going to be equal to three and four it will have delays of flow to delayed delayed equals to Unity engine dot random dot range. So range from zero to r two to multiply by three like this, which actually six for now. So what are we going to do here? Well, right now we are going to have our animation when our fish gets gets hooked.

And it will be like this winner. That Winner Winner Winner equals to transform.do you move to do not do move do move y but do move we're moving in on the we are in the y which Slide it is here. So, this is our non to where it comes in handy from V to number three. So do move and value will be the duration will be non three. So this is our deletion will be three and then snapping it will be false. Like that we'll have set loops, both that loops and influx will be negative one.

So it is setting whoops has no effect if we heart has already started. Number of circus play minus one per infinitive, so we will want to put this infinity loop and then loop type.yo you like this yo Setting the low ping pong option for between has an effect in between the target loop type to behavior default restart. So it will just go back and forth that what yo is all about. What to say here between four and backwards alternative serve cycles is an asset will go just back and forward. Then from there we're going to set is then it will be that linear fee will be in one line will not go up and down just one line. That said delay.

And delay will be our delay that we all we have here calculated so we can see that run range from zero to 2.93. And then the clock base will be on set complete. Then we'll have our delegate put this curly brackets on the say vector three local scale equals to transform dot local scale local scaling this local scale dot x equals to minus or negative local scale that x, low co skill x. And there were saying the transform dot local scale equals to local scale simple and we'll finish this up by adding some I call. So right here we'll have to move our fish and it will be mostly on the x axis because it will just move left and right. So that where our loop Tiger comes in handy, it will be in linear motion so going left to right with delay to point the start and when it's done on setup complete, we are having are no fish because it goes oh no mother when it when it's finished, they're actually just swapping.

So right now we mentioned our fish is like this when it goes the right size commodity and hit the bounce it has to go back but imagine like this imagine fish is here, it goes here and then come back like this like kids here and then come back like this. It makes no sense. So when it hits sunset complete, we will just scale it at negative one. So it actually turns the side you know so that is all about when we hit the bounce which is we move it on the Y on the weenie which is negative position the x it will go from left to right. And when it when it hits the bounce save tip here is here I mean where is it will go to negative One, it goes all the way to the other side and hit the bounds. It will just turn side and continue doing its thing.

So that is what was that all that and guess what, that is not a there is just one more function which is our public void hooked. So this is where our fish gets hooked. And here I said this, this winner was a four. When our fish gets gets hooked, My bet is actually for moving left or right. As for the hooks, we're going to say call Legion that enabled equals false. And we'll have our winner dot kill equals to false meaning that Arduino has done so this is finished the the fish will not move left or right no more.

Sorry guys. That will be it. for setting up our fish Yeah, I mean, you could start the game with this but nothing will happen really because you did not we did not call out our reason fish. And okay, this is for testing purposes. So I'm just testing if I call reset fish here or actually in update function maybe or not here, if I call it will our physical left or right. Let's see Let's check if that is actually going to happen.

I haven't tried it before. But logically, I think it should move left or right. So okay, let me put it just here. So we can see it. I want the hook hook it but we do not have particular hook. And as you see we have a problem.

We have I okay, yeah, we haven't we haven't added this. Maybe if we were to add the votes we could see our fish moving but that's how I mean I could do that but I believe that up to you try that out for yourself because this video is a bit too long and I do not want to expand it with this information that is really not needed. So yeah guys that will be it for this video. You will see the moment for the fish when fish bar comes in. And that will be it. Goodbye guys.

I will see you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.